Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 修复中文顿号列表标记缩进 (#1760)

DavidShenXDf37921468bb0
diff --git a/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts b/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts
index 52ee371930..b5d94dd63f 100644
--- a/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts
+++ b/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts
@@ -1,4 +1,6 @@
// @vitest-environment jsdom
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
import { afterEach, describe, expect, it } from 'vitest';
import { Editor, Node } from '@tiptap/core';
import Document from '@tiptap/extension-document';
@@ -211,6 +213,29 @@ describe('composer structured list input rules', () => {
expect(editor.state.doc.lastChild?.attrs.start).toBe(3);
});
+ it('reserves the full-width CJK marker separately from the ordinal digits', () => {
+ const editor = makeEditor();
+
+ typeThroughInputRules(editor, '2、');
+
+ const list = editor.view.dom.querySelector('ol');
+ expect(list?.getAttribute('data-marker')).toBe('、');
+ expect(list?.getAttribute('data-marker-digits')).toBe('1');
+
+ const css = readFileSync(resolve(__dirname, '..', 'styles', 'globals.css'), 'utf8');
+ const baseListRule = css.match(
+ /\[data-chat-input-root\]\s+\.ProseMirror\s+:is\(ul,\s*ol\)\s*\{([\s\S]*?)\r?\n\s*\}/,
+ )?.[1];
+ const cjkMarkerRule = css.match(
+ /\[data-chat-input-root\]\s+\.ProseMirror\s+ol\[data-marker='、'\]\s*\{([\s\S]*?)\r?\n\s*\}/,
+ )?.[1];
+ expect(baseListRule).toContain('--composer-list-marker-extra: 0em;');
+ expect(baseListRule).toContain(
+ 'var(--composer-list-padding, 1.5em) + var(--composer-list-marker-extra, 0em)',
+ );
+ expect(cjkMarkerRule).toContain('--composer-list-marker-extra: 0.7em;');
+ });
+
it('reserves enough marker width for long ordered-list numbers', () => {
const editor = makeEditor();
diff --git a/apps/desktop/src/renderer/styles/globals.css b/apps/desktop/src/renderer/styles/globals.css
index ab677326b8..2f656107d3 100644
--- a/apps/desktop/src/renderer/styles/globals.css
+++ b/apps/desktop/src/renderer/styles/globals.css
@@ -364,7 +364,16 @@ html:lang(ko) {
[data-chat-input-root] .ProseMirror :is(ul, ol) {
margin: 0;
--composer-list-padding: 1.5em;
- padding-inline-start: var(--composer-list-padding, 1.5em);
+ --composer-list-marker-extra: 0em;
+ padding-inline-start: calc(
+ var(--composer-list-padding, 1.5em) + var(--composer-list-marker-extra, 0em)
+ );
+}
+/* The ideographic comma is a full-width glyph, unlike the period / closing
+ parenthesis in the other ordered markers. Keep its extra width separate
+ from the digit budget so multi-digit ordinals still compose correctly. */
+[data-chat-input-root] .ProseMirror ol[data-marker='、'] {
+ --composer-list-marker-extra: 0.7em;
}
[data-chat-input-root] .ProseMirror ol[data-marker-digits='2'] {
--composer-list-padding: 2.2em;