diff --git a/packages/app-mobile/components/NoteEditor/RichTextEditor.test.tsx b/packages/app-mobile/components/NoteEditor/RichTextEditor.test.tsx index 508a06ec71..1c05ddf60d 100644 --- a/packages/app-mobile/components/NoteEditor/RichTextEditor.test.tsx +++ b/packages/app-mobile/components/NoteEditor/RichTextEditor.test.tsx @@ -406,4 +406,32 @@ describe('RichTextEditor', () => { expect(body.trim()).toBe('# Heading\n\n# Heading 2\n\n[toc]\n\nTest. testing'); }); }); + + it.each([ + '**bold**', + '*italic*', + '$\\text{math}$', + 'test', + '`code`', + '==highlight==ed', + 'Superscript', + 'Subscript', + ])('should preserve inline markup on edit (case %#)', async (initialBody) => { + initialBody += 'test'; // Ensure that typing will add new content outside the formatting + let body = initialBody; + + render( { body = newBody; }} + />); + + await findElement('div.prosemirror-editor'); + + const window = await getEditorWindow(); + mockTyping(window, ' testing'); + + await waitFor(async () => { + expect(body.trim()).toBe(`${initialBody} testing`); + }); + }); }); diff --git a/packages/editor/ProseMirror/schema.ts b/packages/editor/ProseMirror/schema.ts index 2df964da67..4d927a4d50 100644 --- a/packages/editor/ProseMirror/schema.ts +++ b/packages/editor/ProseMirror/schema.ts @@ -21,6 +21,9 @@ const domOutputSpecs = { listItem: ['li', 0], blockQuote: ['blockquote', 0], hr: ['hr'], + sub: ['sub', 0], + sup: ['sup', 0], + mark: ['mark', 0], } satisfies Record; type AttributeSpecs = Record; @@ -216,6 +219,18 @@ const marks = { toDOM: () => domOutputSpecs.code, excludes: '_', }, + sub: { + parseDOM: [{ tag: 'sub' }], + toDOM: () => domOutputSpecs.sub, + }, + sup: { + parseDOM: [{ tag: 'sup' }], + toDOM: () => domOutputSpecs.sup, + }, + mark: { + parseDOM: [{ tag: 'mark' }], + toDOM: () => domOutputSpecs.mark, + }, color: { inclusive: false, parseDOM: [{