diff --git a/packages/core/src/ExtensionManager.ts b/packages/core/src/ExtensionManager.ts index 80ec7e715..5c6ea347c 100644 --- a/packages/core/src/ExtensionManager.ts +++ b/packages/core/src/ExtensionManager.ts @@ -122,14 +122,14 @@ export default class ExtensionManager { getPos: (() => number) | boolean, decorations: Decoration[], ) => { - const attributes = getRenderedAttributes(node, extensionAttributes) + const HTMLAttributes = getRenderedAttributes(node, extensionAttributes) return renderer({ editor, node, getPos, decorations, - attributes, + HTMLAttributes, }) } diff --git a/packages/core/src/MarkExtension.ts b/packages/core/src/MarkExtension.ts index da1d1f41f..36c46bfa1 100644 --- a/packages/core/src/MarkExtension.ts +++ b/packages/core/src/MarkExtension.ts @@ -45,7 +45,7 @@ export interface MarkExtensionSpec extends Overwrit }, props: { mark: Mark, - attributes: { [key: string]: any }, + HTMLAttributes: { [key: string]: any }, } ) => DOMOutputSpec) | null, diff --git a/packages/core/src/NodeExtension.ts b/packages/core/src/NodeExtension.ts index d7401cd13..73c1d90ab 100644 --- a/packages/core/src/NodeExtension.ts +++ b/packages/core/src/NodeExtension.ts @@ -80,7 +80,7 @@ export interface NodeExtensionSpec extends Overwrit }, props: { node: Node, - attributes: { [key: string]: any }, + HTMLAttributes: { [key: string]: any }, } ) => DOMOutputSpec) | null, diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index ff8fcea25..fd0065f09 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -49,7 +49,7 @@ export type NodeViewRendererProps = { node: Node, getPos: (() => number) | boolean, decorations: Decoration[], - attributes: AnyObject, + HTMLAttributes: { [key: string]: any }, } export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView diff --git a/packages/core/src/utils/getSchema.ts b/packages/core/src/utils/getSchema.ts index 1a191f50f..72d3db626 100644 --- a/packages/core/src/utils/getSchema.ts +++ b/packages/core/src/utils/getSchema.ts @@ -50,7 +50,7 @@ export default function getSchema(extensions: Extensions): Schema { if (extension.renderHTML) { schema.toDOM = node => (extension.renderHTML as Function)?.bind(context)({ node, - attributes: getRenderedAttributes(node, extensionAttributes), + HTMLAttributes: getRenderedAttributes(node, extensionAttributes), }) } @@ -79,7 +79,7 @@ export default function getSchema(extensions: Extensions): Schema { if (extension.renderHTML) { schema.toDOM = mark => (extension.renderHTML as Function)?.bind(context)({ mark, - attributes: getRenderedAttributes(mark, extensionAttributes), + HTMLAttributes: getRenderedAttributes(mark, extensionAttributes), }) } diff --git a/packages/extension-blockquote/src/index.ts b/packages/extension-blockquote/src/index.ts index f4995c351..5df5ae473 100644 --- a/packages/extension-blockquote/src/index.ts +++ b/packages/extension-blockquote/src/index.ts @@ -18,8 +18,8 @@ const Blockquote = createNode({ ] }, - renderHTML({ attributes }) { - return ['blockquote', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['blockquote', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-bold/src/index.ts b/packages/extension-bold/src/index.ts index 4b649d4da..ee37ebb43 100644 --- a/packages/extension-bold/src/index.ts +++ b/packages/extension-bold/src/index.ts @@ -26,8 +26,8 @@ const Bold = createMark({ ] }, - renderHTML({ attributes }) { - return ['strong', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['strong', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-bullet-list/src/index.ts b/packages/extension-bullet-list/src/index.ts index cc1c19903..49b6f2923 100644 --- a/packages/extension-bullet-list/src/index.ts +++ b/packages/extension-bullet-list/src/index.ts @@ -16,8 +16,8 @@ const BulletList = createNode({ ] }, - renderHTML({ attributes }) { - return ['ul', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['ul', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-code-block/src/index.ts b/packages/extension-code-block/src/index.ts index 5fa068ec6..d8203b5af 100644 --- a/packages/extension-code-block/src/index.ts +++ b/packages/extension-code-block/src/index.ts @@ -64,8 +64,8 @@ const CodeBlock = createNode({ ] }, - renderHTML({ attributes }) { - return ['pre', ['code', attributes, 0]] + renderHTML({ HTMLAttributes }) { + return ['pre', ['code', HTMLAttributes, 0]] }, addCommands() { diff --git a/packages/extension-code/src/index.ts b/packages/extension-code/src/index.ts index 30679ee19..7b68e0d6c 100644 --- a/packages/extension-code/src/index.ts +++ b/packages/extension-code/src/index.ts @@ -16,8 +16,8 @@ const Code = createMark({ ] }, - renderHTML({ attributes }) { - return ['code', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['code', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-hard-break/src/index.ts b/packages/extension-hard-break/src/index.ts index 95b92ca6e..be300ba90 100644 --- a/packages/extension-hard-break/src/index.ts +++ b/packages/extension-hard-break/src/index.ts @@ -16,8 +16,8 @@ const HardBreak = createNode({ ] }, - renderHTML({ attributes }) { - return ['br', attributes] + renderHTML({ HTMLAttributes }) { + return ['br', HTMLAttributes] }, addCommands() { diff --git a/packages/extension-heading/src/index.ts b/packages/extension-heading/src/index.ts index d5053f7c3..2cef9f7c4 100644 --- a/packages/extension-heading/src/index.ts +++ b/packages/extension-heading/src/index.ts @@ -5,6 +5,9 @@ type Level = 1 | 2 | 3 | 4 | 5 | 6 export interface HeadingOptions { levels: Level[], + HTMLAttributes: { + [key: string]: any + }, } const Heading = createNode({ @@ -12,6 +15,7 @@ const Heading = createNode({ defaultOptions: { levels: [1, 2, 3, 4, 5, 6], + HTMLAttributes: {}, }, content: 'inline*', @@ -37,13 +41,13 @@ const Heading = createNode({ })) }, - renderHTML({ node, attributes }) { + renderHTML({ node, HTMLAttributes }) { const hasLevel = this.options.levels.includes(node.attrs.level) const level = hasLevel ? node.attrs.level : this.options.levels[0] - return [`h${level}`, attributes, 0] + return [`h${level}`, HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-highlight/src/index.ts b/packages/extension-highlight/src/index.ts index fac55d1fb..44586cceb 100644 --- a/packages/extension-highlight/src/index.ts +++ b/packages/extension-highlight/src/index.ts @@ -42,8 +42,8 @@ const Highlight = createMark({ ] }, - renderHTML({ attributes }) { - return ['mark', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['mark', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-horizontal-rule/src/index.ts b/packages/extension-horizontal-rule/src/index.ts index a4dd2ca1c..d0babb665 100644 --- a/packages/extension-horizontal-rule/src/index.ts +++ b/packages/extension-horizontal-rule/src/index.ts @@ -11,8 +11,8 @@ const HorizontalRule = createNode({ ] }, - renderHTML({ attributes }) { - return ['hr', attributes] + renderHTML({ HTMLAttributes }) { + return ['hr', HTMLAttributes] }, addCommands() { diff --git a/packages/extension-image/src/index.ts b/packages/extension-image/src/index.ts index 09ee1318a..1957cddb4 100644 --- a/packages/extension-image/src/index.ts +++ b/packages/extension-image/src/index.ts @@ -45,8 +45,8 @@ const Image = createNode({ ] }, - renderHTML({ attributes }) { - return ['img', attributes] + renderHTML({ HTMLAttributes }) { + return ['img', HTMLAttributes] }, addCommands() { diff --git a/packages/extension-italic/src/index.ts b/packages/extension-italic/src/index.ts index 772a5cba6..ad5a63900 100644 --- a/packages/extension-italic/src/index.ts +++ b/packages/extension-italic/src/index.ts @@ -25,8 +25,8 @@ const Italic = createMark({ ] }, - renderHTML({ attributes }) { - return ['em', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['em', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-link/src/index.ts b/packages/extension-link/src/index.ts index 16c81d956..70334a1ca 100644 --- a/packages/extension-link/src/index.ts +++ b/packages/extension-link/src/index.ts @@ -39,8 +39,8 @@ const Link = createMark({ ] }, - renderHTML({ attributes }) { - return ['a', mergeAttributes(attributes, { rel: this.options.rel }), 0] + renderHTML({ HTMLAttributes }) { + return ['a', mergeAttributes(HTMLAttributes, { rel: this.options.rel }), 0] }, addCommands() { diff --git a/packages/extension-list-item/src/index.ts b/packages/extension-list-item/src/index.ts index f75f5d808..8e3c05bdb 100644 --- a/packages/extension-list-item/src/index.ts +++ b/packages/extension-list-item/src/index.ts @@ -15,8 +15,8 @@ const ListItem = createNode({ ] }, - renderHTML({ attributes }) { - return ['li', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['li', HTMLAttributes, 0] }, addKeyboardShortcuts() { diff --git a/packages/extension-ordered-list/src/index.ts b/packages/extension-ordered-list/src/index.ts index 10ccfd59a..11da5dd67 100644 --- a/packages/extension-ordered-list/src/index.ts +++ b/packages/extension-ordered-list/src/index.ts @@ -31,12 +31,12 @@ const OrderedList = createNode({ ] }, - renderHTML({ attributes }) { - const { start, ...attributesWithoutStart } = attributes + renderHTML({ HTMLAttributes }) { + const { start, ...attributesWithoutStart } = HTMLAttributes return start === 1 ? ['ol', attributesWithoutStart, 0] - : ['ol', attributes, 0] + : ['ol', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-paragraph/src/index.ts b/packages/extension-paragraph/src/index.ts index 6f7c24d8d..246d1ac2c 100644 --- a/packages/extension-paragraph/src/index.ts +++ b/packages/extension-paragraph/src/index.ts @@ -14,8 +14,8 @@ const Paragraph = createNode({ ] }, - renderHTML({ attributes }) { - return ['p', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['p', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-strike/src/index.ts b/packages/extension-strike/src/index.ts index 1775b457f..8856ba6ef 100644 --- a/packages/extension-strike/src/index.ts +++ b/packages/extension-strike/src/index.ts @@ -25,8 +25,8 @@ const Strike = createMark({ ] }, - renderHTML({ attributes }) { - return ['s', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['s', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-task-item/src/index.ts b/packages/extension-task-item/src/index.ts index a30c25ea2..9f3eeb37e 100644 --- a/packages/extension-task-item/src/index.ts +++ b/packages/extension-task-item/src/index.ts @@ -43,8 +43,8 @@ const TaskItem = createNode({ ] }, - renderHTML({ attributes }) { - return ['li', mergeAttributes(attributes, { 'data-type': 'taskItem' }), 0] + renderHTML({ HTMLAttributes }) { + return ['li', mergeAttributes(HTMLAttributes, { 'data-type': 'taskItem' }), 0] }, addKeyboardShortcuts() { @@ -64,7 +64,7 @@ const TaskItem = createNode({ }, addNodeView() { - return ({ attributes, getPos, editor }) => { + return ({ HTMLAttributes, getPos, editor }) => { const { view } = editor const listItem = document.createElement('li') const checkbox = document.createElement('input') @@ -82,13 +82,13 @@ const TaskItem = createNode({ } }) - if (attributes['data-checked'] === true) { + if (HTMLAttributes['data-checked'] === true) { checkbox.setAttribute('checked', 'checked') } listItem.append(checkbox, content) - Object.entries(attributes).forEach(([key, value]) => { + Object.entries(HTMLAttributes).forEach(([key, value]) => { listItem.setAttribute(key, value) }) diff --git a/packages/extension-task-list/src/index.ts b/packages/extension-task-list/src/index.ts index 7f3173d38..862578b2e 100644 --- a/packages/extension-task-list/src/index.ts +++ b/packages/extension-task-list/src/index.ts @@ -16,8 +16,8 @@ const TaskList = createNode({ ] }, - renderHTML({ attributes }) { - return ['ul', mergeAttributes(attributes, { 'data-type': 'taskList' }), 0] + renderHTML({ HTMLAttributes }) { + return ['ul', mergeAttributes(HTMLAttributes, { 'data-type': 'taskList' }), 0] }, addCommands() { diff --git a/packages/extension-text-style/src/index.ts b/packages/extension-text-style/src/index.ts index 73f35981e..1eead702c 100644 --- a/packages/extension-text-style/src/index.ts +++ b/packages/extension-text-style/src/index.ts @@ -20,8 +20,8 @@ const TextStyle = createMark({ ] }, - renderHTML({ attributes }) { - return ['span', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['span', HTMLAttributes, 0] }, addCommands() { diff --git a/packages/extension-underline/src/index.ts b/packages/extension-underline/src/index.ts index 39628b7f6..bd4e00818 100644 --- a/packages/extension-underline/src/index.ts +++ b/packages/extension-underline/src/index.ts @@ -14,8 +14,8 @@ const Underline = createMark({ ] }, - renderHTML({ attributes }) { - return ['u', attributes, 0] + renderHTML({ HTMLAttributes }) { + return ['u', HTMLAttributes, 0] }, addCommands() {