@domternal/core 0.9.1 → 0.11.0
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/README.md +3 -3
- package/dist/index.cjs +47 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -39
- package/dist/index.d.ts +22 -39
- package/dist/index.js +47 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -83,26 +83,6 @@ interface ContentErrorProps {
|
|
|
83
83
|
/** The original content that failed validation */
|
|
84
84
|
content: unknown;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Props passed to paste event handler
|
|
88
|
-
*/
|
|
89
|
-
interface PasteEventProps {
|
|
90
|
-
editor: EditorInstance;
|
|
91
|
-
event: ClipboardEvent;
|
|
92
|
-
/** ProseMirror Slice of pasted content */
|
|
93
|
-
slice: unknown;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Props passed to drop event handler
|
|
97
|
-
*/
|
|
98
|
-
interface DropEventProps {
|
|
99
|
-
editor: EditorInstance;
|
|
100
|
-
event: DragEvent;
|
|
101
|
-
/** ProseMirror Slice of dropped content */
|
|
102
|
-
slice: unknown;
|
|
103
|
-
/** Whether the content was moved (true) or copied (false) */
|
|
104
|
-
moved: boolean;
|
|
105
|
-
}
|
|
106
86
|
/**
|
|
107
87
|
* Props passed to mount event handler
|
|
108
88
|
*/
|
|
@@ -110,16 +90,6 @@ interface MountEventProps {
|
|
|
110
90
|
editor: EditorInstance;
|
|
111
91
|
view: unknown;
|
|
112
92
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Props passed to delete event handler
|
|
115
|
-
*/
|
|
116
|
-
interface DeleteEventProps {
|
|
117
|
-
editor: EditorInstance;
|
|
118
|
-
/** Start position of deleted content */
|
|
119
|
-
from: number;
|
|
120
|
-
/** End position of deleted content */
|
|
121
|
-
to: number;
|
|
122
|
-
}
|
|
123
93
|
/**
|
|
124
94
|
* Props passed to error event handler (2.7: Extension Error Isolation)
|
|
125
95
|
*/
|
|
@@ -152,16 +122,8 @@ interface EditorEvents {
|
|
|
152
122
|
destroy: undefined;
|
|
153
123
|
/** Fired when content doesn't match schema (AD-8) */
|
|
154
124
|
contentError: ContentErrorProps;
|
|
155
|
-
/** Fired when content is pasted */
|
|
156
|
-
paste: PasteEventProps;
|
|
157
|
-
/** Fired when content is dropped */
|
|
158
|
-
drop: DropEventProps;
|
|
159
125
|
/** Fired when editor view is mounted to DOM */
|
|
160
126
|
mount: MountEventProps;
|
|
161
|
-
/** Fired when editor view is unmounted from DOM */
|
|
162
|
-
unmount: MountEventProps;
|
|
163
|
-
/** Fired when content is deleted */
|
|
164
|
-
delete: DeleteEventProps;
|
|
165
127
|
/** Fired when an extension throws an error (2.7: Extension Error Isolation) */
|
|
166
128
|
error: ErrorEventProps$1;
|
|
167
129
|
/** Fired when link editing UI should open (toolbar link button, Ctrl+K) */
|
|
@@ -2670,6 +2632,27 @@ declare function copyThemeClass(view: {
|
|
|
2670
2632
|
dom: Element;
|
|
2671
2633
|
}, target: Element): void;
|
|
2672
2634
|
|
|
2635
|
+
/**
|
|
2636
|
+
* Return focus to the editor on the next frame after a toolbar / menu command,
|
|
2637
|
+
* UNLESS the command moved focus into a popover input the user is meant to type
|
|
2638
|
+
* into (currently the math LaTeX field).
|
|
2639
|
+
*
|
|
2640
|
+
* The refocus exists so keyboard (Enter / Space) activation of a plain command
|
|
2641
|
+
* button returns the caret to the document and keeps the native `::selection`
|
|
2642
|
+
* highlight. Mouse clicks already keep focus via `mousedown.preventDefault()`.
|
|
2643
|
+
*
|
|
2644
|
+
* A focused element is treated as such a popover when it sits inside a
|
|
2645
|
+
* `[data-dm-editor-ui]` element that is NOT the toolbar / bubble-menu / floating-
|
|
2646
|
+
* menu chrome and is not inside the contenteditable. To opt in, a popover must
|
|
2647
|
+
* render outside those surfaces, carry `data-dm-editor-ui`, and focus itself
|
|
2648
|
+
* synchronously while the opening command dispatches (so `activeElement` reflects
|
|
2649
|
+
* it before this frame runs).
|
|
2650
|
+
*/
|
|
2651
|
+
declare function refocusEditorAfterCommand(view: {
|
|
2652
|
+
dom: Element;
|
|
2653
|
+
focus: () => void;
|
|
2654
|
+
}): void;
|
|
2655
|
+
|
|
2673
2656
|
/**
|
|
2674
2657
|
* Default `contexts` map for a bubble menu when the consumer has not
|
|
2675
2658
|
* supplied one. Returns a richer item set when the editor (or any
|
|
@@ -6459,4 +6442,4 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6459
6442
|
*/
|
|
6460
6443
|
declare const VERSION = "0.1.0";
|
|
6461
6444
|
|
|
6462
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS,
|
|
6445
|
+
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.d.ts
CHANGED
|
@@ -83,26 +83,6 @@ interface ContentErrorProps {
|
|
|
83
83
|
/** The original content that failed validation */
|
|
84
84
|
content: unknown;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Props passed to paste event handler
|
|
88
|
-
*/
|
|
89
|
-
interface PasteEventProps {
|
|
90
|
-
editor: EditorInstance;
|
|
91
|
-
event: ClipboardEvent;
|
|
92
|
-
/** ProseMirror Slice of pasted content */
|
|
93
|
-
slice: unknown;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Props passed to drop event handler
|
|
97
|
-
*/
|
|
98
|
-
interface DropEventProps {
|
|
99
|
-
editor: EditorInstance;
|
|
100
|
-
event: DragEvent;
|
|
101
|
-
/** ProseMirror Slice of dropped content */
|
|
102
|
-
slice: unknown;
|
|
103
|
-
/** Whether the content was moved (true) or copied (false) */
|
|
104
|
-
moved: boolean;
|
|
105
|
-
}
|
|
106
86
|
/**
|
|
107
87
|
* Props passed to mount event handler
|
|
108
88
|
*/
|
|
@@ -110,16 +90,6 @@ interface MountEventProps {
|
|
|
110
90
|
editor: EditorInstance;
|
|
111
91
|
view: unknown;
|
|
112
92
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Props passed to delete event handler
|
|
115
|
-
*/
|
|
116
|
-
interface DeleteEventProps {
|
|
117
|
-
editor: EditorInstance;
|
|
118
|
-
/** Start position of deleted content */
|
|
119
|
-
from: number;
|
|
120
|
-
/** End position of deleted content */
|
|
121
|
-
to: number;
|
|
122
|
-
}
|
|
123
93
|
/**
|
|
124
94
|
* Props passed to error event handler (2.7: Extension Error Isolation)
|
|
125
95
|
*/
|
|
@@ -152,16 +122,8 @@ interface EditorEvents {
|
|
|
152
122
|
destroy: undefined;
|
|
153
123
|
/** Fired when content doesn't match schema (AD-8) */
|
|
154
124
|
contentError: ContentErrorProps;
|
|
155
|
-
/** Fired when content is pasted */
|
|
156
|
-
paste: PasteEventProps;
|
|
157
|
-
/** Fired when content is dropped */
|
|
158
|
-
drop: DropEventProps;
|
|
159
125
|
/** Fired when editor view is mounted to DOM */
|
|
160
126
|
mount: MountEventProps;
|
|
161
|
-
/** Fired when editor view is unmounted from DOM */
|
|
162
|
-
unmount: MountEventProps;
|
|
163
|
-
/** Fired when content is deleted */
|
|
164
|
-
delete: DeleteEventProps;
|
|
165
127
|
/** Fired when an extension throws an error (2.7: Extension Error Isolation) */
|
|
166
128
|
error: ErrorEventProps$1;
|
|
167
129
|
/** Fired when link editing UI should open (toolbar link button, Ctrl+K) */
|
|
@@ -2670,6 +2632,27 @@ declare function copyThemeClass(view: {
|
|
|
2670
2632
|
dom: Element;
|
|
2671
2633
|
}, target: Element): void;
|
|
2672
2634
|
|
|
2635
|
+
/**
|
|
2636
|
+
* Return focus to the editor on the next frame after a toolbar / menu command,
|
|
2637
|
+
* UNLESS the command moved focus into a popover input the user is meant to type
|
|
2638
|
+
* into (currently the math LaTeX field).
|
|
2639
|
+
*
|
|
2640
|
+
* The refocus exists so keyboard (Enter / Space) activation of a plain command
|
|
2641
|
+
* button returns the caret to the document and keeps the native `::selection`
|
|
2642
|
+
* highlight. Mouse clicks already keep focus via `mousedown.preventDefault()`.
|
|
2643
|
+
*
|
|
2644
|
+
* A focused element is treated as such a popover when it sits inside a
|
|
2645
|
+
* `[data-dm-editor-ui]` element that is NOT the toolbar / bubble-menu / floating-
|
|
2646
|
+
* menu chrome and is not inside the contenteditable. To opt in, a popover must
|
|
2647
|
+
* render outside those surfaces, carry `data-dm-editor-ui`, and focus itself
|
|
2648
|
+
* synchronously while the opening command dispatches (so `activeElement` reflects
|
|
2649
|
+
* it before this frame runs).
|
|
2650
|
+
*/
|
|
2651
|
+
declare function refocusEditorAfterCommand(view: {
|
|
2652
|
+
dom: Element;
|
|
2653
|
+
focus: () => void;
|
|
2654
|
+
}): void;
|
|
2655
|
+
|
|
2673
2656
|
/**
|
|
2674
2657
|
* Default `contexts` map for a bubble menu when the consumer has not
|
|
2675
2658
|
* supplied one. Returns a richer item set when the editor (or any
|
|
@@ -6459,4 +6442,4 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6459
6442
|
*/
|
|
6460
6443
|
declare const VERSION = "0.1.0";
|
|
6461
6444
|
|
|
6462
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS,
|
|
6445
|
+
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, BubbleMenu, type BubbleMenuOptions, type BuildCommandPropsOptions, BulletList, type BulletListOptions, type CanChainedCommands, CanChecker, type CanCheckerEditor, type CanCheckerOptions, type CanCommands, ChainBuilder, type ChainBuilderEditor, type ChainBuilderOptions, type ChainFailure, type ChainedCommands, CharacterCount, type CharacterCountOptions, type CharacterCountStorage, type ClearContentOptions, ClearFormatting, Code, CodeBlock, type CodeBlockOptions, type CodeOptions, type Command, type CommandEditor, CommandManager, type CommandManagerEditor, type CommandMap, type CommandProps, type CommandPropsEditor, type CommandSpec, type Content, type ContentErrorProps, type CreateBubbleMenuPluginOptions, type CreateDocumentOptions, type CreateEventProps, type CreateFloatingMenuPluginOptions, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document$1 as Document, Dropcursor, type DropcursorOptions, Editor, type EditorEventName, type EditorEvents, type EditorInstance, type EditorOptions, EventEmitter, Extension, type ExtensionConfig, type ExtensionEditor, ExtensionManager, type ExtensionManagerEditor, type ExtensionManagerOptions, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, type FindChildResult, type FindParentNodeResult, FloatingMenuController, type FloatingMenuGroup, type FloatingMenuItem, type FloatingMenuItemsOverride, type FloatingMenuKeymap, type FloatingMenuOptions, Focus, type FocusEventProps, type FocusOptions, type FocusPosition, FontFamily, type FontFamilyOptions, FontSize, type FontSizeOptions, Gapcursor, type GenerateHTMLOptions, type GenerateJSONOptions, type GenerateTextOptions, type GlobalAttributeSpec, type GlobalAttributes, HardBreak, type HardBreakOptions, Heading, type HeadingOptions, Highlight, type HighlightOptions, History, type HistoryOptions, HorizontalRule, type HorizontalRuleOptions, type IconSet, type InlineStyleOverrides, type InsertAsListItemChildArgs, type InsertAsListItemChildResult, InvisibleChars, type InvisibleCharsOptions, type InvisibleCharsStorage, type IsNodeEmptyOptions, type IsValidUrlOptions, Italic, type ItalicOptions, type JSONAttribute, type JSONContent, type JSONMark, type KeyboardShortcutCommand, LIST_ITEM_TYPE_NAMES, LineHeight, type LineHeightOptions, Link, type LinkAttributes, type LinkClickPluginOptions, type LinkExitPluginOptions, type LinkOptions, type LinkPastePluginOptions, LinkPopover, type LinkPopoverOptions, ListIndent, ListItem, type ListItemCursorContext, type ListItemOptions, ListKeymap, type ListKeymapOptions, Mark, type MarkConfig, type MarkInputRuleOptions, type MarkParseRule, type MarkRange, type MarkRenderHTMLProps, type MountEventProps, Node, type NodeConfig, type NodeInputRuleOptions, type NodeParseRule, type NodeRenderHTMLProps, type NodeViewContext, NotionColorPicker, type NotionColorPickerOptions, type NotionColorPickerStorage, OrderedList, type OrderedListOptions, Paragraph, type ParagraphOptions, Placeholder, type PlaceholderOptions, type PositionFloatingOptions, type Range, type RawCommands, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionStorage, type SetContentOptions, type SingleCommands, type SplitListForInsertRange, StarterKit, type StarterKitOptions, Strike, type StrikeOptions, Subscript, type SubscriptOptions, Superscript, type SuperscriptOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, Text, TextAlign, type TextAlignOptions, TextColor, type TextColorOptions, type TextInputRuleOptions, TextStyle, type TextStyleOptions, type TextblockTypeInputRuleOptions, type ToolbarButton, ToolbarController, type ToolbarControllerEditor, type ToolbarDropdown, type ToolbarGroup, type ToolbarItem, type ToolbarLayoutDropdown, type ToolbarLayoutEntry, type ToolbarSeparator, TrailingNode, type TrailingNodeOptions, type TransactionEventProps, Typography, type TypographyOptions, Underline, type UnderlineOptions, UniqueID, type UniqueIDOptions, VERSION, type WrappingInputRuleOptions, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.js
CHANGED
|
@@ -200,6 +200,7 @@ function inputRulesPlugin({ rules }) {
|
|
|
200
200
|
handleDOMEvents: {
|
|
201
201
|
compositionend: (view) => {
|
|
202
202
|
setTimeout(() => {
|
|
203
|
+
if (view.isDestroyed) return;
|
|
203
204
|
const { $cursor } = view.state.selection;
|
|
204
205
|
if ($cursor) {
|
|
205
206
|
run(view, $cursor.pos, $cursor.pos, "", rules, plugin);
|
|
@@ -1420,26 +1421,31 @@ var insertContent = (content) => ({ state, tr, dispatch }) => {
|
|
|
1420
1421
|
const { schema } = state;
|
|
1421
1422
|
const { from, to } = tr.selection;
|
|
1422
1423
|
let fragment;
|
|
1423
|
-
|
|
1424
|
-
if (typeof
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
if (
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1424
|
+
try {
|
|
1425
|
+
if (typeof content === "string") {
|
|
1426
|
+
if (typeof window === "undefined") {
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
const parser = DOMParser.fromSchema(schema);
|
|
1430
|
+
const wrapper = document.createElement("div");
|
|
1431
|
+
wrapper.innerHTML = content;
|
|
1432
|
+
const parsed = parser.parse(wrapper);
|
|
1433
|
+
fragment = parsed.content;
|
|
1434
|
+
} else if (content && typeof content === "object") {
|
|
1435
|
+
if (Array.isArray(content)) {
|
|
1436
|
+
if (content.length === 0) return false;
|
|
1437
|
+
const nodes = content.map((item) => schema.nodeFromJSON(item));
|
|
1438
|
+
fragment = Fragment.from(nodes);
|
|
1439
|
+
} else if ("type" in content) {
|
|
1440
|
+
const node = schema.nodeFromJSON(content);
|
|
1441
|
+
fragment = node.type.name === "doc" ? node.content : Fragment.from(node);
|
|
1442
|
+
} else {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1439
1445
|
} else {
|
|
1440
1446
|
return false;
|
|
1441
1447
|
}
|
|
1442
|
-
}
|
|
1448
|
+
} catch {
|
|
1443
1449
|
return false;
|
|
1444
1450
|
}
|
|
1445
1451
|
if (!dispatch) {
|
|
@@ -4133,6 +4139,21 @@ function copyThemeClass(view, target) {
|
|
|
4133
4139
|
});
|
|
4134
4140
|
}
|
|
4135
4141
|
|
|
4142
|
+
// src/utils/refocusEditorAfterCommand.ts
|
|
4143
|
+
function refocusEditorAfterCommand(view) {
|
|
4144
|
+
requestAnimationFrame(() => {
|
|
4145
|
+
const ae = document.activeElement;
|
|
4146
|
+
if (!ae) {
|
|
4147
|
+
view.focus();
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4150
|
+
if (ae.closest("[data-dm-editor-ui]") && !ae.closest(".dm-toolbar") && !ae.closest(".dm-bubble-menu") && !ae.closest(".dm-floating-menu") && !view.dom.contains(ae)) {
|
|
4151
|
+
return;
|
|
4152
|
+
}
|
|
4153
|
+
view.focus();
|
|
4154
|
+
});
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4136
4157
|
// src/utils/defaultBubbleContexts.ts
|
|
4137
4158
|
var NOTION_MODE_CLASS = "dm-notion-mode";
|
|
4138
4159
|
var NOTION_TEXT_CONTEXT = Object.freeze([
|
|
@@ -4141,6 +4162,7 @@ var NOTION_TEXT_CONTEXT = Object.freeze([
|
|
|
4141
4162
|
"underline",
|
|
4142
4163
|
"strike",
|
|
4143
4164
|
"code",
|
|
4165
|
+
"mathInline",
|
|
4144
4166
|
"|",
|
|
4145
4167
|
"link",
|
|
4146
4168
|
"|",
|
|
@@ -4152,6 +4174,7 @@ var STANDARD_TEXT_CONTEXT = Object.freeze([
|
|
|
4152
4174
|
"underline",
|
|
4153
4175
|
"strike",
|
|
4154
4176
|
"code",
|
|
4177
|
+
"mathInline",
|
|
4155
4178
|
"|",
|
|
4156
4179
|
"link"
|
|
4157
4180
|
]);
|
|
@@ -5388,6 +5411,9 @@ var defaultIcons = {
|
|
|
5388
5411
|
highlighterCircle: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M201.54,54.46A104,104,0,0,0,54.46,201.54,104,104,0,0,0,201.54,54.46ZM96,210V152h64v58a88.33,88.33,0,0,1-64,0Zm48-74H112V100.94l32-16Zm46.22,54.22A88.09,88.09,0,0,1,176,201.77V152a16,16,0,0,0-16-16V72a8,8,0,0,0-11.58-7.16l-48,24A8,8,0,0,0,96,96v40a16,16,0,0,0-16,16v49.77a88,88,0,1,1,110.22-11.55Z"/></svg>',
|
|
5389
5412
|
textSubscript: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M248,208a8,8,0,0,1-8,8H192a8,8,0,0,1-6.4-12.8l43.17-57.56a16,16,0,1,0-27.86-15,8,8,0,0,1-15.09-5.34,32.18,32.18,0,0,1,4.63-8.59,32,32,0,0,1,51.11,38.52L208,200h32A8,8,0,0,1,248,208ZM149.24,50a8,8,0,0,0-11.29.81L92,103.78l-45.95-53A8,8,0,0,0,34,61.24L81.41,116,34,170.76a8,8,0,0,0,12.1,10.48l46-53,45.95,53a8,8,0,1,0,12.1-10.48L102.59,116l47.46-54.76A8,8,0,0,0,149.24,50Z"/></svg>',
|
|
5390
5413
|
textSuperscript: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M248,144a8,8,0,0,1-8,8H192a8,8,0,0,1-6.4-12.8l43.17-57.55a16,16,0,1,0-27.86-15,8,8,0,0,1-15.09-5.33,32,32,0,1,1,55.74,29.92L208,136h32A8,8,0,0,1,248,144ZM149.24,74a8,8,0,0,0-11.29.8L92,127.79l-45.95-53A8,8,0,0,0,34,85.24L81.41,140,34,194.76a8,8,0,0,0,12.1,10.48l46-53,45.95,53a8,8,0,1,0,12.1-10.48L102.59,140l47.46-54.76A8,8,0,0,0,149.24,74Z"/></svg>',
|
|
5414
|
+
// --- Math ---
|
|
5415
|
+
sigma: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none" stroke="currentColor" stroke-width="18" stroke-linecap="round" stroke-linejoin="round"><path d="M196 56H64l64 72-64 72h132"/></svg>',
|
|
5416
|
+
radical: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="none" stroke="currentColor" stroke-width="18" stroke-linecap="round" stroke-linejoin="round"><path d="M24 150 L66 200 L118 56 L236 56 M150 98 L204 156 M204 98 L150 156"/></svg>',
|
|
5391
5417
|
link: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/></svg>',
|
|
5392
5418
|
// --- Format: Block ---
|
|
5393
5419
|
paragraph: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M208,40H96a64,64,0,0,0,0,128h40v40a8,8,0,0,0,16,0V56h24V208a8,8,0,0,0,16,0V56h16a8,8,0,0,0,0-16ZM136,152H96a48,48,0,0,1,0-96h40Z"/></svg>',
|
|
@@ -5524,7 +5550,7 @@ var Heading = Node2.create({
|
|
|
5524
5550
|
},
|
|
5525
5551
|
renderHTML({ node, HTMLAttributes }) {
|
|
5526
5552
|
const level = node.attrs["level"];
|
|
5527
|
-
const validLevel = this.options.levels.includes(level) ? level : this.options.levels[0];
|
|
5553
|
+
const validLevel = this.options.levels.includes(level) ? level : this.options.levels[0] ?? 1;
|
|
5528
5554
|
return [`h${String(validLevel)}`, { ...this.options.HTMLAttributes, ...HTMLAttributes }, 0];
|
|
5529
5555
|
},
|
|
5530
5556
|
addCommands() {
|
|
@@ -9408,7 +9434,7 @@ var TextColor = Extension.create({
|
|
|
9408
9434
|
return commands.setMark("textStyle", { color, colorToken: null });
|
|
9409
9435
|
},
|
|
9410
9436
|
unsetTextColor: () => ({ commands }) => {
|
|
9411
|
-
if (!commands.setMark("textStyle", { color: null })) return false;
|
|
9437
|
+
if (!commands.setMark("textStyle", { color: null, colorToken: null })) return false;
|
|
9412
9438
|
commands.removeEmptyTextStyle();
|
|
9413
9439
|
return true;
|
|
9414
9440
|
},
|
|
@@ -9553,7 +9579,7 @@ var Highlight = Extension.create({
|
|
|
9553
9579
|
return commands.setMark("textStyle", { backgroundColor: color, backgroundColorToken: null });
|
|
9554
9580
|
},
|
|
9555
9581
|
unsetHighlight: () => ({ commands }) => {
|
|
9556
|
-
if (!commands.setMark("textStyle", { backgroundColor: null })) return false;
|
|
9582
|
+
if (!commands.setMark("textStyle", { backgroundColor: null, backgroundColorToken: null })) return false;
|
|
9557
9583
|
commands.removeEmptyTextStyle();
|
|
9558
9584
|
return true;
|
|
9559
9585
|
},
|
|
@@ -10485,6 +10511,6 @@ var StarterKit = Extension.create({
|
|
|
10485
10511
|
// src/index.ts
|
|
10486
10512
|
var VERSION = "0.1.0";
|
|
10487
10513
|
|
|
10488
|
-
export { BaseKeymap, BlockColor, Blockquote, Bold, BubbleMenu, BulletList, CanChecker, ChainBuilder, CharacterCount, ClearFormatting, Code, CodeBlock, CommandManager, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document, Dropcursor, Editor, EventEmitter, Extension, ExtensionManager, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, FloatingMenuController, Focus, FontFamily, FontSize, Gapcursor, HardBreak, Heading, Highlight, History, HorizontalRule, InvisibleChars, Italic, LIST_ITEM_TYPE_NAMES, LineHeight, Link, LinkPopover, ListIndent, ListItem, ListKeymap, Mark, Node2 as Node, NotionColorPicker, OrderedList, Paragraph, Placeholder, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
10514
|
+
export { BaseKeymap, BlockColor, Blockquote, Bold, BubbleMenu, BulletList, CanChecker, ChainBuilder, CharacterCount, ClearFormatting, Code, CodeBlock, CommandManager, DEFAULT_BLOCK_COLORS, DEFAULT_BLOCK_COLOR_TYPES, DEFAULT_HIGHLIGHT_COLORS, DEFAULT_NOTION_COLOR_PALETTE, DEFAULT_TEXT_COLORS, Document, Dropcursor, Editor, EventEmitter, Extension, ExtensionManager, FLOATING_MENU_META, FLOATING_MENU_NO_FOCUS, FloatingMenuController, Focus, FontFamily, FontSize, Gapcursor, HardBreak, Heading, Highlight, History, HorizontalRule, InvisibleChars, Italic, LIST_ITEM_TYPE_NAMES, LineHeight, Link, LinkPopover, ListIndent, ListItem, ListKeymap, Mark, Node2 as Node, NotionColorPicker, OrderedList, Paragraph, Placeholder, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, applyInlineStyles, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, resetAttributes, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, wrapIn, wrappingInputRule, writeToClipboard };
|
|
10489
10515
|
//# sourceMappingURL=index.js.map
|
|
10490
10516
|
//# sourceMappingURL=index.js.map
|