diff --git a/packages/core/src/Extension.ts b/packages/core/src/Extension.ts index 8bb371240..0f49851c1 100644 --- a/packages/core/src/Extension.ts +++ b/packages/core/src/Extension.ts @@ -108,8 +108,9 @@ declare module '@tiptap/core' { name: string options: Options storage: Storage + extensions: (Node | Mark)[] parent: ParentConfig>['addGlobalAttributes'] - }) => GlobalAttributes | {} + }) => GlobalAttributes /** * This function adds commands to the editor diff --git a/packages/core/src/Mark.ts b/packages/core/src/Mark.ts index 8599bf339..5424e19aa 100644 --- a/packages/core/src/Mark.ts +++ b/packages/core/src/Mark.ts @@ -111,8 +111,9 @@ declare module '@tiptap/core' { name: string options: Options storage: Storage + extensions: (Node | Mark)[] parent: ParentConfig>['addGlobalAttributes'] - }) => GlobalAttributes | {} + }) => GlobalAttributes /** * This function adds commands to the editor diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index cb7bc0cd8..437b02cc9 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -7,6 +7,7 @@ import { Editor } from './Editor.js' import { getExtensionField } from './helpers/getExtensionField.js' import { NodeConfig } from './index.js' import { InputRule } from './InputRule.js' +import { Mark } from './Mark.js' import { PasteRule } from './PasteRule.js' import { AnyConfig, @@ -111,8 +112,9 @@ declare module '@tiptap/core' { name: string options: Options storage: Storage + extensions: (Node | Mark)[] parent: ParentConfig>['addGlobalAttributes'] - }) => GlobalAttributes | {} + }) => GlobalAttributes /** * This function adds commands to the editor diff --git a/packages/core/src/helpers/getAttributesFromExtensions.ts b/packages/core/src/helpers/getAttributesFromExtensions.ts index 2ae8e0f06..8df1f7a9f 100644 --- a/packages/core/src/helpers/getAttributesFromExtensions.ts +++ b/packages/core/src/helpers/getAttributesFromExtensions.ts @@ -5,7 +5,6 @@ import { Attributes, ExtensionAttribute, Extensions, - GlobalAttributes, } from '../types.js' import { getExtensionField } from './getExtensionField.js' import { splitExtensions } from './splitExtensions.js' @@ -32,6 +31,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt name: extension.name, options: extension.options, storage: extension.storage, + extensions: nodeAndMarkExtensions, } const addGlobalAttributes = getExtensionField( @@ -44,8 +44,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt return } - // TODO: remove `as GlobalAttributes` - const globalAttributes = addGlobalAttributes() as GlobalAttributes + const globalAttributes = addGlobalAttributes() globalAttributes.forEach(globalAttribute => { globalAttribute.types.forEach(type => { diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 065d89c0b..41964830c 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -152,7 +152,13 @@ export type ExtensionAttribute = { } export type GlobalAttributes = { + /** + * The node & mark types this attribute should be applied to. + */ types: string[] + /** + * The attributes to add to the node or mark types. + */ attributes: { [key: string]: Attribute }