diff --git a/src/renderer/src/components/editor/rich-markdown-code-mark-order.test.ts b/src/renderer/src/components/editor/rich-markdown-code-mark-order.test.ts deleted file mode 100644 index 6d434311476..00000000000 --- a/src/renderer/src/components/editor/rich-markdown-code-mark-order.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Editor } from '@tiptap/core' -import { describe, expect, it } from 'vitest' -import { encodeRawMarkdownHtmlForRichEditor } from './raw-markdown-html' -import { createRichMarkdownExtensions } from './rich-markdown-extensions' -import { createRichMarkdownEditorCodec } from './rich-markdown-source-transport' - -function roundTrip(source: string): string { - const codec = createRichMarkdownEditorCodec() - const editor = new Editor({ - element: null, - extensions: createRichMarkdownExtensions({ codec }), - content: encodeRawMarkdownHtmlForRichEditor(source, codec), - contentType: 'markdown' - }) - try { - return editor.getMarkdown().trimEnd() - } finally { - editor.destroy() - } -} - -const NESTINGS = [ - ['**`B93934206`**'], - ['`**B93934206**`'], - ['a **`x`** b'], - ['**bold `code` tail**'], - ['*italic `code`*'], - ['`**a**` and **`b`**'], - ['***`x`***'], - ['**`a`** and **b** and `c`'] -] - -describe('code mark ordering', () => { - it.each(NESTINGS)('preserves %j', (source) => { - expect(roundTrip(source)).toBe(source) - }) - - it.each(NESTINGS)('keeps %j stable across three cycles', (source) => { - let current = source - for (let cycle = 0; cycle < 3; cycle += 1) { - current = roundTrip(current) - } - expect(current).toBe(source) - }) - - it.each([ - ['[`label`](https://example.com)'], - ['`code` and [`linked code`](http://x.com) and **bold**'], - ['[**bold link**](http://x.com)'] - ])('leaves the linked code label %j unchanged', (source) => { - expect(roundTrip(source)).toBe(source) - }) - - it('keeps the two nestings distinct', () => { - expect(roundTrip('**`a`**')).not.toBe(roundTrip('`**a**`')) - }) -}) diff --git a/src/renderer/src/components/editor/rich-markdown-extensions.ts b/src/renderer/src/components/editor/rich-markdown-extensions.ts index 77efadd7513..d7fb73fdebe 100644 --- a/src/renderer/src/components/editor/rich-markdown-extensions.ts +++ b/src/renderer/src/components/editor/rich-markdown-extensions.ts @@ -48,11 +48,7 @@ const lowlight = createCachedLowlight(createLowlight(common)) const RichMarkdownCode = Code.extend({ // Why: Markdown supports linked code labels, so code cannot exclude the link // mark even though it should still stay exclusive with emphasis marks. - excludes: 'code bold italic strike underline', - // Why: ProseMirror ranks a text node's marks by schema order, which Tiptap takes - // from priority; code must outrank emphasis so **`x`** serializes with the - // asterisks outside the backticks. - priority: 200 + excludes: 'code bold italic strike underline' }) export function createRichMarkdownExtensions({