TypeScript
fix(web): composer list markers no longer clip in wider prompt fonts (#18972)
Jyrki De Neveea493ec1d888
diff --git a/apps/web/src/composer-rich-text-doc.ts b/apps/web/src/composer-rich-text-doc.tsindex af7fd8c566d..bef884c1862 100644--- a/apps/web/src/composer-rich-text-doc.ts+++ b/apps/web/src/composer-rich-text-doc.ts@@ -262,8 +262,18 @@ const ComposerListItemExtension = ListItem.extend({Delete: () => deleteAcrossList(this.editor),};},+ // ProseMirror can reuse the parent list when only an item's marker changes.+ // Item metadata lets CSS resize its gutter through CommonMark's nine-digit limit.renderHTML({ node, HTMLAttributes }) {- return ["li", mergeAttributes(HTMLAttributes, { "data-marker": node.attrs.marker }), 0];+ const marker = String(node.attrs.marker);+ return [+ "li",+ mergeAttributes(HTMLAttributes, {+ "data-marker": marker,+ "data-marker-width": Math.min(marker.length, 10),+ }),+ 0,+ ];},});diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 76ad4037306..c88c04a327d 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -1869,6 +1869,48 @@ code {content: attr(data-marker) " ";}+/* The prompt font and size can differ from the interface, so its gutter must+ also follow the prompt's font metrics. */+.composer-tiptap ol {+ --list-gutter: max(1.25rem, 3ch);+}++.composer-tiptap ol:has(> li[data-marker-width="3"]) {+ --list-gutter: max(1.25rem, 4ch);+}++.composer-tiptap ol:has(> li[data-marker-width="4"]) {+ --list-gutter: max(1.25rem, 5ch);+}++.composer-tiptap ol:has(> li[data-marker-width="5"]) {+ --list-gutter: max(1.25rem, 6ch);+}++.composer-tiptap ol:has(> li[data-marker-width="6"]) {+ --list-gutter: max(1.25rem, 7ch);+}++.composer-tiptap ol:has(> li[data-marker-width="7"]) {+ --list-gutter: max(1.25rem, 8ch);+}++.composer-tiptap ol:has(> li[data-marker-width="8"]) {+ --list-gutter: max(1.25rem, 9ch);+}++.composer-tiptap ol:has(> li[data-marker-width="9"]) {+ --list-gutter: max(1.25rem, 10ch);+}++.composer-tiptap ol:has(> li[data-marker-width="10"]) {+ --list-gutter: max(1.25rem, 11ch);+}++.composer-tiptap ul {+ padding-left: max(1.25rem, 2ch);+}+:is(.chat-markdown, .composer-tiptap) ul ul {list-style-type: circle;}