fix tests
This commit is contained in:
@@ -39,7 +39,7 @@ export interface MarkExtensionSpec<Options = {}, Commands = {}> extends Overwrit
|
|||||||
/**
|
/**
|
||||||
* Render HTML
|
* Render HTML
|
||||||
*/
|
*/
|
||||||
renderHTML?: (
|
renderHTML?: ((
|
||||||
this: {
|
this: {
|
||||||
options: Options,
|
options: Options,
|
||||||
},
|
},
|
||||||
@@ -47,7 +47,7 @@ export interface MarkExtensionSpec<Options = {}, Commands = {}> extends Overwrit
|
|||||||
mark: Mark,
|
mark: Mark,
|
||||||
attributes: { [key: string]: any },
|
attributes: { [key: string]: any },
|
||||||
}
|
}
|
||||||
) => DOMOutputSpec,
|
) => DOMOutputSpec) | null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes
|
* Attributes
|
||||||
@@ -122,7 +122,7 @@ const defaultMark: MarkExtension = {
|
|||||||
group: null,
|
group: null,
|
||||||
spanning: null,
|
spanning: null,
|
||||||
parseHTML: () => null,
|
parseHTML: () => null,
|
||||||
renderHTML: () => '',
|
renderHTML: null,
|
||||||
addAttributes: () => ({}),
|
addAttributes: () => ({}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export interface NodeExtensionSpec<Options = {}, Commands = {}> extends Overwrit
|
|||||||
/**
|
/**
|
||||||
* Render HTML
|
* Render HTML
|
||||||
*/
|
*/
|
||||||
renderHTML?: (
|
renderHTML?: ((
|
||||||
this: {
|
this: {
|
||||||
options: Options,
|
options: Options,
|
||||||
},
|
},
|
||||||
@@ -82,7 +82,7 @@ export interface NodeExtensionSpec<Options = {}, Commands = {}> extends Overwrit
|
|||||||
node: Node,
|
node: Node,
|
||||||
attributes: { [key: string]: any },
|
attributes: { [key: string]: any },
|
||||||
}
|
}
|
||||||
) => DOMOutputSpec,
|
) => DOMOutputSpec) | null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Attributes
|
* Add Attributes
|
||||||
@@ -164,7 +164,7 @@ const defaultNode: NodeExtension = {
|
|||||||
defining: null,
|
defining: null,
|
||||||
isolating: null,
|
isolating: null,
|
||||||
parseHTML: () => null,
|
parseHTML: () => null,
|
||||||
renderHTML: () => '',
|
renderHTML: null,
|
||||||
addAttributes: () => ({}),
|
addAttributes: () => ({}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,16 +38,18 @@ export default function getSchema(extensions: Extensions): Schema {
|
|||||||
code: extension.code,
|
code: extension.code,
|
||||||
defining: extension.defining,
|
defining: extension.defining,
|
||||||
isolating: extension.isolating,
|
isolating: extension.isolating,
|
||||||
parseDOM: extension.parseHTML.bind(context)(),
|
|
||||||
toDOM: node => {
|
|
||||||
return extension.renderHTML.bind(context)({
|
|
||||||
node,
|
|
||||||
attributes: getRenderedAttributes(node, attributes),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
attrs: Object.fromEntries(attributes.map(attribute => {
|
attrs: Object.fromEntries(attributes.map(attribute => {
|
||||||
return [attribute.name, { default: attribute?.attribute?.default }]
|
return [attribute.name, { default: attribute?.attribute?.default }]
|
||||||
})),
|
})),
|
||||||
|
parseDOM: extension.parseHTML.bind(context)(),
|
||||||
|
...(typeof extension.renderHTML === 'function') && {
|
||||||
|
toDOM: node => {
|
||||||
|
return (extension.renderHTML as Function).bind(context)({
|
||||||
|
node,
|
||||||
|
attributes: getRenderedAttributes(node, attributes),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return [extension.name, schema]
|
return [extension.name, schema]
|
||||||
@@ -65,16 +67,18 @@ export default function getSchema(extensions: Extensions): Schema {
|
|||||||
excludes: extension.excludes,
|
excludes: extension.excludes,
|
||||||
group: extension.group,
|
group: extension.group,
|
||||||
spanning: extension.spanning,
|
spanning: extension.spanning,
|
||||||
parseDOM: extension.parseHTML.bind(context)(),
|
|
||||||
toDOM: mark => {
|
|
||||||
return extension.renderHTML.bind(context)({
|
|
||||||
mark,
|
|
||||||
attributes: getRenderedAttributes(mark, attributes),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
attrs: Object.fromEntries(attributes.map(attribute => {
|
attrs: Object.fromEntries(attributes.map(attribute => {
|
||||||
return [attribute.name, { default: attribute?.attribute?.default }]
|
return [attribute.name, { default: attribute?.attribute?.default }]
|
||||||
})),
|
})),
|
||||||
|
parseDOM: extension.parseHTML.bind(context)(),
|
||||||
|
...(typeof extension.renderHTML === 'function') && {
|
||||||
|
toDOM: mark => {
|
||||||
|
return (extension.renderHTML as Function).bind(context)({
|
||||||
|
mark,
|
||||||
|
attributes: getRenderedAttributes(mark, attributes),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return [extension.name, schema]
|
return [extension.name, schema]
|
||||||
|
|||||||
Reference in New Issue
Block a user