@tiptap/core 3.0.0-beta.25 → 3.0.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +49 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/ExtensionManager.ts +4 -1
- package/src/MarkView.ts +56 -0
- package/src/types.ts +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -1448,8 +1448,9 @@ interface MarkViewRendererProps {
|
|
|
1448
1448
|
* The HTML attributes that should be added to the mark's DOM element.
|
|
1449
1449
|
*/
|
|
1450
1450
|
HTMLAttributes: Record<string, any>;
|
|
1451
|
+
updateAttributes: (attrs: Record<string, any>) => void;
|
|
1451
1452
|
}
|
|
1452
|
-
type MarkViewRenderer = (props:
|
|
1453
|
+
type MarkViewRenderer<Props = MarkViewRendererProps> = (props: Props) => MarkView$1;
|
|
1453
1454
|
interface MarkViewRendererOptions {
|
|
1454
1455
|
ignoreMutation: ((props: {
|
|
1455
1456
|
mutation: ViewMutationRecord;
|
|
@@ -3205,6 +3206,7 @@ declare function Fragment(props: {
|
|
|
3205
3206
|
}): JSXRenderer[];
|
|
3206
3207
|
declare const h: JSXRenderer;
|
|
3207
3208
|
|
|
3209
|
+
declare function updateMarkViewAttributes(checkMark: Mark$1, editor: Editor, attrs?: Record<string, any>): void;
|
|
3208
3210
|
declare class MarkView<Component, Options extends MarkViewRendererOptions = MarkViewRendererOptions> {
|
|
3209
3211
|
component: Component;
|
|
3210
3212
|
editor: Editor;
|
|
@@ -3214,6 +3216,11 @@ declare class MarkView<Component, Options extends MarkViewRendererOptions = Mark
|
|
|
3214
3216
|
constructor(component: Component, props: MarkViewProps, options?: Partial<Options>);
|
|
3215
3217
|
get dom(): HTMLElement;
|
|
3216
3218
|
get contentDOM(): HTMLElement | null;
|
|
3219
|
+
/**
|
|
3220
|
+
* Update the attributes of the mark in the document.
|
|
3221
|
+
* @param attrs The attributes to update.
|
|
3222
|
+
*/
|
|
3223
|
+
updateAttributes(attrs: Record<string, any>, checkMark?: Mark$1): void;
|
|
3217
3224
|
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3218
3225
|
}
|
|
3219
3226
|
|
|
@@ -3377,4 +3384,4 @@ interface Commands<ReturnType = any> {
|
|
|
3377
3384
|
interface Storage {
|
|
3378
3385
|
}
|
|
3379
3386
|
|
|
3380
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
3387
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, updateMarkViewAttributes, wrappingInputRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1448,8 +1448,9 @@ interface MarkViewRendererProps {
|
|
|
1448
1448
|
* The HTML attributes that should be added to the mark's DOM element.
|
|
1449
1449
|
*/
|
|
1450
1450
|
HTMLAttributes: Record<string, any>;
|
|
1451
|
+
updateAttributes: (attrs: Record<string, any>) => void;
|
|
1451
1452
|
}
|
|
1452
|
-
type MarkViewRenderer = (props:
|
|
1453
|
+
type MarkViewRenderer<Props = MarkViewRendererProps> = (props: Props) => MarkView$1;
|
|
1453
1454
|
interface MarkViewRendererOptions {
|
|
1454
1455
|
ignoreMutation: ((props: {
|
|
1455
1456
|
mutation: ViewMutationRecord;
|
|
@@ -3205,6 +3206,7 @@ declare function Fragment(props: {
|
|
|
3205
3206
|
}): JSXRenderer[];
|
|
3206
3207
|
declare const h: JSXRenderer;
|
|
3207
3208
|
|
|
3209
|
+
declare function updateMarkViewAttributes(checkMark: Mark$1, editor: Editor, attrs?: Record<string, any>): void;
|
|
3208
3210
|
declare class MarkView<Component, Options extends MarkViewRendererOptions = MarkViewRendererOptions> {
|
|
3209
3211
|
component: Component;
|
|
3210
3212
|
editor: Editor;
|
|
@@ -3214,6 +3216,11 @@ declare class MarkView<Component, Options extends MarkViewRendererOptions = Mark
|
|
|
3214
3216
|
constructor(component: Component, props: MarkViewProps, options?: Partial<Options>);
|
|
3215
3217
|
get dom(): HTMLElement;
|
|
3216
3218
|
get contentDOM(): HTMLElement | null;
|
|
3219
|
+
/**
|
|
3220
|
+
* Update the attributes of the mark in the document.
|
|
3221
|
+
* @param attrs The attributes to update.
|
|
3222
|
+
*/
|
|
3223
|
+
updateAttributes(attrs: Record<string, any>, checkMark?: Mark$1): void;
|
|
3217
3224
|
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3218
3225
|
}
|
|
3219
3226
|
|
|
@@ -3377,4 +3384,4 @@ interface Commands<ReturnType = any> {
|
|
|
3377
3384
|
interface Storage {
|
|
3378
3385
|
}
|
|
3379
3386
|
|
|
3380
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
3387
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, updateMarkViewAttributes, wrappingInputRule };
|
package/dist/index.js
CHANGED
|
@@ -2269,7 +2269,10 @@ var ExtensionManager = class {
|
|
|
2269
2269
|
// tiptap-specific
|
|
2270
2270
|
editor,
|
|
2271
2271
|
extension,
|
|
2272
|
-
HTMLAttributes
|
|
2272
|
+
HTMLAttributes,
|
|
2273
|
+
updateAttributes: (attrs) => {
|
|
2274
|
+
updateMarkViewAttributes(mark, editor, attrs);
|
|
2275
|
+
}
|
|
2273
2276
|
});
|
|
2274
2277
|
};
|
|
2275
2278
|
return [extension.name, markView];
|
|
@@ -5027,6 +5030,42 @@ function isString(value) {
|
|
|
5027
5030
|
}
|
|
5028
5031
|
|
|
5029
5032
|
// src/MarkView.ts
|
|
5033
|
+
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
5034
|
+
const { state } = editor;
|
|
5035
|
+
const { doc, tr } = state;
|
|
5036
|
+
const thisMark = checkMark;
|
|
5037
|
+
doc.descendants((node, pos) => {
|
|
5038
|
+
const from = tr.mapping.map(pos);
|
|
5039
|
+
const to = tr.mapping.map(pos) + node.nodeSize;
|
|
5040
|
+
let foundMark = null;
|
|
5041
|
+
node.marks.forEach((mark) => {
|
|
5042
|
+
if (mark !== thisMark) {
|
|
5043
|
+
return false;
|
|
5044
|
+
}
|
|
5045
|
+
foundMark = mark;
|
|
5046
|
+
});
|
|
5047
|
+
if (!foundMark) {
|
|
5048
|
+
return;
|
|
5049
|
+
}
|
|
5050
|
+
let needsUpdate = false;
|
|
5051
|
+
Object.keys(attrs).forEach((k) => {
|
|
5052
|
+
if (attrs[k] !== foundMark.attrs[k]) {
|
|
5053
|
+
needsUpdate = true;
|
|
5054
|
+
}
|
|
5055
|
+
});
|
|
5056
|
+
if (needsUpdate) {
|
|
5057
|
+
const updatedMark = checkMark.type.create({
|
|
5058
|
+
...checkMark.attrs,
|
|
5059
|
+
...attrs
|
|
5060
|
+
});
|
|
5061
|
+
tr.removeMark(from, to, checkMark.type);
|
|
5062
|
+
tr.addMark(from, to, updatedMark);
|
|
5063
|
+
}
|
|
5064
|
+
});
|
|
5065
|
+
if (tr.docChanged) {
|
|
5066
|
+
editor.view.dispatch(tr);
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5030
5069
|
var MarkView = class {
|
|
5031
5070
|
constructor(component, props, options) {
|
|
5032
5071
|
this.component = component;
|
|
@@ -5041,6 +5080,13 @@ var MarkView = class {
|
|
|
5041
5080
|
get contentDOM() {
|
|
5042
5081
|
return null;
|
|
5043
5082
|
}
|
|
5083
|
+
/**
|
|
5084
|
+
* Update the attributes of the mark in the document.
|
|
5085
|
+
* @param attrs The attributes to update.
|
|
5086
|
+
*/
|
|
5087
|
+
updateAttributes(attrs, checkMark) {
|
|
5088
|
+
updateMarkViewAttributes(checkMark || this.mark, this.editor, attrs);
|
|
5089
|
+
}
|
|
5044
5090
|
ignoreMutation(mutation) {
|
|
5045
5091
|
if (!this.dom || !this.contentDOM) {
|
|
5046
5092
|
return true;
|
|
@@ -5480,6 +5526,7 @@ export {
|
|
|
5480
5526
|
textInputRule,
|
|
5481
5527
|
textPasteRule,
|
|
5482
5528
|
textblockTypeInputRule,
|
|
5529
|
+
updateMarkViewAttributes,
|
|
5483
5530
|
wrappingInputRule
|
|
5484
5531
|
};
|
|
5485
5532
|
//# sourceMappingURL=index.js.map
|