diff --git a/packages/core/src/extensions/BackgroundColor/BackgroundColorMark.ts b/packages/core/src/extensions/BackgroundColor/BackgroundColorMark.ts deleted file mode 100644 index 3c02df0491..0000000000 --- a/packages/core/src/extensions/BackgroundColor/BackgroundColorMark.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Mark } from "@tiptap/core"; -import { createStyleSpecFromTipTapMark } from "../../schema/index.js"; -import { getBackgroundColorAttribute } from "../../blocks/defaultProps.js"; - -const BackgroundColorMark = Mark.create({ - name: "backgroundColor", - - addAttributes() { - return { - stringValue: getBackgroundColorAttribute("stringValue"), - }; - }, - - parseHTML() { - return [ - { - tag: "span", - getAttrs: (element) => { - if (typeof element === "string") { - return false; - } - - if ( - element.hasAttribute("data-background-color") || - element.style.backgroundColor - ) { - return { - stringValue: element.getAttribute("data-background-color"), - }; - } - - return false; - }, - }, - ]; - }, - - renderHTML({ HTMLAttributes }) { - return ["span", HTMLAttributes, 0]; - }, -}); - -export const BackgroundColor = createStyleSpecFromTipTapMark( - BackgroundColorMark, - "string", -); diff --git a/packages/core/src/extensions/TextColor/TextColorMark.ts b/packages/core/src/extensions/TextColor/TextColorMark.ts deleted file mode 100644 index 34ad2335f7..0000000000 --- a/packages/core/src/extensions/TextColor/TextColorMark.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Mark } from "@tiptap/core"; -import { createStyleSpecFromTipTapMark } from "../../schema/index.js"; -import { getTextColorAttribute } from "../../blocks/defaultProps.js"; - -const TextColorMark = Mark.create({ - name: "textColor", - - addAttributes() { - return { - stringValue: getTextColorAttribute("stringValue"), - }; - }, - - parseHTML() { - return [ - { - tag: "span", - getAttrs: (element) => { - if (typeof element === "string") { - return false; - } - - if (element.hasAttribute("data-text-color") || element.style.color) { - return {}; - } - - return false; - }, - }, - ]; - }, - - renderHTML({ HTMLAttributes }) { - return ["span", HTMLAttributes, 0]; - }, -}); - -export const TextColor = createStyleSpecFromTipTapMark(TextColorMark, "string"); diff --git a/packages/core/src/schema/inlineContent/createSpec.ts b/packages/core/src/schema/inlineContent/createSpec.ts index b48fd503b3..f4522936a4 100644 --- a/packages/core/src/schema/inlineContent/createSpec.ts +++ b/packages/core/src/schema/inlineContent/createSpec.ts @@ -81,6 +81,8 @@ export type CustomInlineContentImplementation< contentDOM?: HTMLElement; } | undefined; + + runsBefore?: string[]; }; export function getInlineContentParseRules( @@ -220,6 +222,7 @@ export function createInlineContentSpec< node, inlineContentConfig.propSchema, { + ...inlineContentImplementation, toExternalHTML: inlineContentImplementation.toExternalHTML, render(inlineContent, updateInlineContent, editor) { const output = inlineContentImplementation.render( diff --git a/packages/core/src/schema/inlineContent/types.ts b/packages/core/src/schema/inlineContent/types.ts index 88ebfd740c..4dca7a0aa3 100644 --- a/packages/core/src/schema/inlineContent/types.ts +++ b/packages/core/src/schema/inlineContent/types.ts @@ -43,6 +43,7 @@ export type InlineContentImplementation = ignoreMutation?: (mutation: ViewMutationRecord) => boolean; destroy?: () => void; }; + runsBefore?: string[]; }; export type InlineContentSchemaWithInlineContent< diff --git a/packages/core/src/schema/schema.ts b/packages/core/src/schema/schema.ts index 7accfbfc23..92d0a7ab88 100644 --- a/packages/core/src/schema/schema.ts +++ b/packages/core/src/schema/schema.ts @@ -84,8 +84,12 @@ export class CustomBlockNoteSchema< const defaultSet = new Set(); dag.set("default", defaultSet); - for (const [key, specDef] of Object.entries(this.opts.blockSpecs)) { - if (specDef.implementation.runsBefore) { + for (const [key, specDef] of Object.entries({ + ...this.opts.blockSpecs, + ...this.opts.inlineContentSpecs, + ...this.opts.styleSpecs, + })) { + if (specDef.implementation?.runsBefore) { dag.set(key, new Set(specDef.implementation.runsBefore)); } else { defaultSet.add(key); @@ -130,6 +134,45 @@ export class CustomBlockNoteSchema< : never; }; + const inlineContentSpecs = Object.fromEntries( + Object.entries(this.opts.inlineContentSpecs).map( + ([key, inlineContentSpec]) => { + // Case for text and links. + if (typeof inlineContentSpec.config !== "object") { + return [key, inlineContentSpec]; + } + + return [ + key, + { + ...inlineContentSpec, + implementation: { + ...inlineContentSpec.implementation, + node: inlineContentSpec.implementation?.node.extend({ + priority: getPriority(key), + }), + }, + }, + ]; + }, + ), + ) as InlineContentSpecs; + + const styleSpecs = Object.fromEntries( + Object.entries(this.opts.styleSpecs).map(([key, styleSpec]) => [ + key, + { + ...styleSpec, + implementation: { + ...styleSpec.implementation, + mark: styleSpec.implementation?.mark.extend({ + priority: getPriority(key), + }), + }, + }, + ]), + ) as StyleSpecs; + return { blockSpecs, blockSchema: Object.fromEntries( @@ -137,12 +180,12 @@ export class CustomBlockNoteSchema< return [key, blockDef.config]; }), ) as any, - inlineContentSpecs: removeUndefined(this.opts.inlineContentSpecs), - styleSpecs: removeUndefined(this.opts.styleSpecs), + inlineContentSpecs: removeUndefined(inlineContentSpecs), + styleSpecs: removeUndefined(styleSpecs), inlineContentSchema: getInlineContentSchemaFromSpecs( - this.opts.inlineContentSpecs, + inlineContentSpecs, ) as any, - styleSchema: getStyleSchemaFromSpecs(this.opts.styleSpecs) as any, + styleSchema: getStyleSchemaFromSpecs(styleSpecs) as any, }; } diff --git a/packages/core/src/schema/styles/createSpec.ts b/packages/core/src/schema/styles/createSpec.ts index 4bd83b3ae0..c8700da0f2 100644 --- a/packages/core/src/schema/styles/createSpec.ts +++ b/packages/core/src/schema/styles/createSpec.ts @@ -22,6 +22,7 @@ export type CustomStyleImplementation = { parse?: ( element: HTMLElement, ) => (T["propSchema"] extends "boolean" ? true : string) | undefined; + runsBefore?: string[]; }; export function getStyleParseRules( @@ -46,6 +47,10 @@ export function getStyleParseRules( if (customParseFunction) { rules.push({ tag: "*", + // By default, styles can overlap each other, so the rules should not + // completely consume the element they parse (which can have multiple + // styles). + consuming: false, getAttrs(node: string | HTMLElement) { if (typeof node === "string") { return false; @@ -107,6 +112,7 @@ export function createStyleSpec( }); return createInternalStyleSpec(styleConfig, { + ...styleImplementation, mark, render: (value) => { const renderResult = styleImplementation.render(value as any); diff --git a/packages/core/src/schema/styles/types.ts b/packages/core/src/schema/styles/types.ts index 3be7cb9d6e..a0eeb7e416 100644 --- a/packages/core/src/schema/styles/types.ts +++ b/packages/core/src/schema/styles/types.ts @@ -28,6 +28,7 @@ export type StyleImplementation = { dom: HTMLElement; contentDOM?: HTMLElement; }; + runsBefore?: string[]; }; // Container for both the config and implementation of a Style, diff --git a/packages/react/src/schema/ReactInlineContentSpec.tsx b/packages/react/src/schema/ReactInlineContentSpec.tsx index 872e548351..341c8981e5 100644 --- a/packages/react/src/schema/ReactInlineContentSpec.tsx +++ b/packages/react/src/schema/ReactInlineContentSpec.tsx @@ -233,6 +233,7 @@ export function createReactInlineContentSpec< return createInternalInlineContentSpec( inlineContentConfig as CustomInlineContentConfig, { + ...inlineContentImplementation, node, render(inlineContent, updateInlineContent, editor) { const Content = inlineContentImplementation.render; diff --git a/packages/react/src/schema/ReactStyleSpec.tsx b/packages/react/src/schema/ReactStyleSpec.tsx index b83f727319..27ecbed323 100644 --- a/packages/react/src/schema/ReactStyleSpec.tsx +++ b/packages/react/src/schema/ReactStyleSpec.tsx @@ -23,6 +23,7 @@ export type ReactCustomStyleImplementation = { contentRef: (el: HTMLElement | null) => void; editor: BlockNoteEditor; }>; + runsBefore?: string[]; }; // A function to create custom block for API consumers @@ -116,6 +117,7 @@ export function createReactStyleSpec( }); return createInternalStyleSpec(styleConfig, { + ...styleImplementation, mark, render(value, editor) { const Content = styleImplementation.render; diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/mentionWithBackgroundColor.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/mentionWithBackgroundColor.html new file mode 100644 index 0000000000..f513256411 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/mentionWithBackgroundColor.html @@ -0,0 +1,11 @@ +

Paragraph 1

+

+ @User +

+

Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/copyTestInstances.ts b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts index 6da8382361..17fa89e08d 100644 --- a/tests/src/unit/core/clipboard/copy/copyTestInstances.ts +++ b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts @@ -650,4 +650,30 @@ export const copyTestInstancesHTML: TestInstance< }, executeTest: testCopyHTML, }, + { + testCase: { + name: "mentionWithBackgroundColor", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + { + type: "paragraph", + content: [{ type: "mention", props: { user: "User" } }], + }, + { + type: "paragraph", + content: "Paragraph 2", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Paragraph 2", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, ]; diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/inlineContent/mentionWithToExternalHTML.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/inlineContent/mentionWithToExternalHTML.html index f9de914732..6fee21d4a0 100644 --- a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/inlineContent/mentionWithToExternalHTML.html +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/inlineContent/mentionWithToExternalHTML.html @@ -7,6 +7,7 @@ @Matthew

diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/inlineContent/mentionWithToExternalHTML.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/inlineContent/mentionWithToExternalHTML.html index 5a331bc21d..34f1953ddd 100644 --- a/tests/src/unit/core/formatConversion/export/__snapshots__/html/inlineContent/mentionWithToExternalHTML.html +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/inlineContent/mentionWithToExternalHTML.html @@ -5,5 +5,6 @@ data-external="true" data-inline-content-type="mention" data-user="Matthew" + style="background-color: red;" >@Matthew

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json index 4519c2a743..801547eba0 100644 --- a/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json @@ -4,6 +4,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -26,6 +27,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -48,6 +50,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -70,6 +73,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -92,6 +96,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -114,6 +119,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -136,6 +142,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Paragraph 1", @@ -155,6 +162,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Paragraph 2", @@ -174,6 +182,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Paragraph 3", @@ -193,6 +202,7 @@ "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Paragraph With @@ -213,6 +223,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "bold": true, "textColor": "rgb(0, 0, 0)", }, @@ -221,6 +232,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": " ", @@ -228,6 +240,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "italic": true, "textColor": "rgb(0, 0, 0)", }, @@ -236,6 +249,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": " Underline ", @@ -243,6 +257,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "strike": true, "textColor": "rgb(0, 0, 0)", }, @@ -251,6 +266,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": " ", @@ -258,6 +274,7 @@ Hard Break", }, { "styles": { + "backgroundColor": "transparent", "bold": true, "italic": true, "strike": true, @@ -284,6 +301,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Nested Numbered List Item 1", @@ -303,6 +321,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Nested Numbered List Item 2", @@ -321,6 +340,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Nested Bullet List Item 1", @@ -340,6 +360,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Nested Bullet List Item 2", @@ -358,6 +379,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Bullet List Item 1", @@ -377,6 +399,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Bullet List Item 2", @@ -396,6 +419,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Numbered List Item 1", @@ -415,6 +439,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Numbered List Item 2", @@ -479,6 +504,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 1", @@ -498,6 +524,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 2", @@ -517,6 +544,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 3", @@ -540,6 +568,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 4", @@ -559,6 +588,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 5", @@ -578,6 +608,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 6", @@ -601,6 +632,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 7", @@ -620,6 +652,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 8", @@ -639,6 +672,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Cell 9", @@ -670,6 +704,7 @@ Hard Break", "content": [ { "styles": { + "backgroundColor": "transparent", "textColor": "rgb(0, 0, 0)", }, "text": "Paragraph", diff --git a/tests/src/unit/core/schema/__snapshots__/inlinecontent.json b/tests/src/unit/core/schema/__snapshots__/inlinecontent.json index 6d7bec7453..6109c12530 100644 --- a/tests/src/unit/core/schema/__snapshots__/inlinecontent.json +++ b/tests/src/unit/core/schema/__snapshots__/inlinecontent.json @@ -29,11 +29,31 @@ "inline": true, "name": "mention", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], "selectable": false, }, "name": "mention", - "parent": null, + "parent": _Node { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": true, + "content": "", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "mention", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": false, + }, + "name": "mention", + "parent": null, + "type": "node", + }, "type": "node", }, "config": { @@ -47,14 +67,38 @@ "inline": true, "name": "mention", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], "selectable": false, }, "name": "mention", - "parent": null, + "parent": _Node { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": true, + "content": "", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "mention", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": false, + }, + "name": "mention", + "parent": null, + "type": "node", + }, "type": "node", }, + "parse": [Function], "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": [Function], }, }, @@ -80,11 +124,31 @@ "inline": true, "name": "tag", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], "selectable": true, }, "name": "tag", - "parent": null, + "parent": _Node { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": false, + "content": "inline*", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "tag", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": true, + }, + "name": "tag", + "parent": null, + "type": "node", + }, "type": "node", }, "config": { @@ -98,14 +162,38 @@ "inline": true, "name": "tag", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], "selectable": true, }, "name": "tag", - "parent": null, + "parent": _Node { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": false, + "content": "inline*", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "tag", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": true, + }, + "name": "tag", + "parent": null, + "type": "node", + }, "type": "node", }, + "parse": [Function], "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": undefined, }, }, diff --git a/tests/src/unit/core/schema/__snapshots__/styles.json b/tests/src/unit/core/schema/__snapshots__/styles.json index 44cc9b468e..4ecdb7241e 100644 --- a/tests/src/unit/core/schema/__snapshots__/styles.json +++ b/tests/src/unit/core/schema/__snapshots__/styles.json @@ -14,10 +14,23 @@ "addOptions": [Function], "name": "backgroundColor", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "backgroundColor", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "backgroundColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "backgroundColor", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -25,13 +38,30 @@ "addMarkView": [Function], "name": "backgroundColor", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "backgroundColor", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "backgroundColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "backgroundColor", + "parent": null, + "type": "mark", + }, "type": "mark", }, + "parse": [Function], "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": [Function], }, }, @@ -52,10 +82,26 @@ "addPasteRules": [Function], "name": "bold", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "bold", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "bold", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "bold", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -66,10 +112,26 @@ "addPasteRules": [Function], "name": "bold", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "bold", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "bold", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "bold", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], @@ -96,10 +158,29 @@ "exitable": true, "name": "code", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "code", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "code": true, + "excludes": "_", + "exitable": true, + "name": "code", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "code", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -113,10 +194,29 @@ "exitable": true, "name": "code", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "code", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "code": true, + "excludes": "_", + "exitable": true, + "name": "code", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "code", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], @@ -138,10 +238,23 @@ "addOptions": [Function], "name": "fontSize", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "fontSize", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "fontSize", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "fontSize", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -149,13 +262,29 @@ "addMarkView": [Function], "name": "fontSize", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "fontSize", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "fontSize", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "fontSize", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": [Function], }, }, @@ -176,10 +305,26 @@ "addPasteRules": [Function], "name": "italic", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "italic", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "italic", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "italic", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -190,10 +335,26 @@ "addPasteRules": [Function], "name": "italic", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "italic", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "italic", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "italic", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], @@ -215,10 +376,23 @@ "addOptions": [Function], "name": "small", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "small", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "small", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "small", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -226,13 +400,29 @@ "addMarkView": [Function], "name": "small", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "small", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "small", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "small", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": [Function], }, }, @@ -253,10 +443,26 @@ "addPasteRules": [Function], "name": "strike", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "strike", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "strike", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "strike", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -267,10 +473,26 @@ "addPasteRules": [Function], "name": "strike", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "strike", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "strike", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "strike", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], @@ -292,10 +514,23 @@ "addOptions": [Function], "name": "textColor", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "textColor", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "textColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "textColor", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -303,13 +538,30 @@ "addMarkView": [Function], "name": "textColor", "parseHTML": [Function], + "priority": 121, "renderHTML": [Function], }, "name": "textColor", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "textColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "textColor", + "parent": null, + "type": "mark", + }, "type": "mark", }, + "parse": [Function], "render": [Function], + "runsBefore": [ + "default", + ], "toExternalHTML": [Function], }, }, @@ -328,10 +580,24 @@ "addOptions": [Function], "name": "underline", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "underline", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "name": "underline", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "underline", + "parent": null, + "type": "mark", + }, "type": "mark", }, "config": { @@ -340,10 +606,24 @@ "addOptions": [Function], "name": "underline", "parseHTML": [Function], + "priority": 101, "renderHTML": [Function], }, "name": "underline", - "parent": null, + "parent": _Mark { + "child": [Circular], + "config": { + "addCommands": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "name": "underline", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "underline", + "parent": null, + "type": "mark", + }, "type": "mark", }, "render": [Function], diff --git a/tests/src/unit/core/testSchema.ts b/tests/src/unit/core/testSchema.ts index 537350eb78..24a623aaf6 100644 --- a/tests/src/unit/core/testSchema.ts +++ b/tests/src/unit/core/testSchema.ts @@ -96,6 +96,7 @@ const Mention = createInlineContentSpec( dom.appendChild(document.createTextNode("@" + ic.props.user)); dom.className = "mention-internal"; dom.setAttribute("data-user", ic.props.user); + dom.style.backgroundColor = "red"; return { dom, @@ -110,6 +111,7 @@ const Mention = createInlineContentSpec( // Add attributes needed for round-trip compatibility dom.setAttribute("data-inline-content-type", "mention"); dom.setAttribute("data-user", ic.props.user); + dom.style.backgroundColor = "red"; return { dom,