@domternal/core 1.0.2 → 1.1.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 +22 -0
- package/dist/index.cjs +121 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -10
- package/dist/index.d.ts +38 -10
- package/dist/index.js +122 -27
- package/dist/index.js.map +1 -1
- package/package.json +12 -14
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema, Node as Node$1, DOMOutputSpec, NodeType, Mark as Mark$1, MarkType, Attrs, ResolvedPos, DOMParser, ContentMatch, NodeSpec, MarkSpec } from '@domternal/pm/model';
|
|
2
|
-
import { Transaction, EditorState, Plugin, PluginKey, Selection as Selection$1 } from '@domternal/pm/state';
|
|
2
|
+
import { Transaction, EditorState, Plugin, PluginKey, PluginView, Selection as Selection$1 } from '@domternal/pm/state';
|
|
3
3
|
export { PluginKey } from '@domternal/pm/state';
|
|
4
|
+
import { EditorView, NodeViewConstructor } from '@domternal/pm/view';
|
|
4
5
|
import { InputRule } from '@domternal/pm/inputrules';
|
|
5
|
-
import { NodeViewConstructor, EditorView } from '@domternal/pm/view';
|
|
6
6
|
import { Placement } from '@floating-ui/dom';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -90,6 +90,15 @@ interface MountEventProps {
|
|
|
90
90
|
editor: EditorInstance;
|
|
91
91
|
view: unknown;
|
|
92
92
|
}
|
|
93
|
+
/** The editor view has moved to a different DOM mounting context. */
|
|
94
|
+
interface AdoptEventProps {
|
|
95
|
+
editor: EditorInstance;
|
|
96
|
+
view: EditorView;
|
|
97
|
+
element: HTMLElement;
|
|
98
|
+
/** The closest editor UI host, if the consumer provides one. */
|
|
99
|
+
host: HTMLElement | null;
|
|
100
|
+
previousHost: HTMLElement | null;
|
|
101
|
+
}
|
|
93
102
|
/**
|
|
94
103
|
* Props passed to error event handler (2.7: Extension Error Isolation)
|
|
95
104
|
*/
|
|
@@ -124,6 +133,8 @@ interface EditorEvents {
|
|
|
124
133
|
contentError: ContentErrorProps;
|
|
125
134
|
/** Fired when editor view is mounted to DOM */
|
|
126
135
|
mount: MountEventProps;
|
|
136
|
+
/** Fired after adopting the existing view into a different DOM context. */
|
|
137
|
+
adopt: AdoptEventProps;
|
|
127
138
|
/** Fired when an extension throws an error (2.7: Extension Error Isolation) */
|
|
128
139
|
error: ErrorEventProps$1;
|
|
129
140
|
/** Fired when link editing UI should open (toolbar link button, Ctrl+K) */
|
|
@@ -1136,6 +1147,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1136
1147
|
* editor itself added, never one the consumer wrote.
|
|
1137
1148
|
*/
|
|
1138
1149
|
private _presetClassHost;
|
|
1150
|
+
private _domContext;
|
|
1139
1151
|
/**
|
|
1140
1152
|
* Creates a new Editor instance
|
|
1141
1153
|
*
|
|
@@ -1173,9 +1185,16 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1173
1185
|
* wrappers call it again after adopting the view's DOM: they construct
|
|
1174
1186
|
* the editor in a detached element, so the creation-time run cannot see
|
|
1175
1187
|
* the host yet. Idempotent; a no-op for any other preset. Only a class
|
|
1176
|
-
* added here is removed
|
|
1188
|
+
* added here is removed when the host changes or the editor is destroyed.
|
|
1177
1189
|
*/
|
|
1178
1190
|
adoptPresetClass(): void;
|
|
1191
|
+
/**
|
|
1192
|
+
* Moves the existing view into a mount element without recreating its state.
|
|
1193
|
+
* Host-dependent UI receives an `adopt` event after the move. Calling this
|
|
1194
|
+
* again with the same DOM context is a no-op. The original `mount` and
|
|
1195
|
+
* `create` events remain creation-time events.
|
|
1196
|
+
*/
|
|
1197
|
+
adoptDom(element: HTMLElement): this;
|
|
1179
1198
|
/**
|
|
1180
1199
|
* Checks if the editor content is empty
|
|
1181
1200
|
*/
|
|
@@ -1336,6 +1355,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1336
1355
|
* Creates the editor instance
|
|
1337
1356
|
*/
|
|
1338
1357
|
private createEditor;
|
|
1358
|
+
private captureDomContext;
|
|
1339
1359
|
/**
|
|
1340
1360
|
* Builds the dispatchTransaction prop. Plugin views can dispatch synchronously
|
|
1341
1361
|
* inside EditorView's constructor, before `editor.view` is assigned; ProseMirror
|
|
@@ -1420,11 +1440,12 @@ interface FloatingMenuItem {
|
|
|
1420
1440
|
*/
|
|
1421
1441
|
isDisabled?: (editor: Editor) => boolean;
|
|
1422
1442
|
/**
|
|
1423
|
-
* Node-type names that
|
|
1424
|
-
* the
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
* the
|
|
1443
|
+
* Node-type names that cause the slash menu to hide this item when they
|
|
1444
|
+
* contain the cursor. Does not affect the separate floating menu.
|
|
1445
|
+
*
|
|
1446
|
+
* Non-list names match any cursor ancestor. List containers only match
|
|
1447
|
+
* the nearest wrapping list while the cursor is in its item's first-child
|
|
1448
|
+
* label slot. Later child paragraphs keep the item available for nesting.
|
|
1428
1449
|
*/
|
|
1429
1450
|
hideWhenInside?: string[];
|
|
1430
1451
|
}
|
|
@@ -2814,6 +2835,13 @@ declare function refocusEditorAfterCommand(view: {
|
|
|
2814
2835
|
focus: () => void;
|
|
2815
2836
|
}): void;
|
|
2816
2837
|
|
|
2838
|
+
/**
|
|
2839
|
+
* Rebinds a DOM-dependent plugin view when the editor changes its mount host.
|
|
2840
|
+
* Only this view's UI resources are recreated; plugin state and editor history
|
|
2841
|
+
* stay intact. Initial setup still runs immediately, including detached views.
|
|
2842
|
+
*/
|
|
2843
|
+
declare function createAdoptablePluginView(editor: Editor | null, view: EditorView, createView: (view: EditorView) => PluginView): PluginView;
|
|
2844
|
+
|
|
2817
2845
|
/**
|
|
2818
2846
|
* Default `contexts` map for a bubble menu when the consumer has not
|
|
2819
2847
|
* supplied one. Returns a richer item set when the editor resolves to the
|
|
@@ -6913,6 +6941,6 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6913
6941
|
* @domternal/core
|
|
6914
6942
|
* Framework-agnostic ProseMirror editor engine
|
|
6915
6943
|
*/
|
|
6916
|
-
declare const VERSION = "1.0
|
|
6944
|
+
declare const VERSION = "1.1.0";
|
|
6917
6945
|
|
|
6918
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, type BubbleContexts, type BubbleItemMaps, BubbleMenu, type BubbleMenuItem, type BubbleMenuOptions, type BubbleMenuSeparator, 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, type EditorPreset, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, 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, Print, type PrintOptions, type PrintStorage, type ProseMirrorCopyConflict, type Range, type RawCommands, type ResolveBubbleMenuItemsOptions, type ResolvedPosShape, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionShape, 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, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
|
6946
|
+
export { type AdoptEventProps, type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, type BubbleContexts, type BubbleItemMaps, BubbleMenu, type BubbleMenuItem, type BubbleMenuOptions, type BubbleMenuSeparator, 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, type EditorPreset, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, 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, Print, type PrintOptions, type PrintStorage, type ProseMirrorCopyConflict, type Range, type RawCommands, type ResolveBubbleMenuItemsOptions, type ResolvedPosShape, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionShape, 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, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createAdoptablePluginView, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema, Node as Node$1, DOMOutputSpec, NodeType, Mark as Mark$1, MarkType, Attrs, ResolvedPos, DOMParser, ContentMatch, NodeSpec, MarkSpec } from '@domternal/pm/model';
|
|
2
|
-
import { Transaction, EditorState, Plugin, PluginKey, Selection as Selection$1 } from '@domternal/pm/state';
|
|
2
|
+
import { Transaction, EditorState, Plugin, PluginKey, PluginView, Selection as Selection$1 } from '@domternal/pm/state';
|
|
3
3
|
export { PluginKey } from '@domternal/pm/state';
|
|
4
|
+
import { EditorView, NodeViewConstructor } from '@domternal/pm/view';
|
|
4
5
|
import { InputRule } from '@domternal/pm/inputrules';
|
|
5
|
-
import { NodeViewConstructor, EditorView } from '@domternal/pm/view';
|
|
6
6
|
import { Placement } from '@floating-ui/dom';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -90,6 +90,15 @@ interface MountEventProps {
|
|
|
90
90
|
editor: EditorInstance;
|
|
91
91
|
view: unknown;
|
|
92
92
|
}
|
|
93
|
+
/** The editor view has moved to a different DOM mounting context. */
|
|
94
|
+
interface AdoptEventProps {
|
|
95
|
+
editor: EditorInstance;
|
|
96
|
+
view: EditorView;
|
|
97
|
+
element: HTMLElement;
|
|
98
|
+
/** The closest editor UI host, if the consumer provides one. */
|
|
99
|
+
host: HTMLElement | null;
|
|
100
|
+
previousHost: HTMLElement | null;
|
|
101
|
+
}
|
|
93
102
|
/**
|
|
94
103
|
* Props passed to error event handler (2.7: Extension Error Isolation)
|
|
95
104
|
*/
|
|
@@ -124,6 +133,8 @@ interface EditorEvents {
|
|
|
124
133
|
contentError: ContentErrorProps;
|
|
125
134
|
/** Fired when editor view is mounted to DOM */
|
|
126
135
|
mount: MountEventProps;
|
|
136
|
+
/** Fired after adopting the existing view into a different DOM context. */
|
|
137
|
+
adopt: AdoptEventProps;
|
|
127
138
|
/** Fired when an extension throws an error (2.7: Extension Error Isolation) */
|
|
128
139
|
error: ErrorEventProps$1;
|
|
129
140
|
/** Fired when link editing UI should open (toolbar link button, Ctrl+K) */
|
|
@@ -1136,6 +1147,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1136
1147
|
* editor itself added, never one the consumer wrote.
|
|
1137
1148
|
*/
|
|
1138
1149
|
private _presetClassHost;
|
|
1150
|
+
private _domContext;
|
|
1139
1151
|
/**
|
|
1140
1152
|
* Creates a new Editor instance
|
|
1141
1153
|
*
|
|
@@ -1173,9 +1185,16 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1173
1185
|
* wrappers call it again after adopting the view's DOM: they construct
|
|
1174
1186
|
* the editor in a detached element, so the creation-time run cannot see
|
|
1175
1187
|
* the host yet. Idempotent; a no-op for any other preset. Only a class
|
|
1176
|
-
* added here is removed
|
|
1188
|
+
* added here is removed when the host changes or the editor is destroyed.
|
|
1177
1189
|
*/
|
|
1178
1190
|
adoptPresetClass(): void;
|
|
1191
|
+
/**
|
|
1192
|
+
* Moves the existing view into a mount element without recreating its state.
|
|
1193
|
+
* Host-dependent UI receives an `adopt` event after the move. Calling this
|
|
1194
|
+
* again with the same DOM context is a no-op. The original `mount` and
|
|
1195
|
+
* `create` events remain creation-time events.
|
|
1196
|
+
*/
|
|
1197
|
+
adoptDom(element: HTMLElement): this;
|
|
1179
1198
|
/**
|
|
1180
1199
|
* Checks if the editor content is empty
|
|
1181
1200
|
*/
|
|
@@ -1336,6 +1355,7 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
1336
1355
|
* Creates the editor instance
|
|
1337
1356
|
*/
|
|
1338
1357
|
private createEditor;
|
|
1358
|
+
private captureDomContext;
|
|
1339
1359
|
/**
|
|
1340
1360
|
* Builds the dispatchTransaction prop. Plugin views can dispatch synchronously
|
|
1341
1361
|
* inside EditorView's constructor, before `editor.view` is assigned; ProseMirror
|
|
@@ -1420,11 +1440,12 @@ interface FloatingMenuItem {
|
|
|
1420
1440
|
*/
|
|
1421
1441
|
isDisabled?: (editor: Editor) => boolean;
|
|
1422
1442
|
/**
|
|
1423
|
-
* Node-type names that
|
|
1424
|
-
* the
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
* the
|
|
1443
|
+
* Node-type names that cause the slash menu to hide this item when they
|
|
1444
|
+
* contain the cursor. Does not affect the separate floating menu.
|
|
1445
|
+
*
|
|
1446
|
+
* Non-list names match any cursor ancestor. List containers only match
|
|
1447
|
+
* the nearest wrapping list while the cursor is in its item's first-child
|
|
1448
|
+
* label slot. Later child paragraphs keep the item available for nesting.
|
|
1428
1449
|
*/
|
|
1429
1450
|
hideWhenInside?: string[];
|
|
1430
1451
|
}
|
|
@@ -2814,6 +2835,13 @@ declare function refocusEditorAfterCommand(view: {
|
|
|
2814
2835
|
focus: () => void;
|
|
2815
2836
|
}): void;
|
|
2816
2837
|
|
|
2838
|
+
/**
|
|
2839
|
+
* Rebinds a DOM-dependent plugin view when the editor changes its mount host.
|
|
2840
|
+
* Only this view's UI resources are recreated; plugin state and editor history
|
|
2841
|
+
* stay intact. Initial setup still runs immediately, including detached views.
|
|
2842
|
+
*/
|
|
2843
|
+
declare function createAdoptablePluginView(editor: Editor | null, view: EditorView, createView: (view: EditorView) => PluginView): PluginView;
|
|
2844
|
+
|
|
2817
2845
|
/**
|
|
2818
2846
|
* Default `contexts` map for a bubble menu when the consumer has not
|
|
2819
2847
|
* supplied one. Returns a richer item set when the editor resolves to the
|
|
@@ -6913,6 +6941,6 @@ declare const StarterKit: Extension<StarterKitOptions, unknown>;
|
|
|
6913
6941
|
* @domternal/core
|
|
6914
6942
|
* Framework-agnostic ProseMirror editor engine
|
|
6915
6943
|
*/
|
|
6916
|
-
declare const VERSION = "1.0
|
|
6944
|
+
declare const VERSION = "1.1.0";
|
|
6917
6945
|
|
|
6918
|
-
export { type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, type BubbleContexts, type BubbleItemMaps, BubbleMenu, type BubbleMenuItem, type BubbleMenuOptions, type BubbleMenuSeparator, 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, type EditorPreset, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, 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, Print, type PrintOptions, type PrintStorage, type ProseMirrorCopyConflict, type Range, type RawCommands, type ResolveBubbleMenuItemsOptions, type ResolvedPosShape, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionShape, 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, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
|
6946
|
+
export { type AdoptEventProps, type AnyExtension, type AnyExtensionConfig, type AttributeSpec, type AttributeSpecs, type AutolinkPluginOptions, BaseKeymap, type BaseKeymapOptions, BlockColor, type BlockColorOptions, Blockquote, type BlockquoteOptions, Bold, type BoldOptions, type BubbleContexts, type BubbleItemMaps, BubbleMenu, type BubbleMenuItem, type BubbleMenuOptions, type BubbleMenuSeparator, 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, type EditorPreset, EventEmitter, Extension, type ExtensionConfig, type ExtensionConfigBase, ExtensionConfigurationError, 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, Print, type PrintOptions, type PrintStorage, type ProseMirrorCopyConflict, type Range, type RawCommands, type ResolveBubbleMenuItemsOptions, type ResolvedPosShape, Selection, SelectionDecoration, type SelectionDecorationOptions, type SelectionOptions, type SelectionShape, 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, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createAdoptablePluginView, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { keymap } from '@domternal/pm/keymap';
|
|
|
7
7
|
import { splitBlock, chainCommands, newlineInCode, createParagraphNear, liftEmptyBlock, baseKeymap, selectNodeBackward as selectNodeBackward$1 } from '@domternal/pm/commands';
|
|
8
8
|
import { InputRule } from '@domternal/pm/inputrules';
|
|
9
9
|
import { liftListItem, sinkListItem, splitListItem, wrapRangeInList } from '@domternal/pm/schema-list';
|
|
10
|
-
import {
|
|
10
|
+
import { hide, autoUpdate, offset, size, flip, shift, computePosition } from '@floating-ui/dom';
|
|
11
11
|
import { find } from 'linkifyjs';
|
|
12
12
|
import { history, redo, undo } from '@domternal/pm/history';
|
|
13
13
|
import { dropCursor } from '@domternal/pm/dropcursor';
|
|
@@ -3663,6 +3663,7 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
3663
3663
|
* editor itself added, never one the consumer wrote.
|
|
3664
3664
|
*/
|
|
3665
3665
|
_presetClassHost = null;
|
|
3666
|
+
_domContext = null;
|
|
3666
3667
|
/**
|
|
3667
3668
|
* Creates a new Editor instance
|
|
3668
3669
|
*
|
|
@@ -3741,18 +3742,50 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
3741
3742
|
* wrappers call it again after adopting the view's DOM: they construct
|
|
3742
3743
|
* the editor in a detached element, so the creation-time run cannot see
|
|
3743
3744
|
* the host yet. Idempotent; a no-op for any other preset. Only a class
|
|
3744
|
-
* added here is removed
|
|
3745
|
+
* added here is removed when the host changes or the editor is destroyed.
|
|
3745
3746
|
*/
|
|
3746
3747
|
adoptPresetClass() {
|
|
3747
|
-
if (this.options.preset !== "notion"
|
|
3748
|
+
if (this.options.preset !== "notion") {
|
|
3748
3749
|
return;
|
|
3749
3750
|
}
|
|
3750
3751
|
const host = this.view.dom.closest(".dm-editor");
|
|
3752
|
+
if (this._presetClassHost && this._presetClassHost !== host) {
|
|
3753
|
+
this._presetClassHost.classList.remove("dm-notion-mode");
|
|
3754
|
+
this._presetClassHost = null;
|
|
3755
|
+
}
|
|
3751
3756
|
if (host && !host.classList.contains("dm-notion-mode")) {
|
|
3752
3757
|
host.classList.add("dm-notion-mode");
|
|
3753
3758
|
this._presetClassHost = host;
|
|
3754
3759
|
}
|
|
3755
3760
|
}
|
|
3761
|
+
/**
|
|
3762
|
+
* Moves the existing view into a mount element without recreating its state.
|
|
3763
|
+
* Host-dependent UI receives an `adopt` event after the move. Calling this
|
|
3764
|
+
* again with the same DOM context is a no-op. The original `mount` and
|
|
3765
|
+
* `create` events remain creation-time events.
|
|
3766
|
+
*/
|
|
3767
|
+
adoptDom(element) {
|
|
3768
|
+
if (this._isDestroyed) return this;
|
|
3769
|
+
if (this.view.dom.parentElement !== element) {
|
|
3770
|
+
element.appendChild(this.view.dom);
|
|
3771
|
+
}
|
|
3772
|
+
this.view.updateRoot();
|
|
3773
|
+
this.adoptPresetClass();
|
|
3774
|
+
const previous = this._domContext;
|
|
3775
|
+
const current = this.captureDomContext();
|
|
3776
|
+
this._domContext = current;
|
|
3777
|
+
if (previous?.element === current.element && previous.host === current.host && previous.hostParent === current.hostParent && previous.root === current.root && previous.connected === current.connected) {
|
|
3778
|
+
return this;
|
|
3779
|
+
}
|
|
3780
|
+
this.emit("adopt", {
|
|
3781
|
+
editor: this,
|
|
3782
|
+
view: this.view,
|
|
3783
|
+
element,
|
|
3784
|
+
host: current.host,
|
|
3785
|
+
previousHost: previous?.host ?? null
|
|
3786
|
+
});
|
|
3787
|
+
return this;
|
|
3788
|
+
}
|
|
3756
3789
|
/**
|
|
3757
3790
|
* Checks if the editor content is empty
|
|
3758
3791
|
*/
|
|
@@ -4100,6 +4133,7 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
4100
4133
|
this._presetClassHost = null;
|
|
4101
4134
|
}
|
|
4102
4135
|
this.view.destroy();
|
|
4136
|
+
this._domContext = null;
|
|
4103
4137
|
this._extensionManager.destroy();
|
|
4104
4138
|
this.removeAllListeners();
|
|
4105
4139
|
this._isDestroyed = true;
|
|
@@ -4202,6 +4236,7 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
4202
4236
|
});
|
|
4203
4237
|
this._isViewConstructing = false;
|
|
4204
4238
|
this.adoptPresetClass();
|
|
4239
|
+
this._domContext = this.captureDomContext();
|
|
4205
4240
|
this.emit("mount", { editor: this, view: this.view });
|
|
4206
4241
|
this.options.onMount?.({ editor: this, view: this.view });
|
|
4207
4242
|
this.commandManager = new CommandManager(this);
|
|
@@ -4217,6 +4252,16 @@ var Editor = class _Editor extends EventEmitter {
|
|
|
4217
4252
|
this.options.onCreate?.({ editor: this });
|
|
4218
4253
|
this._extensionManager.callOnCreate();
|
|
4219
4254
|
}
|
|
4255
|
+
captureDomContext() {
|
|
4256
|
+
const host = this.view.dom.closest(".dm-editor");
|
|
4257
|
+
return {
|
|
4258
|
+
element: this.view.dom.parentElement,
|
|
4259
|
+
host,
|
|
4260
|
+
hostParent: host?.parentElement ?? null,
|
|
4261
|
+
root: this.view.dom.getRootNode(),
|
|
4262
|
+
connected: this.view.dom.isConnected
|
|
4263
|
+
};
|
|
4264
|
+
}
|
|
4220
4265
|
/**
|
|
4221
4266
|
* Builds the dispatchTransaction prop. Plugin views can dispatch synchronously
|
|
4222
4267
|
* inside EditorView's constructor, before `editor.view` is assigned; ProseMirror
|
|
@@ -4437,6 +4482,36 @@ function refocusEditorAfterCommand(view) {
|
|
|
4437
4482
|
});
|
|
4438
4483
|
}
|
|
4439
4484
|
|
|
4485
|
+
// src/utils/createAdoptablePluginView.ts
|
|
4486
|
+
function createAdoptablePluginView(editor, view, createView) {
|
|
4487
|
+
let currentView = view;
|
|
4488
|
+
let binding = createView(currentView);
|
|
4489
|
+
let destroyed = false;
|
|
4490
|
+
const rebind = () => {
|
|
4491
|
+
const previous = binding;
|
|
4492
|
+
binding = void 0;
|
|
4493
|
+
previous?.destroy?.();
|
|
4494
|
+
if (!destroyed) {
|
|
4495
|
+
binding = createView(currentView);
|
|
4496
|
+
}
|
|
4497
|
+
};
|
|
4498
|
+
editor?.on("adopt", rebind);
|
|
4499
|
+
return {
|
|
4500
|
+
update(nextView, previousState) {
|
|
4501
|
+
currentView = nextView;
|
|
4502
|
+
binding?.update?.(nextView, previousState);
|
|
4503
|
+
},
|
|
4504
|
+
destroy() {
|
|
4505
|
+
if (destroyed) return;
|
|
4506
|
+
destroyed = true;
|
|
4507
|
+
editor?.off("adopt", rebind);
|
|
4508
|
+
const previous = binding;
|
|
4509
|
+
binding = void 0;
|
|
4510
|
+
previous?.destroy?.();
|
|
4511
|
+
}
|
|
4512
|
+
};
|
|
4513
|
+
}
|
|
4514
|
+
|
|
4440
4515
|
// src/utils/defaultBubbleContexts.ts
|
|
4441
4516
|
var NOTION_TEXT_CONTEXT = Object.freeze([
|
|
4442
4517
|
"ai",
|
|
@@ -5830,7 +5905,7 @@ function createFloatingMenuPlugin(options) {
|
|
|
5830
5905
|
return false;
|
|
5831
5906
|
}
|
|
5832
5907
|
},
|
|
5833
|
-
view: (editorView) => {
|
|
5908
|
+
view: (view) => createAdoptablePluginView(editor, view, (editorView) => {
|
|
5834
5909
|
editorEl = editorView.dom.closest(".dm-editor");
|
|
5835
5910
|
if (editorEl && element.parentElement !== editorEl) {
|
|
5836
5911
|
editorEl.appendChild(element);
|
|
@@ -5866,11 +5941,11 @@ function createFloatingMenuPlugin(options) {
|
|
|
5866
5941
|
editor.on("focus", onFocus);
|
|
5867
5942
|
editor.on("blur", onBlur);
|
|
5868
5943
|
return {
|
|
5869
|
-
update: (
|
|
5870
|
-
if (isVisibleNow(
|
|
5944
|
+
update: (view2) => {
|
|
5945
|
+
if (isVisibleNow(view2)) updatePosition(view2);
|
|
5871
5946
|
else {
|
|
5872
5947
|
hideMenu();
|
|
5873
|
-
clearTriggeredFlag(
|
|
5948
|
+
clearTriggeredFlag(view2);
|
|
5874
5949
|
}
|
|
5875
5950
|
},
|
|
5876
5951
|
destroy: () => {
|
|
@@ -5888,7 +5963,7 @@ function createFloatingMenuPlugin(options) {
|
|
|
5888
5963
|
editorEl = null;
|
|
5889
5964
|
}
|
|
5890
5965
|
};
|
|
5891
|
-
}
|
|
5966
|
+
})
|
|
5892
5967
|
});
|
|
5893
5968
|
}
|
|
5894
5969
|
|
|
@@ -7952,9 +8027,9 @@ function autolinkPlugin(options) {
|
|
|
7952
8027
|
}
|
|
7953
8028
|
const { state } = view;
|
|
7954
8029
|
const $from = state.doc.resolve(from);
|
|
8030
|
+
const lookbackStart = Math.max(0, $from.parentOffset - 500);
|
|
7955
8031
|
const textBefore = $from.parent.textBetween(
|
|
7956
|
-
|
|
7957
|
-
// Look back max 500 chars
|
|
8032
|
+
lookbackStart,
|
|
7958
8033
|
$from.parentOffset,
|
|
7959
8034
|
void 0,
|
|
7960
8035
|
"\uFFFC"
|
|
@@ -7985,15 +8060,35 @@ function autolinkPlugin(options) {
|
|
|
7985
8060
|
return false;
|
|
7986
8061
|
}
|
|
7987
8062
|
const blockStart = from - $from.parentOffset;
|
|
7988
|
-
const linkStart = blockStart + lastMatch.start;
|
|
7989
|
-
const linkEnd = blockStart + lastMatch.end;
|
|
8063
|
+
const linkStart = blockStart + lookbackStart + lastMatch.start;
|
|
8064
|
+
const linkEnd = blockStart + lookbackStart + lastMatch.end;
|
|
7990
8065
|
const $linkStart = state.doc.resolve(linkStart);
|
|
7991
|
-
|
|
8066
|
+
const existingLink = $linkStart.marks().find((mark2) => mark2.type === type);
|
|
8067
|
+
if (existingLink && state.doc.resolve(to).nodeAfter?.marks.some((mark2) => mark2.eq(existingLink))) {
|
|
7992
8068
|
return false;
|
|
7993
8069
|
}
|
|
7994
8070
|
const tr = state.tr;
|
|
7995
|
-
|
|
8071
|
+
if (!existingLink) {
|
|
8072
|
+
tr.addMark(linkStart, linkEnd, type.create({ href }));
|
|
8073
|
+
} else {
|
|
8074
|
+
let markedEnd = linkStart;
|
|
8075
|
+
state.doc.nodesBetween(linkStart, linkEnd, (node, pos) => {
|
|
8076
|
+
if (node.isText && pos <= markedEnd && node.marks.some((mark2) => mark2.eq(existingLink))) {
|
|
8077
|
+
markedEnd = Math.min(pos + node.nodeSize, linkEnd);
|
|
8078
|
+
}
|
|
8079
|
+
});
|
|
8080
|
+
if (markedEnd > linkStart && markedEnd < linkEnd) {
|
|
8081
|
+
const prefix = state.doc.textBetween(linkStart, markedEnd);
|
|
8082
|
+
const prefixMatch = find(prefix, { defaultProtocol })[0];
|
|
8083
|
+
if (prefixMatch?.start === 0 && prefixMatch.end === prefix.length && prefixMatch.href === existingLink.attrs["href"]) {
|
|
8084
|
+
tr.addMark(linkStart, linkEnd, type.create({ ...existingLink.attrs, href }));
|
|
8085
|
+
}
|
|
8086
|
+
}
|
|
8087
|
+
}
|
|
8088
|
+
const insertionMarks = type.removeFromSet(state.storedMarks ?? $from.marks());
|
|
8089
|
+
tr.setStoredMarks(insertionMarks);
|
|
7996
8090
|
tr.insertText(text, from, to);
|
|
8091
|
+
tr.setStoredMarks(insertionMarks);
|
|
7997
8092
|
view.dispatch(tr);
|
|
7998
8093
|
return true;
|
|
7999
8094
|
}
|
|
@@ -9729,11 +9824,11 @@ var SelectionDecoration = Extension.create(
|
|
|
9729
9824
|
return false;
|
|
9730
9825
|
}
|
|
9731
9826
|
}
|
|
9732
|
-
const { from, to } = view.state.selection;
|
|
9827
|
+
const { from, to, $from } = view.state.selection;
|
|
9733
9828
|
if (from !== to) {
|
|
9734
9829
|
view.dispatch(
|
|
9735
9830
|
view.state.tr.setSelection(
|
|
9736
|
-
TextSelection.
|
|
9831
|
+
TextSelection.between($from, $from, 1)
|
|
9737
9832
|
)
|
|
9738
9833
|
);
|
|
9739
9834
|
}
|
|
@@ -11039,7 +11134,7 @@ function createBubbleMenuPlugin(options) {
|
|
|
11039
11134
|
return { visible, from, to };
|
|
11040
11135
|
}
|
|
11041
11136
|
},
|
|
11042
|
-
view: (editorView) => {
|
|
11137
|
+
view: (view) => createAdoptablePluginView(editor, view, (editorView) => {
|
|
11043
11138
|
const editorEl = editorView.dom.closest(".dm-editor");
|
|
11044
11139
|
if (editorEl && element.parentElement !== editorEl) {
|
|
11045
11140
|
editorEl.appendChild(element);
|
|
@@ -11103,16 +11198,16 @@ function createBubbleMenuPlugin(options) {
|
|
|
11103
11198
|
editor.on("focus", onFocus);
|
|
11104
11199
|
editor.on("blur", onBlur);
|
|
11105
11200
|
return {
|
|
11106
|
-
update: (
|
|
11107
|
-
if (
|
|
11108
|
-
if (!
|
|
11201
|
+
update: (view2, prevState) => {
|
|
11202
|
+
if (view2.composing) return;
|
|
11203
|
+
if (!view2.editable) {
|
|
11109
11204
|
hideMenu();
|
|
11110
11205
|
return;
|
|
11111
11206
|
}
|
|
11112
|
-
const state = pluginKey.getState(
|
|
11207
|
+
const state = pluginKey.getState(view2.state);
|
|
11113
11208
|
const prevPluginState = pluginKey.getState(prevState);
|
|
11114
11209
|
const domShown = element.hasAttribute("data-show") || updateTimeout !== null;
|
|
11115
|
-
if (state?.visible === prevPluginState?.visible && state?.from === prevPluginState?.from && state?.to === prevPluginState?.to && !(state?.visible &&
|
|
11210
|
+
if (state?.visible === prevPluginState?.visible && state?.from === prevPluginState?.from && state?.to === prevPluginState?.to && !(state?.visible && view2.state.doc !== prevState.doc) && domShown === Boolean(state?.visible)) {
|
|
11116
11211
|
return;
|
|
11117
11212
|
}
|
|
11118
11213
|
if (updateTimeout) {
|
|
@@ -11122,10 +11217,10 @@ function createBubbleMenuPlugin(options) {
|
|
|
11122
11217
|
if (state?.visible && !mouseDown) {
|
|
11123
11218
|
if (updateDelay > 0) {
|
|
11124
11219
|
updateTimeout = setTimeout(() => {
|
|
11125
|
-
updatePosition(
|
|
11220
|
+
updatePosition(view2, state.from, state.to);
|
|
11126
11221
|
}, updateDelay);
|
|
11127
11222
|
} else {
|
|
11128
|
-
updatePosition(
|
|
11223
|
+
updatePosition(view2, state.from, state.to);
|
|
11129
11224
|
}
|
|
11130
11225
|
} else {
|
|
11131
11226
|
hideMenu();
|
|
@@ -11153,7 +11248,7 @@ function createBubbleMenuPlugin(options) {
|
|
|
11153
11248
|
hideMenu();
|
|
11154
11249
|
}
|
|
11155
11250
|
};
|
|
11156
|
-
}
|
|
11251
|
+
})
|
|
11157
11252
|
});
|
|
11158
11253
|
}
|
|
11159
11254
|
var BubbleMenu = Extension.create({
|
|
@@ -11239,8 +11334,8 @@ var StarterKit = Extension.create({
|
|
|
11239
11334
|
});
|
|
11240
11335
|
|
|
11241
11336
|
// src/index.ts
|
|
11242
|
-
var VERSION = "1.0
|
|
11337
|
+
var VERSION = "1.1.0";
|
|
11243
11338
|
|
|
11244
|
-
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, ExtensionConfigurationError, 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, Print, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
|
11339
|
+
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, ExtensionConfigurationError, 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, Print, Selection5 as Selection, SelectionDecoration, StarterKit, Strike, Subscript, Superscript, TaskItem, TaskList, Text, TextAlign, TextColor, TextStyle, ToolbarController, TrailingNode, Typography, Underline, UniqueID, VERSION, announce, applyInlineStyles, assertSingleProseMirrorCopy, autolinkPlugin, autolinkPluginKey, blur, bubbleMenuPluginKey, buildBubbleItemMaps, buildCommandProps, builtInCommands, callOrReturn, characterCountPluginKey, clearContent, collapseSeparators, copyThemeClass, createAccumulatingDispatch, createAdoptablePluginView, createBubbleMenuPlugin, createBubbleShouldShow, createCanChecker, createChainBuilder, createDocument, createFloatingMenuPlugin, defaultBlockAt, defaultBubbleContexts, defaultFloatingMenuShouldShow, defaultIcons, deleteSelection, detectBubbleContext, filterBubbleItemsBySchema, findChildren, findListItemAncestorDepth, findParentNode, floatingMenuPluginKey, focus, focusPluginKey, generateHTML, generateJSON, generateText, getBubbleFormatItems, getListItemCursorContext, getMarkRange, groupFloatingMenuItems, hideFloatingMenu, indentBlockAsListChild, inlineStyles, insertAsListItemChild, insertChildrenZoneSibling, insertContent, insertText, invisibleCharsPluginKey, isDocumentEmpty, isInListItemLabel, isInsideListItem, isInsideTableCell, isNodeEmpty, isValidUrl, lift, liftCurrentListItem, liftEmptyChildrenZoneParagraph, linkClickPlugin, linkClickPluginKey, linkExitPlugin, linkExitPluginKey, linkPastePlugin, linkPastePluginKey, markInputRule, markInputRulePatterns, nodeInputRule, outdentBlockFromListItem, placeholderPluginKey, positionFloating, positionFloatingOnce, refocusEditorAfterCommand, registerProseMirrorCopy, resetAttributes, resolveBubbleMenuItems, resolveBubbleNames, selectAll, selectNodeBackward, selectionDecorationPluginKey, setBlockType, setContent, setMark, showFloatingMenu, splitListForInsert, stripInlineColorConflicts, textInputRule, textblockTypeInputRule, toggleBlockType, toggleList, toggleMark, toggleWrap, uniqueIDPluginKey, unsetAllMarks, unsetMark, updateAttributes, warnOnDuplicateProseMirrorCopy, wrapIn, wrappingInputRule, writeToClipboard };
|
|
11245
11340
|
//# sourceMappingURL=index.js.map
|
|
11246
11341
|
//# sourceMappingURL=index.js.map
|