@tiptap/core 3.21.0 → 3.22.1
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 +66 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +62 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/NodeView.ts +10 -1
- package/src/__tests__/htmlEntities.test.ts +55 -0
- package/src/commands/extendMarkRange.ts +3 -2
- package/src/extensions/delete.ts +2 -1
- package/src/helpers/getMarkRange.ts +7 -2
- package/src/lib/ResizableNodeView.ts +1 -1
- package/src/utilities/htmlEntities.ts +26 -0
- package/src/utilities/index.ts +2 -0
- package/src/utilities/nodeViewPositionRegistry.ts +70 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction, EditorState, Plugin, Selection, NodeSelection, TextSelection, PluginKey } from '@tiptap/pm/state';
|
|
2
2
|
import { Node as Node$1, MarkType as MarkType$1, MarkSpec, Mark as Mark$1, DOMOutputSpec, NodeType as NodeType$1, NodeSpec, Slice, ParseOptions, Fragment as Fragment$1, Schema, ContentMatch, ResolvedPos, ParseRule } from '@tiptap/pm/model';
|
|
3
|
-
import { NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1, EditorProps, EditorView,
|
|
3
|
+
import { NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1, EditorProps, EditorView, Decoration, DecorationAttrs, ViewMutationRecord, DecorationSource } from '@tiptap/pm/view';
|
|
4
4
|
import { Transform, Mappable, MapResult } from '@tiptap/pm/transform';
|
|
5
5
|
|
|
6
6
|
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
@@ -2622,7 +2622,8 @@ declare module '@tiptap/core' {
|
|
|
2622
2622
|
/**
|
|
2623
2623
|
* Extends the text selection to the current mark by type or name.
|
|
2624
2624
|
* @param typeOrName The type or name of the mark.
|
|
2625
|
-
* @param attributes The attributes
|
|
2625
|
+
* @param attributes The attributes to match against.
|
|
2626
|
+
* If not provided, only the first mark at the position will be matched.
|
|
2626
2627
|
* @example editor.commands.extendMarkRange('bold')
|
|
2627
2628
|
* @example editor.commands.extendMarkRange('mention', { userId: "1" })
|
|
2628
2629
|
*/
|
|
@@ -4480,6 +4481,24 @@ declare function findDuplicates<T>(items: T[]): T[];
|
|
|
4480
4481
|
|
|
4481
4482
|
declare function fromString(value: any): any;
|
|
4482
4483
|
|
|
4484
|
+
/**
|
|
4485
|
+
* Decode common HTML entities in text content so they display as literal
|
|
4486
|
+
* characters inside the editor. The decode order matters: `&` must be
|
|
4487
|
+
* decoded **last** so that doubly-encoded sequences like `&lt;` first
|
|
4488
|
+
* survive the `<` pass and then correctly become `<` (not `<`).
|
|
4489
|
+
*/
|
|
4490
|
+
declare function decodeHtmlEntities(text: string): string;
|
|
4491
|
+
/**
|
|
4492
|
+
* Encode HTML special characters so they roundtrip safely through markdown.
|
|
4493
|
+
* `&` is encoded **first** to avoid double-encoding the ampersand in other
|
|
4494
|
+
* entities (e.g. `<` → `<`, not `&lt;`).
|
|
4495
|
+
*
|
|
4496
|
+
* Note: `"` is intentionally NOT encoded here because double quotes are
|
|
4497
|
+
* ordinary characters in markdown and do not need escaping. The decode
|
|
4498
|
+
* function still handles `"` because the markdown tokenizer may emit it.
|
|
4499
|
+
*/
|
|
4500
|
+
declare function encodeHtmlEntities(text: string): string;
|
|
4501
|
+
|
|
4483
4502
|
declare function isAndroid(): boolean;
|
|
4484
4503
|
|
|
4485
4504
|
declare function isEmptyObject(value?: {}): boolean;
|
|
@@ -4928,6 +4947,18 @@ declare function mergeDeep(target: Record<string, any>, source: Record<string, a
|
|
|
4928
4947
|
|
|
4929
4948
|
declare function minMax(value?: number, min?: number, max?: number): number;
|
|
4930
4949
|
|
|
4950
|
+
/**
|
|
4951
|
+
* Register a callback to be called (via a shared rAF) after every editor
|
|
4952
|
+
* update transaction. If this is the first registration for the given editor,
|
|
4953
|
+
* a new registry entry and a single `editor.on('update')` listener are created.
|
|
4954
|
+
*/
|
|
4955
|
+
declare function schedulePositionCheck(editor: Editor, callback: () => void): void;
|
|
4956
|
+
/**
|
|
4957
|
+
* Unregister a previously registered callback. When the last callback for an
|
|
4958
|
+
* editor is removed, the shared listener and any pending rAF are also cleaned up.
|
|
4959
|
+
*/
|
|
4960
|
+
declare function cancelPositionCheck(editor: Editor, callback: () => void): void;
|
|
4961
|
+
|
|
4931
4962
|
/**
|
|
4932
4963
|
* Check if object1 includes object2
|
|
4933
4964
|
* @param object1 Object
|
|
@@ -4951,4 +4982,4 @@ interface Commands<ReturnType = any> {
|
|
|
4951
4982
|
interface Storage {
|
|
4952
4983
|
}
|
|
4953
4984
|
|
|
4954
|
-
export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFirefox, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isSafari, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4985
|
+
export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, cancelPositionCheck, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, decodeHtmlEntities, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, encodeHtmlEntities, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFirefox, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isSafari, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, schedulePositionCheck, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction, EditorState, Plugin, Selection, NodeSelection, TextSelection, PluginKey } from '@tiptap/pm/state';
|
|
2
2
|
import { Node as Node$1, MarkType as MarkType$1, MarkSpec, Mark as Mark$1, DOMOutputSpec, NodeType as NodeType$1, NodeSpec, Slice, ParseOptions, Fragment as Fragment$1, Schema, ContentMatch, ResolvedPos, ParseRule } from '@tiptap/pm/model';
|
|
3
|
-
import { NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1, EditorProps, EditorView,
|
|
3
|
+
import { NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1, EditorProps, EditorView, Decoration, DecorationAttrs, ViewMutationRecord, DecorationSource } from '@tiptap/pm/view';
|
|
4
4
|
import { Transform, Mappable, MapResult } from '@tiptap/pm/transform';
|
|
5
5
|
|
|
6
6
|
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
@@ -2622,7 +2622,8 @@ declare module '@tiptap/core' {
|
|
|
2622
2622
|
/**
|
|
2623
2623
|
* Extends the text selection to the current mark by type or name.
|
|
2624
2624
|
* @param typeOrName The type or name of the mark.
|
|
2625
|
-
* @param attributes The attributes
|
|
2625
|
+
* @param attributes The attributes to match against.
|
|
2626
|
+
* If not provided, only the first mark at the position will be matched.
|
|
2626
2627
|
* @example editor.commands.extendMarkRange('bold')
|
|
2627
2628
|
* @example editor.commands.extendMarkRange('mention', { userId: "1" })
|
|
2628
2629
|
*/
|
|
@@ -4480,6 +4481,24 @@ declare function findDuplicates<T>(items: T[]): T[];
|
|
|
4480
4481
|
|
|
4481
4482
|
declare function fromString(value: any): any;
|
|
4482
4483
|
|
|
4484
|
+
/**
|
|
4485
|
+
* Decode common HTML entities in text content so they display as literal
|
|
4486
|
+
* characters inside the editor. The decode order matters: `&` must be
|
|
4487
|
+
* decoded **last** so that doubly-encoded sequences like `&lt;` first
|
|
4488
|
+
* survive the `<` pass and then correctly become `<` (not `<`).
|
|
4489
|
+
*/
|
|
4490
|
+
declare function decodeHtmlEntities(text: string): string;
|
|
4491
|
+
/**
|
|
4492
|
+
* Encode HTML special characters so they roundtrip safely through markdown.
|
|
4493
|
+
* `&` is encoded **first** to avoid double-encoding the ampersand in other
|
|
4494
|
+
* entities (e.g. `<` → `<`, not `&lt;`).
|
|
4495
|
+
*
|
|
4496
|
+
* Note: `"` is intentionally NOT encoded here because double quotes are
|
|
4497
|
+
* ordinary characters in markdown and do not need escaping. The decode
|
|
4498
|
+
* function still handles `"` because the markdown tokenizer may emit it.
|
|
4499
|
+
*/
|
|
4500
|
+
declare function encodeHtmlEntities(text: string): string;
|
|
4501
|
+
|
|
4483
4502
|
declare function isAndroid(): boolean;
|
|
4484
4503
|
|
|
4485
4504
|
declare function isEmptyObject(value?: {}): boolean;
|
|
@@ -4928,6 +4947,18 @@ declare function mergeDeep(target: Record<string, any>, source: Record<string, a
|
|
|
4928
4947
|
|
|
4929
4948
|
declare function minMax(value?: number, min?: number, max?: number): number;
|
|
4930
4949
|
|
|
4950
|
+
/**
|
|
4951
|
+
* Register a callback to be called (via a shared rAF) after every editor
|
|
4952
|
+
* update transaction. If this is the first registration for the given editor,
|
|
4953
|
+
* a new registry entry and a single `editor.on('update')` listener are created.
|
|
4954
|
+
*/
|
|
4955
|
+
declare function schedulePositionCheck(editor: Editor, callback: () => void): void;
|
|
4956
|
+
/**
|
|
4957
|
+
* Unregister a previously registered callback. When the last callback for an
|
|
4958
|
+
* editor is removed, the shared listener and any pending rAF are also cleaned up.
|
|
4959
|
+
*/
|
|
4960
|
+
declare function cancelPositionCheck(editor: Editor, callback: () => void): void;
|
|
4961
|
+
|
|
4931
4962
|
/**
|
|
4932
4963
|
* Check if object1 includes object2
|
|
4933
4964
|
* @param object1 Object
|
|
@@ -4951,4 +4982,4 @@ interface Commands<ReturnType = any> {
|
|
|
4951
4982
|
interface Storage {
|
|
4952
4983
|
}
|
|
4953
4984
|
|
|
4954
|
-
export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFirefox, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isSafari, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
|
4985
|
+
export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, cancelPositionCheck, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, decodeHtmlEntities, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, encodeHtmlEntities, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFirefox, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isSafari, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, schedulePositionCheck, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
|
package/dist/index.js
CHANGED
|
@@ -397,7 +397,6 @@ function isMarkInSet(marks, type, attributes = {}) {
|
|
|
397
397
|
return !!findMarkInSet(marks, type, attributes);
|
|
398
398
|
}
|
|
399
399
|
function getMarkRange($pos, type, attributes) {
|
|
400
|
-
var _a;
|
|
401
400
|
if (!$pos || !type) {
|
|
402
401
|
return;
|
|
403
402
|
}
|
|
@@ -408,7 +407,12 @@ function getMarkRange($pos, type, attributes) {
|
|
|
408
407
|
if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
|
|
409
408
|
return;
|
|
410
409
|
}
|
|
411
|
-
|
|
410
|
+
if (!attributes) {
|
|
411
|
+
const firstMark = start.node.marks.find((mark2) => mark2.type === type);
|
|
412
|
+
if (firstMark) {
|
|
413
|
+
attributes = firstMark.attrs;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
412
416
|
const mark = findMarkInSet([...start.node.marks], type, attributes);
|
|
413
417
|
if (!mark) {
|
|
414
418
|
return;
|
|
@@ -443,7 +447,7 @@ function getMarkType(nameOrType, schema) {
|
|
|
443
447
|
}
|
|
444
448
|
|
|
445
449
|
// src/commands/extendMarkRange.ts
|
|
446
|
-
var extendMarkRange = (typeOrName, attributes
|
|
450
|
+
var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
|
|
447
451
|
const type = getMarkType(typeOrName, state.schema);
|
|
448
452
|
const { doc, selection } = tr;
|
|
449
453
|
const { $from, from, to } = selection;
|
|
@@ -4017,7 +4021,7 @@ var Delete = Extension.create({
|
|
|
4017
4021
|
const newEnd = mapping.slice(index).map(step.to);
|
|
4018
4022
|
const oldStart = mapping.invert().map(newStart, -1);
|
|
4019
4023
|
const oldEnd = mapping.invert().map(newEnd);
|
|
4020
|
-
const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
|
|
4024
|
+
const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
|
|
4021
4025
|
const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
|
|
4022
4026
|
this.editor.emit("delete", {
|
|
4023
4027
|
type: "mark",
|
|
@@ -5591,7 +5595,7 @@ var ResizableNodeView = class {
|
|
|
5591
5595
|
const element = document.createElement("div");
|
|
5592
5596
|
element.dataset.resizeContainer = "";
|
|
5593
5597
|
element.dataset.node = this.node.type.name;
|
|
5594
|
-
element.style.display = "flex";
|
|
5598
|
+
element.style.display = this.node.type.isInline ? "inline-flex" : "flex";
|
|
5595
5599
|
if (this.classNames.container) {
|
|
5596
5600
|
element.className = this.classNames.container;
|
|
5597
5601
|
}
|
|
@@ -5942,6 +5946,14 @@ function escapeForRegEx(string) {
|
|
|
5942
5946
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
5943
5947
|
}
|
|
5944
5948
|
|
|
5949
|
+
// src/utilities/htmlEntities.ts
|
|
5950
|
+
function decodeHtmlEntities(text) {
|
|
5951
|
+
return text.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
|
|
5952
|
+
}
|
|
5953
|
+
function encodeHtmlEntities(text) {
|
|
5954
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
5955
|
+
}
|
|
5956
|
+
|
|
5945
5957
|
// src/utilities/isFirefox.ts
|
|
5946
5958
|
function isFirefox() {
|
|
5947
5959
|
return typeof navigator !== "undefined" ? /Firefox/.test(navigator.userAgent) : false;
|
|
@@ -6445,6 +6457,45 @@ ${indentedChild}`;
|
|
|
6445
6457
|
return output;
|
|
6446
6458
|
}
|
|
6447
6459
|
|
|
6460
|
+
// src/utilities/nodeViewPositionRegistry.ts
|
|
6461
|
+
var positionUpdateRegistries = /* @__PURE__ */ new WeakMap();
|
|
6462
|
+
function schedulePositionCheck(editor, callback) {
|
|
6463
|
+
let registry = positionUpdateRegistries.get(editor);
|
|
6464
|
+
if (!registry) {
|
|
6465
|
+
const newRegistry = {
|
|
6466
|
+
callbacks: /* @__PURE__ */ new Set(),
|
|
6467
|
+
rafId: null,
|
|
6468
|
+
handler: () => {
|
|
6469
|
+
if (newRegistry.rafId !== null) {
|
|
6470
|
+
cancelAnimationFrame(newRegistry.rafId);
|
|
6471
|
+
}
|
|
6472
|
+
newRegistry.rafId = requestAnimationFrame(() => {
|
|
6473
|
+
newRegistry.rafId = null;
|
|
6474
|
+
newRegistry.callbacks.forEach((cb) => cb());
|
|
6475
|
+
});
|
|
6476
|
+
}
|
|
6477
|
+
};
|
|
6478
|
+
positionUpdateRegistries.set(editor, newRegistry);
|
|
6479
|
+
editor.on("update", newRegistry.handler);
|
|
6480
|
+
registry = newRegistry;
|
|
6481
|
+
}
|
|
6482
|
+
registry.callbacks.add(callback);
|
|
6483
|
+
}
|
|
6484
|
+
function cancelPositionCheck(editor, callback) {
|
|
6485
|
+
const registry = positionUpdateRegistries.get(editor);
|
|
6486
|
+
if (!registry) {
|
|
6487
|
+
return;
|
|
6488
|
+
}
|
|
6489
|
+
registry.callbacks.delete(callback);
|
|
6490
|
+
if (registry.callbacks.size === 0) {
|
|
6491
|
+
if (registry.rafId !== null) {
|
|
6492
|
+
cancelAnimationFrame(registry.rafId);
|
|
6493
|
+
}
|
|
6494
|
+
editor.off("update", registry.handler);
|
|
6495
|
+
positionUpdateRegistries.delete(editor);
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6448
6499
|
// src/MarkView.ts
|
|
6449
6500
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
6450
6501
|
const { state } = editor;
|
|
@@ -6651,6 +6702,7 @@ var NodeView = class {
|
|
|
6651
6702
|
return false;
|
|
6652
6703
|
}
|
|
6653
6704
|
const isDragEvent = event.type.startsWith("drag");
|
|
6705
|
+
const isDragOverEnterEvent = event.type === "dragover" || event.type === "dragenter";
|
|
6654
6706
|
const isDropEvent = event.type === "drop";
|
|
6655
6707
|
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
6656
6708
|
if (isInput && !isDropEvent && !isDragEvent) {
|
|
@@ -6699,7 +6751,7 @@ var NodeView = class {
|
|
|
6699
6751
|
);
|
|
6700
6752
|
}
|
|
6701
6753
|
}
|
|
6702
|
-
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
6754
|
+
if (isDragging || isDragOverEnterEvent || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
6703
6755
|
return false;
|
|
6704
6756
|
}
|
|
6705
6757
|
return true;
|
|
@@ -6887,6 +6939,7 @@ export {
|
|
|
6887
6939
|
Tracker,
|
|
6888
6940
|
callOrReturn,
|
|
6889
6941
|
canInsertNode,
|
|
6942
|
+
cancelPositionCheck,
|
|
6890
6943
|
combineTransactionSteps,
|
|
6891
6944
|
commands_exports as commands,
|
|
6892
6945
|
createAtomBlockMarkdownSpec,
|
|
@@ -6898,9 +6951,11 @@ export {
|
|
|
6898
6951
|
createMappablePosition,
|
|
6899
6952
|
createNodeFromContent,
|
|
6900
6953
|
createStyleTag,
|
|
6954
|
+
decodeHtmlEntities,
|
|
6901
6955
|
defaultBlockAt,
|
|
6902
6956
|
deleteProps,
|
|
6903
6957
|
elementFromString,
|
|
6958
|
+
encodeHtmlEntities,
|
|
6904
6959
|
escapeForRegEx,
|
|
6905
6960
|
extensions_exports as extensions,
|
|
6906
6961
|
findChildren,
|
|
@@ -6979,6 +7034,7 @@ export {
|
|
|
6979
7034
|
resolveExtensions,
|
|
6980
7035
|
resolveFocusPosition,
|
|
6981
7036
|
rewriteUnknownContent,
|
|
7037
|
+
schedulePositionCheck,
|
|
6982
7038
|
selectionToInsertionEnd,
|
|
6983
7039
|
serializeAttributes,
|
|
6984
7040
|
sortExtensions,
|