@lofcz/platejs-core 52.3.4 → 52.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hotkeys-DI1HPO2Q.js +1 -2
- package/dist/{index-NTp--CEF.d.ts → index-CLvWpTKx.d.ts} +52 -1745
- package/dist/index.d.ts +2 -2
- package/dist/index.js +31 -3
- package/dist/react/index.d.ts +194 -195
- package/dist/react/index.js +3 -4
- package/dist/static/index.d.ts +1 -1
- package/dist/static/index.js +2 -2
- package/dist/{static-CVN6JhaR.js → static-DIYyt_jS.js} +27 -15
- package/dist/{withSlate-1B0SfAWG.js → withSlate-BfRR5wTZ.js} +98 -81
- package/package.json +5 -5
- package/dist/hotkeys-DI1HPO2Q.js.map +0 -1
- package/dist/index-NTp--CEF.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/static-CVN6JhaR.js.map +0 -1
- package/dist/withSlate-1B0SfAWG.js.map +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Gt as getEditorPlugin$1, Kt as createSlatePlugin, Pt as BaseParagraphPlugin, Z as DOMPlugin, dt as getPluginNodeProps, f as isEditOnly, n as withSlate, s as SlateExtensionPlugin, tt as ChunkingPlugin, ut as getSlateClass, zt as getPluginByType } from "../withSlate-
|
|
1
|
+
import { Gt as getEditorPlugin$1, Kt as createSlatePlugin, Pt as BaseParagraphPlugin, Z as DOMPlugin, dt as getPluginNodeProps, f as isEditOnly, n as withSlate, s as SlateExtensionPlugin, tt as ChunkingPlugin, ut as getSlateClass, zt as getPluginByType } from "../withSlate-BfRR5wTZ.js";
|
|
2
2
|
import { t as Hotkeys } from "../hotkeys-DI1HPO2Q.js";
|
|
3
|
-
import { A as pipeInjectNodeProps, C as createStaticEditor, k as pipeDecorate, s as PlateStatic } from "../static-
|
|
3
|
+
import { A as pipeInjectNodeProps, C as createStaticEditor, k as pipeDecorate, s as PlateStatic } from "../static-DIYyt_jS.js";
|
|
4
4
|
import { PathApi, createEditor } from "@platejs/slate";
|
|
5
5
|
import { isDefined } from "@udecode/utils";
|
|
6
6
|
import { DefaultPlaceholder, Editable, Slate, useComposing, useFocused, useReadOnly, useSelected, useSlateStatic, withReact } from "slate-react";
|
|
@@ -2578,5 +2578,4 @@ const withHOC = (HOC, Component, hocProps, hocRef) => React.forwardRef((props, c
|
|
|
2578
2578
|
});
|
|
2579
2579
|
|
|
2580
2580
|
//#endregion
|
|
2581
|
-
export { BLUR_EDITOR_EVENT, BelowRootNodes, ContentVisibilityChunk, DOM_HANDLERS, DefaultPlaceholder, Editable, EditorHotkeysEffect, EditorMethodsEffect, EditorRefEffect, EditorRefPluginEffect, ElementProvider, EventEditorPlugin, EventEditorStore, FOCUS_EDITOR_EVENT, GLOBAL_PLATE_SCOPE, PLATE_SCOPE, ParagraphPlugin, Plate, PlateContainer, PlateContent, PlateController, PlateControllerEffect, PlateElement, PlateLeaf, PlateSlate, PlateStoreProvider, PlateTest, PlateText, PlateView, ReactPlugin, SCOPE_ELEMENT, Slate, SlateReactExtensionPlugin, atom, convertDomEventToSyntheticEvent, createAtomStore, createPlateEditor, createPlateFallbackEditor, createPlatePlugin, createPlateStore, createTPlatePlugin, createZustandStore, elementStore, getEditorPlugin, getEventPlateId, getPlateCorePlugins, getPlugin, getRenderNodeProps, isEventHandled, omitPluginContext, pipeHandler, pipeOnChange, pipeRenderElement, pipeRenderLeaf, pipeRenderText, plateControllerStore, plateStore, pluginRenderElement, pluginRenderLeaf, pluginRenderText, toPlatePlugin, toTPlatePlugin, useComposing, useEditableProps, useEditorComposing, useEditorContainerRef, useEditorId, useEditorMounted, useEditorPlugin, useEditorPluginOption, useEditorPluginOptions, useEditorReadOnly, useEditorRef, useEditorScrollRef, useEditorSelection, useEditorSelector, useEditorState, useEditorValue, useEditorVersion, useElement, useElementSelector, useElementStore, useEventEditorValue, useEventPlateId, useFocusEditorEvents, useFocused, useFocusedLast, useIncrementVersion, useNodeAttributes, useNodePath, usePath, usePlateControllerExists, usePlateControllerLocalStore, usePlateControllerStore, usePlateEditor, usePlateLocalStore, usePlateSet, usePlateState, usePlateStore, usePlateValue, usePlateViewEditor, usePluginOption, usePluginOptions, useReadOnly, useRedecorate, useScrollRef, useSelected, useSelectionVersion, useSlateProps, useSlateStatic, useStoreAtomState, useStoreAtomValue, useStoreSelect, useStoreSetAtom, useStoreState, useStoreValue, useTracked, useTrackedStore, useValueVersion, withHOC, withPlate, withPlateReact, withReact };
|
|
2582
|
-
//# sourceMappingURL=index.js.map
|
|
2581
|
+
export { BLUR_EDITOR_EVENT, BelowRootNodes, ContentVisibilityChunk, DOM_HANDLERS, DefaultPlaceholder, Editable, EditorHotkeysEffect, EditorMethodsEffect, EditorRefEffect, EditorRefPluginEffect, ElementProvider, EventEditorPlugin, EventEditorStore, FOCUS_EDITOR_EVENT, GLOBAL_PLATE_SCOPE, PLATE_SCOPE, ParagraphPlugin, Plate, PlateContainer, PlateContent, PlateController, PlateControllerEffect, PlateElement, PlateLeaf, PlateSlate, PlateStoreProvider, PlateTest, PlateText, PlateView, ReactPlugin, SCOPE_ELEMENT, Slate, SlateReactExtensionPlugin, atom, convertDomEventToSyntheticEvent, createAtomStore, createPlateEditor, createPlateFallbackEditor, createPlatePlugin, createPlateStore, createTPlatePlugin, createZustandStore, elementStore, getEditorPlugin, getEventPlateId, getPlateCorePlugins, getPlugin, getRenderNodeProps, isEventHandled, omitPluginContext, pipeHandler, pipeOnChange, pipeRenderElement, pipeRenderLeaf, pipeRenderText, plateControllerStore, plateStore, pluginRenderElement, pluginRenderLeaf, pluginRenderText, toPlatePlugin, toTPlatePlugin, useComposing, useEditableProps, useEditorComposing, useEditorContainerRef, useEditorId, useEditorMounted, useEditorPlugin, useEditorPluginOption, useEditorPluginOptions, useEditorReadOnly, useEditorRef, useEditorScrollRef, useEditorSelection, useEditorSelector, useEditorState, useEditorValue, useEditorVersion, useElement, useElementSelector, useElementStore, useEventEditorValue, useEventPlateId, useFocusEditorEvents, useFocused, useFocusedLast, useIncrementVersion, useNodeAttributes, useNodePath, usePath, usePlateControllerExists, usePlateControllerLocalStore, usePlateControllerStore, usePlateEditor, usePlateLocalStore, usePlateSet, usePlateState, usePlateStore, usePlateValue, usePlateViewEditor, usePluginOption, usePluginOptions, useReadOnly, useRedecorate, useScrollRef, useSelected, useSelectionVersion, useSlateProps, useSlateStatic, useStoreAtomState, useStoreAtomValue, useStoreSelect, useStoreSetAtom, useStoreState, useStoreValue, useTracked, useTrackedStore, useValueVersion, withHOC, withPlate, withPlateReact, withReact };
|
package/dist/static/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $i as SlateElement, Aa as pluginRenderElementStatic, Bi as pipeDecorate, Ca as pipeRenderTextStatic, Da as pluginRenderLeafStatic, Ea as pipeRenderLeafStatic, Gi as getRenderNodeStaticProps, Hi as getSelectedDomNode, Ji as createStaticString, Ki as getNodeDataAttributes, Oa as pipeRenderElementStatic, Qi as getEditorDOMFromHtmlString, Ri as stripSlateDataAttributes, Sa as SlateRenderText, Ta as SlateRenderLeaf, Ui as getSelectedDomFragment, Vi as isSelectOutside, Wi as getSelectedDomBlocks, Xi as ViewPlugin, Yi as getStaticPlugins, Zi as createStaticEditor, _a as serializeHtml, aa as SlateText, ba as PlateStatic, ca as StyledSlateLeafProps, da as BoxStaticProps, ea as SlateElementProps, fa as SlateRenderElementProps, ga as SerializeHtmlOptions, ha as SlateRenderTextProps, ia as SlateNodeProps, ka as SlateRenderElement, la as StyledSlateTextProps, ma as SlateRenderNodeProps, na as SlateLeaf, oa as SlateTextProps, pa as SlateRenderLeafProps, qi as getPluginDataAttributes, ra as SlateLeafProps, sa as StyledSlateElementProps, ta as SlateHTMLProps, ua as useNodeAttributes, va as ElementStatic, wa as pluginRenderTextStatic, xa as PlateStaticProps, ya as LeafStatic, zi as stripHtmlClassNames } from "../index-CLvWpTKx";
|
|
2
2
|
export { BoxStaticProps, ElementStatic, LeafStatic, PlateStatic, PlateStaticProps, SerializeHtmlOptions, SlateElement, SlateElementProps, SlateHTMLProps, SlateLeaf, SlateLeafProps, SlateNodeProps, SlateRenderElement, SlateRenderElementProps, SlateRenderLeaf, SlateRenderLeafProps, SlateRenderNodeProps, SlateRenderText, SlateRenderTextProps, SlateText, SlateTextProps, StyledSlateElementProps, StyledSlateLeafProps, StyledSlateTextProps, ViewPlugin, createStaticEditor, createStaticString, getEditorDOMFromHtmlString, getNodeDataAttributes, getPluginDataAttributes, getRenderNodeStaticProps, getSelectedDomBlocks, getSelectedDomFragment, getSelectedDomNode, getStaticPlugins, isSelectOutside, pipeDecorate, pipeRenderElementStatic, pipeRenderLeafStatic, pipeRenderTextStatic, pluginRenderElementStatic, pluginRenderLeafStatic, pluginRenderTextStatic, serializeHtml, stripHtmlClassNames, stripSlateDataAttributes, useNodeAttributes };
|
package/dist/static/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../withSlate-
|
|
2
|
-
import { C as createStaticEditor, D as getSelectedDomNode, E as isSelectOutside, O as getSelectedDomFragment, S as useNodeAttributes, T as ViewPlugin, _ as getPluginDataAttributes, a as ElementStatic, b as SlateLeaf, c as pipeRenderTextStatic, d as pluginRenderElementStatic, f as stripSlateDataAttributes, g as getNodeDataAttributes, h as getRenderNodeStaticProps, i as pluginRenderLeafStatic, k as pipeDecorate, l as pluginRenderTextStatic, m as getSelectedDomBlocks, n as serializeHtml, o as LeafStatic, p as stripHtmlClassNames, r as pipeRenderLeafStatic, s as PlateStatic, t as getEditorDOMFromHtmlString, u as pipeRenderElementStatic, v as createStaticString, w as getStaticPlugins, x as SlateText, y as SlateElement } from "../static-
|
|
1
|
+
import "../withSlate-BfRR5wTZ.js";
|
|
2
|
+
import { C as createStaticEditor, D as getSelectedDomNode, E as isSelectOutside, O as getSelectedDomFragment, S as useNodeAttributes, T as ViewPlugin, _ as getPluginDataAttributes, a as ElementStatic, b as SlateLeaf, c as pipeRenderTextStatic, d as pluginRenderElementStatic, f as stripSlateDataAttributes, g as getNodeDataAttributes, h as getRenderNodeStaticProps, i as pluginRenderLeafStatic, k as pipeDecorate, l as pluginRenderTextStatic, m as getSelectedDomBlocks, n as serializeHtml, o as LeafStatic, p as stripHtmlClassNames, r as pipeRenderLeafStatic, s as PlateStatic, t as getEditorDOMFromHtmlString, u as pipeRenderElementStatic, v as createStaticString, w as getStaticPlugins, x as SlateText, y as SlateElement } from "../static-DIYyt_jS.js";
|
|
3
3
|
|
|
4
4
|
export { ElementStatic, LeafStatic, PlateStatic, SlateElement, SlateLeaf, SlateText, ViewPlugin, createStaticEditor, createStaticString, getEditorDOMFromHtmlString, getNodeDataAttributes, getPluginDataAttributes, getRenderNodeStaticProps, getSelectedDomBlocks, getSelectedDomFragment, getSelectedDomNode, getStaticPlugins, isSelectOutside, pipeDecorate, pipeRenderElementStatic, pipeRenderLeafStatic, pipeRenderTextStatic, pluginRenderElementStatic, pluginRenderLeafStatic, pluginRenderTextStatic, serializeHtml, stripHtmlClassNames, stripSlateDataAttributes, useNodeAttributes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Gt as getEditorPlugin, Z as DOMPlugin, dt as getPluginNodeProps, f as isEditOnly, ht as getInjectMatch, n as withSlate, pt as keyToDataAttribute, ut as getSlateClass, zt as getPluginByType } from "./withSlate-
|
|
1
|
+
import { Gt as getEditorPlugin, Z as DOMPlugin, dt as getPluginNodeProps, f as isEditOnly, ht as getInjectMatch, n as withSlate, pt as keyToDataAttribute, ut as getSlateClass, zt as getPluginByType } from "./withSlate-BfRR5wTZ.js";
|
|
2
2
|
import { ElementApi, NodeApi, RangeApi, TextApi, createEditor, isElementDecorationsEqual, isTextDecorationsEqual } from "@platejs/slate";
|
|
3
3
|
import { isDefined } from "@udecode/utils";
|
|
4
4
|
import React from "react";
|
|
@@ -288,7 +288,7 @@ const getPluginDataAttributes = (editor, plugin, node) => {
|
|
|
288
288
|
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/static/utils/getRenderNodeStaticProps.ts
|
|
291
|
-
const getRenderNodeStaticProps = ({ attributes: nodeAttributes, editor, node, plugin, props }) => {
|
|
291
|
+
const getRenderNodeStaticProps = ({ attributes: nodeAttributes, editor, node, path, plugin, props }) => {
|
|
292
292
|
let newProps = {
|
|
293
293
|
...props,
|
|
294
294
|
...plugin ? getEditorPlugin(editor, plugin) : {
|
|
@@ -311,7 +311,7 @@ const getRenderNodeStaticProps = ({ attributes: nodeAttributes, editor, node, pl
|
|
|
311
311
|
className: clsx$1(getSlateClass(plugin?.node.type), className) || void 0
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
newProps = pipeInjectNodeProps(editor, newProps, (node$1) => editor.api.findPath(node$1));
|
|
314
|
+
newProps = pipeInjectNodeProps(editor, newProps, path ? () => path : (node$1) => editor.api.findPath(node$1));
|
|
315
315
|
if (newProps.style && Object.keys(newProps.style).length === 0) newProps.style = void 0;
|
|
316
316
|
return newProps;
|
|
317
317
|
};
|
|
@@ -363,6 +363,7 @@ const pluginRenderElementStatic = (editor, plugin) => function render(nodeProps)
|
|
|
363
363
|
},
|
|
364
364
|
editor,
|
|
365
365
|
node: element,
|
|
366
|
+
path: nodeProps.path,
|
|
366
367
|
plugin,
|
|
367
368
|
props: nodeProps
|
|
368
369
|
});
|
|
@@ -409,6 +410,7 @@ const pipeRenderElementStatic = (editor, { renderElement: renderElementProp } =
|
|
|
409
410
|
if (renderElementProp) return renderElementProp(props);
|
|
410
411
|
const ctxProps = getRenderNodeStaticProps({
|
|
411
412
|
editor,
|
|
413
|
+
path: props.path,
|
|
412
414
|
props: { ...props }
|
|
413
415
|
});
|
|
414
416
|
return /* @__PURE__ */ React.createElement(SlateElement, ctxProps, props.children, editor.meta.pluginCache.render.belowRootNodes.map((key) => {
|
|
@@ -431,6 +433,7 @@ const pluginRenderTextStatic = (editor, plugin) => function render(nodeProps) {
|
|
|
431
433
|
attributes: { ...text.attributes },
|
|
432
434
|
editor,
|
|
433
435
|
node: text,
|
|
436
|
+
path: nodeProps.path,
|
|
434
437
|
plugin,
|
|
435
438
|
props: nodeProps
|
|
436
439
|
});
|
|
@@ -475,6 +478,7 @@ const pipeRenderTextStatic = (editor, { renderText: renderTextProp } = {}) => {
|
|
|
475
478
|
});
|
|
476
479
|
const ctxProps = getRenderNodeStaticProps({
|
|
477
480
|
editor,
|
|
481
|
+
path: props.path,
|
|
478
482
|
props: {
|
|
479
483
|
attributes,
|
|
480
484
|
...props
|
|
@@ -497,7 +501,7 @@ const pipeRenderTextStatic = (editor, { renderText: renderTextProp } = {}) => {
|
|
|
497
501
|
function BaseElementStatic({ decorate, decorations, editor, element = {
|
|
498
502
|
children: [],
|
|
499
503
|
type: ""
|
|
500
|
-
} }) {
|
|
504
|
+
}, path }) {
|
|
501
505
|
const renderElement = pipeRenderElementStatic(editor);
|
|
502
506
|
const attributes = {
|
|
503
507
|
"data-slate-node": "element",
|
|
@@ -506,7 +510,8 @@ function BaseElementStatic({ decorate, decorations, editor, element = {
|
|
|
506
510
|
let children = /* @__PURE__ */ React.createElement(Children, {
|
|
507
511
|
decorate,
|
|
508
512
|
decorations,
|
|
509
|
-
editor
|
|
513
|
+
editor,
|
|
514
|
+
parentPath: path
|
|
510
515
|
}, element.children);
|
|
511
516
|
if (editor.api.isVoid(element)) {
|
|
512
517
|
attributes["data-slate-void"] = true;
|
|
@@ -521,18 +526,20 @@ function BaseElementStatic({ decorate, decorations, editor, element = {
|
|
|
521
526
|
}, /* @__PURE__ */ React.createElement(Children, {
|
|
522
527
|
decorate,
|
|
523
528
|
decorations,
|
|
524
|
-
editor
|
|
529
|
+
editor,
|
|
530
|
+
parentPath: path
|
|
525
531
|
}, element.children));
|
|
526
532
|
}
|
|
527
533
|
if (editor.api.isInline(element)) attributes["data-slate-inline"] = true;
|
|
528
534
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, renderElement?.({
|
|
529
535
|
attributes,
|
|
530
536
|
children,
|
|
531
|
-
element
|
|
537
|
+
element,
|
|
538
|
+
path
|
|
532
539
|
}));
|
|
533
540
|
}
|
|
534
541
|
const ElementStatic = React.memo(BaseElementStatic, (prev, next) => (prev.element === next.element || prev.element._memo !== void 0 && prev.element._memo === next.element._memo) && isElementDecorationsEqual(prev.decorations, next.decorations));
|
|
535
|
-
function BaseLeafStatic({ decorations, editor, text = { text: "" } }) {
|
|
542
|
+
function BaseLeafStatic({ decorations, editor, path, text = { text: "" } }) {
|
|
536
543
|
const renderLeaf = pipeRenderLeafStatic(editor);
|
|
537
544
|
const renderText = pipeRenderTextStatic(editor);
|
|
538
545
|
const leafElements = TextApi.decorations(text, decorations).map(({ leaf, position }, index) => {
|
|
@@ -541,6 +548,7 @@ function BaseLeafStatic({ decorations, editor, text = { text: "" } }) {
|
|
|
541
548
|
children: /* @__PURE__ */ React.createElement("span", { "data-slate-string": true }, leaf.text === "" ? "" : leaf.text),
|
|
542
549
|
leaf,
|
|
543
550
|
leafPosition: position,
|
|
551
|
+
path,
|
|
544
552
|
text: leaf
|
|
545
553
|
});
|
|
546
554
|
return /* @__PURE__ */ React.createElement(React.Fragment, { key: index }, leafElement);
|
|
@@ -551,6 +559,7 @@ function BaseLeafStatic({ decorations, editor, text = { text: "" } }) {
|
|
|
551
559
|
ref: null
|
|
552
560
|
},
|
|
553
561
|
children: leafElements,
|
|
562
|
+
path,
|
|
554
563
|
text
|
|
555
564
|
});
|
|
556
565
|
}
|
|
@@ -558,12 +567,12 @@ const LeafStatic = React.memo(BaseLeafStatic, (prev, next) => {
|
|
|
558
567
|
return TextApi.equals(next.text, prev.text) && isTextDecorationsEqual(next.decorations, prev.decorations);
|
|
559
568
|
});
|
|
560
569
|
const defaultDecorate = () => [];
|
|
561
|
-
function Children({ children = [], decorate = defaultDecorate, decorations = [], editor }) {
|
|
570
|
+
function Children({ children = [], decorate = defaultDecorate, decorations = [], editor, parentPath = [] }) {
|
|
562
571
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children.map((child, i) => {
|
|
563
|
-
const p =
|
|
572
|
+
const p = [...parentPath, i];
|
|
564
573
|
let ds = [];
|
|
565
|
-
|
|
566
|
-
|
|
574
|
+
const range = editor.api.range(p);
|
|
575
|
+
if (range) {
|
|
567
576
|
ds = decorate([child, p]);
|
|
568
577
|
for (const dec of decorations) {
|
|
569
578
|
const d = RangeApi.intersection(dec, range);
|
|
@@ -575,11 +584,13 @@ function Children({ children = [], decorate = defaultDecorate, decorations = [],
|
|
|
575
584
|
decorate,
|
|
576
585
|
decorations: ds,
|
|
577
586
|
editor,
|
|
578
|
-
element: child
|
|
587
|
+
element: child,
|
|
588
|
+
path: p
|
|
579
589
|
}) : /* @__PURE__ */ React.createElement(LeafStatic, {
|
|
580
590
|
key: i,
|
|
581
591
|
decorations: ds,
|
|
582
592
|
editor,
|
|
593
|
+
path: p,
|
|
583
594
|
text: child
|
|
584
595
|
});
|
|
585
596
|
}));
|
|
@@ -627,6 +638,7 @@ const pluginRenderLeafStatic = (editor, plugin) => function render(props) {
|
|
|
627
638
|
attributes: { ...leaf.attributes },
|
|
628
639
|
editor,
|
|
629
640
|
node: leaf,
|
|
641
|
+
path: props.path,
|
|
630
642
|
plugin,
|
|
631
643
|
props
|
|
632
644
|
});
|
|
@@ -671,6 +683,7 @@ const pipeRenderLeafStatic = (editor, { renderLeaf: renderLeafProp } = {}) => {
|
|
|
671
683
|
});
|
|
672
684
|
const ctxProps = getRenderNodeStaticProps({
|
|
673
685
|
editor,
|
|
686
|
+
path: props.path,
|
|
674
687
|
props: {
|
|
675
688
|
attributes,
|
|
676
689
|
...props
|
|
@@ -724,5 +737,4 @@ const getEditorDOMFromHtmlString = (html) => {
|
|
|
724
737
|
};
|
|
725
738
|
|
|
726
739
|
//#endregion
|
|
727
|
-
export { pipeInjectNodeProps as A, createStaticEditor as C, getSelectedDomNode as D, isSelectOutside as E, getSelectedDomFragment as O, useNodeAttributes as S, ViewPlugin as T, getPluginDataAttributes as _, ElementStatic as a, SlateLeaf as b, pipeRenderTextStatic as c, pluginRenderElementStatic as d, stripSlateDataAttributes as f, getNodeDataAttributes as g, getRenderNodeStaticProps as h, pluginRenderLeafStatic as i, pipeDecorate as k, pluginRenderTextStatic as l, getSelectedDomBlocks as m, serializeHtml as n, LeafStatic as o, stripHtmlClassNames as p, pipeRenderLeafStatic as r, PlateStatic as s, getEditorDOMFromHtmlString as t, pipeRenderElementStatic as u, createStaticString as v, getStaticPlugins as w, SlateText as x, SlateElement as y };
|
|
728
|
-
//# sourceMappingURL=static-CVN6JhaR.js.map
|
|
740
|
+
export { pipeInjectNodeProps as A, createStaticEditor as C, getSelectedDomNode as D, isSelectOutside as E, getSelectedDomFragment as O, useNodeAttributes as S, ViewPlugin as T, getPluginDataAttributes as _, ElementStatic as a, SlateLeaf as b, pipeRenderTextStatic as c, pluginRenderElementStatic as d, stripSlateDataAttributes as f, getNodeDataAttributes as g, getRenderNodeStaticProps as h, pluginRenderLeafStatic as i, pipeDecorate as k, pluginRenderTextStatic as l, getSelectedDomBlocks as m, serializeHtml as n, LeafStatic as o, stripHtmlClassNames as p, pipeRenderLeafStatic as r, PlateStatic as s, getEditorDOMFromHtmlString as t, pipeRenderElementStatic as u, createStaticString as v, getStaticPlugins as w, SlateText as x, SlateElement as y };
|
|
@@ -1328,16 +1328,28 @@ const withScrolling = (editor, fn, options) => {
|
|
|
1328
1328
|
const prevOptions = editor.getOptions(DOMPlugin);
|
|
1329
1329
|
const prevAutoScroll = AUTO_SCROLL.get(editor) ?? false;
|
|
1330
1330
|
if (options) {
|
|
1331
|
+
const scrollOptions = typeof options.scrollOptions === "object" && options.scrollOptions ? {
|
|
1332
|
+
...typeof prevOptions.scrollOptions === "object" ? prevOptions.scrollOptions : {},
|
|
1333
|
+
...omitBy(options.scrollOptions, isUndefined)
|
|
1334
|
+
} : options.scrollOptions ?? prevOptions.scrollOptions;
|
|
1331
1335
|
const ops = {
|
|
1332
1336
|
...prevOptions,
|
|
1333
|
-
|
|
1337
|
+
scrollOperations: {
|
|
1338
|
+
...prevOptions.scrollOperations,
|
|
1339
|
+
...omitBy(options.operations ?? {}, isUndefined)
|
|
1340
|
+
},
|
|
1341
|
+
scrollOptions,
|
|
1342
|
+
...omitBy({ scrollMode: options.mode }, isUndefined)
|
|
1334
1343
|
};
|
|
1335
1344
|
editor.setOptions(DOMPlugin, ops);
|
|
1336
1345
|
}
|
|
1337
1346
|
AUTO_SCROLL.set(editor, true);
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1347
|
+
try {
|
|
1348
|
+
fn();
|
|
1349
|
+
} finally {
|
|
1350
|
+
AUTO_SCROLL.set(editor, prevAutoScroll);
|
|
1351
|
+
editor.setOptions(DOMPlugin, prevOptions);
|
|
1352
|
+
}
|
|
1341
1353
|
};
|
|
1342
1354
|
|
|
1343
1355
|
//#endregion
|
|
@@ -2393,15 +2405,17 @@ const insertExitBreak = (editor, { match, reverse } = {}) => {
|
|
|
2393
2405
|
//#endregion
|
|
2394
2406
|
//#region src/lib/plugins/slate-extension/transforms/resetBlock.ts
|
|
2395
2407
|
/**
|
|
2396
|
-
* Reset the current block to a paragraph, removing all properties except
|
|
2397
|
-
* type.
|
|
2408
|
+
* Reset the current block to a paragraph, removing all properties except the
|
|
2409
|
+
* configured node id key and type.
|
|
2398
2410
|
*/
|
|
2399
2411
|
const resetBlock = (editor, { at } = {}) => {
|
|
2400
2412
|
const entry = editor.api.block({ at });
|
|
2401
2413
|
if (!entry?.[0]) return;
|
|
2402
2414
|
const [block, path] = entry;
|
|
2415
|
+
const idKey = editor.getOptions(NodeIdPlugin).idKey ?? "id";
|
|
2403
2416
|
editor.tf.withoutNormalizing(() => {
|
|
2404
|
-
const {
|
|
2417
|
+
const { type, ...otherProps } = NodeApi.extractProps(block);
|
|
2418
|
+
delete otherProps[idKey];
|
|
2405
2419
|
Object.keys(otherProps).forEach((key) => {
|
|
2406
2420
|
editor.tf.unsetNodes(key, { at: path });
|
|
2407
2421
|
});
|
|
@@ -2427,91 +2441,95 @@ const setValue = (editor, value) => {
|
|
|
2427
2441
|
//#region src/lib/plugins/slate-extension/SlateExtensionPlugin.ts
|
|
2428
2442
|
/** Opinionated extension of slate default behavior. */
|
|
2429
2443
|
const SlateExtensionPlugin = createTSlatePlugin({
|
|
2444
|
+
api: { redecorate: () => {} },
|
|
2430
2445
|
key: "slateExtension",
|
|
2431
2446
|
options: {
|
|
2432
2447
|
onNodeChange: () => {},
|
|
2433
2448
|
onTextChange: () => {}
|
|
2434
2449
|
}
|
|
2435
|
-
}).extendEditorTransforms(({ editor, getOption, tf
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
node = operation.node;
|
|
2457
|
-
break;
|
|
2458
|
-
case "merge_node":
|
|
2459
|
-
case "move_node":
|
|
2460
|
-
case "set_node":
|
|
2461
|
-
case "split_node":
|
|
2462
|
-
prevNode = NodeApi.get(editor, operation.path);
|
|
2463
|
-
break;
|
|
2464
|
-
case "remove_node":
|
|
2465
|
-
prevNode = operation.node;
|
|
2466
|
-
node = operation.node;
|
|
2467
|
-
break;
|
|
2468
|
-
}
|
|
2469
|
-
else if (OperationApi.isTextOperation(operation) && hasTextHandlers) {
|
|
2470
|
-
const parentPath = PathApi.parent(operation.path);
|
|
2471
|
-
parentNode = NodeApi.get(editor, parentPath);
|
|
2472
|
-
prevText = NodeApi.get(editor, operation.path).text;
|
|
2473
|
-
}
|
|
2474
|
-
apply(operation);
|
|
2475
|
-
if (OperationApi.isNodeOperation(operation) && hasNodeHandlers) {
|
|
2476
|
-
switch (operation.type) {
|
|
2450
|
+
}).extendEditorTransforms(({ editor, getOption, tf }) => {
|
|
2451
|
+
const apply = tf?.apply ?? editor.tf.apply;
|
|
2452
|
+
return {
|
|
2453
|
+
init: bindFirst(init, editor),
|
|
2454
|
+
insertExitBreak: bindFirst(insertExitBreak, editor),
|
|
2455
|
+
resetBlock: bindFirst(resetBlock, editor),
|
|
2456
|
+
setValue: bindFirst(setValue, editor),
|
|
2457
|
+
apply(operation) {
|
|
2458
|
+
const noop = () => {};
|
|
2459
|
+
const hasNodeHandlers = editor.meta.pluginCache.handlers.onNodeChange.length > 0 || getOption("onNodeChange") !== noop;
|
|
2460
|
+
const hasTextHandlers = editor.meta.pluginCache.handlers.onTextChange.length > 0 || getOption("onTextChange") !== noop;
|
|
2461
|
+
if (!hasNodeHandlers && !hasTextHandlers) {
|
|
2462
|
+
apply(operation);
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
let prevNode;
|
|
2466
|
+
let node;
|
|
2467
|
+
let prevText;
|
|
2468
|
+
let text;
|
|
2469
|
+
let parentNode;
|
|
2470
|
+
if (OperationApi.isNodeOperation(operation) && hasNodeHandlers) switch (operation.type) {
|
|
2477
2471
|
case "insert_node":
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
const prevPath = PathApi.previous(operation.path);
|
|
2481
|
-
if (prevPath) node = NodeApi.get(editor, prevPath);
|
|
2472
|
+
prevNode = operation.node;
|
|
2473
|
+
node = operation.node;
|
|
2482
2474
|
break;
|
|
2483
|
-
|
|
2475
|
+
case "merge_node":
|
|
2484
2476
|
case "move_node":
|
|
2485
|
-
node = NodeApi.get(editor, operation.newPath);
|
|
2486
|
-
break;
|
|
2487
2477
|
case "set_node":
|
|
2488
|
-
node = NodeApi.get(editor, operation.path);
|
|
2489
|
-
break;
|
|
2490
2478
|
case "split_node":
|
|
2491
|
-
|
|
2479
|
+
prevNode = NodeApi.get(editor, operation.path);
|
|
2480
|
+
break;
|
|
2481
|
+
case "remove_node":
|
|
2482
|
+
prevNode = operation.node;
|
|
2483
|
+
node = operation.node;
|
|
2492
2484
|
break;
|
|
2493
2485
|
}
|
|
2494
|
-
if (
|
|
2495
|
-
|
|
2496
|
-
editor,
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2486
|
+
else if (OperationApi.isTextOperation(operation) && hasTextHandlers) {
|
|
2487
|
+
const parentPath = PathApi.parent(operation.path);
|
|
2488
|
+
parentNode = NodeApi.get(editor, parentPath);
|
|
2489
|
+
prevText = NodeApi.get(editor, operation.path).text;
|
|
2490
|
+
}
|
|
2491
|
+
apply(operation);
|
|
2492
|
+
if (OperationApi.isNodeOperation(operation) && hasNodeHandlers) {
|
|
2493
|
+
switch (operation.type) {
|
|
2494
|
+
case "insert_node":
|
|
2495
|
+
case "remove_node": break;
|
|
2496
|
+
case "merge_node": {
|
|
2497
|
+
const prevPath = PathApi.previous(operation.path);
|
|
2498
|
+
if (prevPath) node = NodeApi.get(editor, prevPath);
|
|
2499
|
+
break;
|
|
2500
|
+
}
|
|
2501
|
+
case "move_node":
|
|
2502
|
+
node = NodeApi.get(editor, operation.newPath);
|
|
2503
|
+
break;
|
|
2504
|
+
case "set_node":
|
|
2505
|
+
node = NodeApi.get(editor, operation.path);
|
|
2506
|
+
break;
|
|
2507
|
+
case "split_node":
|
|
2508
|
+
node = NodeApi.get(editor, operation.path);
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
if (!node) node = prevNode;
|
|
2512
|
+
if (!pipeOnNodeChange(editor, node, prevNode, operation)) getOption("onNodeChange")({
|
|
2513
|
+
editor,
|
|
2514
|
+
node,
|
|
2515
|
+
operation,
|
|
2516
|
+
prevNode
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
if (OperationApi.isTextOperation(operation) && hasTextHandlers) {
|
|
2520
|
+
const textNodeAfter = NodeApi.get(editor, operation.path);
|
|
2521
|
+
if (textNodeAfter) text = textNodeAfter.text;
|
|
2522
|
+
if (!pipeOnTextChange(editor, parentNode, text, prevText, operation)) getOption("onTextChange")({
|
|
2523
|
+
editor,
|
|
2524
|
+
node: parentNode,
|
|
2525
|
+
operation,
|
|
2526
|
+
prevText,
|
|
2527
|
+
text
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2512
2530
|
}
|
|
2513
|
-
}
|
|
2514
|
-
})
|
|
2531
|
+
};
|
|
2532
|
+
});
|
|
2515
2533
|
|
|
2516
2534
|
//#endregion
|
|
2517
2535
|
//#region src/lib/utils/normalizeDescendantsToDocumentFragment.ts
|
|
@@ -2819,5 +2837,4 @@ const withSlate = (e, { id, affinity = true, autoSelect, chunking = true, maxLen
|
|
|
2819
2837
|
const createSlateEditor = ({ editor = createEditor(), ...options } = {}) => withSlate(editor, options);
|
|
2820
2838
|
|
|
2821
2839
|
//#endregion
|
|
2822
|
-
export { DebugPlugin as $, pluginDeserializeHtml as A, withNormalizeRules as At, collapseWhiteSpaceText as B, getPluginKey as Bt, deserializeHtmlElement as C, isSlatePluginNode as Ct, pipeDeserializeHtmlLeaf as D, applyDeepToNodes as Dt, htmlElementToLeaf as E, isSlateVoid as Et, collapseWhiteSpace as F, HistoryPlugin as Ft, isHtmlBlockElement as G, getEditorPlugin as Gt, upsertInlineFormattingContext as H, getPluginType as Ht, collapseWhiteSpaceElement as I, withPlateHistory as It, isHtmlText as J, isHtmlInlineElement as K, createSlatePlugin as Kt, inferWhiteSpaceRule as L, AstPlugin as Lt, htmlBrToNewLine as M, withDeleteRules as Mt, htmlBodyToFragment as N, withBreakRules as Nt, htmlElementToElement as O, OverridePlugin as Ot, deserializeHtmlNodeChildren as P, BaseParagraphPlugin as Pt, withScrolling as Q, collapseWhiteSpaceChildren as R, getContainerTypes as Rt, htmlStringToDOMNode as S, isSlatePluginElement as St, htmlTextNodeToString as T, isSlateText as Tt, isLastNonEmptyTextOfInlineFormattingContext as U, getPluginTypes as Ut, endInlineFormattingContext as V, getPluginKeys as Vt, collapseString as W, getSlatePlugin as Wt, AUTO_SCROLL as X, isHtmlElement as Y, DOMPlugin as Z, withNodeId as _, getSlateElements as _t, pipeInsertDataQuery as a, isNodeAffinity as at, parseHtmlDocument as b, isSlateLeaf as bt, setValue as c, getEdgeNodes as ct, init as d, getPluginNodeProps as dt, PlateError as et, isEditOnly as f, getNodeDataAttributeKeys as ft, normalizeNodeId as g, defaultsDeepToNodes as gt, NodeIdPlugin as h, getInjectMatch as ht, ParserPlugin as i, setAffinitySelection as it, getDataNodeProps as j, withMergeRules as jt, pipeDeserializeHtmlElement as k, withOverrides as kt, resetBlock as l, mergeDeepToNodes as lt, pipeOnNodeChange as m, getInjectedPlugins as mt, withSlate as n, withChunking as nt, normalizeDescendantsToDocumentFragment as o, isNodesAffinity as ot, pipeOnTextChange as p, keyToDataAttribute as pt, inlineTagNames as q, createTSlatePlugin as qt, getCorePlugins as r, AffinityPlugin as rt, SlateExtensionPlugin as s, getMarkBoundaryAffinity as st, createSlateEditor as t, ChunkingPlugin as tt, insertExitBreak as u, getSlateClass as ut, LengthPlugin as v, isSlateEditor as vt, deserializeHtmlNode as w, isSlateString as wt, deserializeHtml as x, isSlateNode as xt, HtmlPlugin as y, isSlateElement as yt, collapseWhiteSpaceNode as z, getPluginByType as zt };
|
|
2823
|
-
//# sourceMappingURL=withSlate-1B0SfAWG.js.map
|
|
2840
|
+
export { DebugPlugin as $, pluginDeserializeHtml as A, withNormalizeRules as At, collapseWhiteSpaceText as B, getPluginKey as Bt, deserializeHtmlElement as C, isSlatePluginNode as Ct, pipeDeserializeHtmlLeaf as D, applyDeepToNodes as Dt, htmlElementToLeaf as E, isSlateVoid as Et, collapseWhiteSpace as F, HistoryPlugin as Ft, isHtmlBlockElement as G, getEditorPlugin as Gt, upsertInlineFormattingContext as H, getPluginType as Ht, collapseWhiteSpaceElement as I, withPlateHistory as It, isHtmlText as J, isHtmlInlineElement as K, createSlatePlugin as Kt, inferWhiteSpaceRule as L, AstPlugin as Lt, htmlBrToNewLine as M, withDeleteRules as Mt, htmlBodyToFragment as N, withBreakRules as Nt, htmlElementToElement as O, OverridePlugin as Ot, deserializeHtmlNodeChildren as P, BaseParagraphPlugin as Pt, withScrolling as Q, collapseWhiteSpaceChildren as R, getContainerTypes as Rt, htmlStringToDOMNode as S, isSlatePluginElement as St, htmlTextNodeToString as T, isSlateText as Tt, isLastNonEmptyTextOfInlineFormattingContext as U, getPluginTypes as Ut, endInlineFormattingContext as V, getPluginKeys as Vt, collapseString as W, getSlatePlugin as Wt, AUTO_SCROLL as X, isHtmlElement as Y, DOMPlugin as Z, withNodeId as _, getSlateElements as _t, pipeInsertDataQuery as a, isNodeAffinity as at, parseHtmlDocument as b, isSlateLeaf as bt, setValue as c, getEdgeNodes as ct, init as d, getPluginNodeProps as dt, PlateError as et, isEditOnly as f, getNodeDataAttributeKeys as ft, normalizeNodeId as g, defaultsDeepToNodes as gt, NodeIdPlugin as h, getInjectMatch as ht, ParserPlugin as i, setAffinitySelection as it, getDataNodeProps as j, withMergeRules as jt, pipeDeserializeHtmlElement as k, withOverrides as kt, resetBlock as l, mergeDeepToNodes as lt, pipeOnNodeChange as m, getInjectedPlugins as mt, withSlate as n, withChunking as nt, normalizeDescendantsToDocumentFragment as o, isNodesAffinity as ot, pipeOnTextChange as p, keyToDataAttribute as pt, inlineTagNames as q, createTSlatePlugin as qt, getCorePlugins as r, AffinityPlugin as rt, SlateExtensionPlugin as s, getMarkBoundaryAffinity as st, createSlateEditor as t, ChunkingPlugin as tt, insertExitBreak as u, getSlateClass as ut, LengthPlugin as v, isSlateEditor as vt, deserializeHtmlNode as w, isSlateString as wt, deserializeHtml as x, isSlateNode as xt, HtmlPlugin as y, isSlateElement as yt, collapseWhiteSpaceNode as z, getPluginByType as zt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-core",
|
|
3
|
-
"version": "52.3.
|
|
3
|
+
"version": "52.3.6",
|
|
4
4
|
"description": "The core of Plate – a plugin system for slate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentEditable",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"use-deep-compare": "^1.3.0",
|
|
54
54
|
"zustand": "^5.0.5",
|
|
55
55
|
"zustand-x": "6.2.1",
|
|
56
|
-
"@platejs/slate": "npm:@lofcz/platejs-slate@52.3.
|
|
57
|
-
"@udecode/react-hotkeys": "npm:@lofcz/udecode-react-hotkeys@52.
|
|
58
|
-
"@udecode/utils": "npm:@lofcz/udecode-utils@52.3.4",
|
|
59
|
-
"@udecode/
|
|
56
|
+
"@platejs/slate": "npm:@lofcz/platejs-slate@52.3.6",
|
|
57
|
+
"@udecode/react-hotkeys": "npm:@lofcz/udecode-react-hotkeys@52.3.6",
|
|
58
|
+
"@udecode/react-utils": "npm:@lofcz/udecode-react-utils@52.3.4",
|
|
59
|
+
"@udecode/utils": "npm:@lofcz/udecode-utils@52.3.4"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": ">=18.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-DI1HPO2Q.js","names":["Editor","IS_APPLE","KeyboardEventLike","isKeyHotkey","isHotkey","HOTKEYS","bold","compose","deleteBackward","deleteForward","escape","extendBackward","extendDownward","extendForward","extendUpward","insertSoftBreak","italic","moveBackward","moveDownward","moveForward","moveUpward","moveWordBackward","moveWordForward","selectAll","splitBlock","tab","undo","untab","APPLE_HOTKEYS","deleteLineBackward","deleteLineForward","deleteWordBackward","deleteWordForward","extendLineBackward","extendLineForward","moveLineBackward","moveLineForward","redo","transposeCharacter","WINDOWS_HOTKEYS","createHotkey","key","generic","apple","windows","isGeneric","isApple","isWindows","event","createComposing","editor","React","KeyboardEvent","composing","api","isComposing","Hotkeys","isBold","isCompose","isDeleteBackward","isDeleteForward","isDeleteLineBackward","isDeleteLineForward","isDeleteWordBackward","isDeleteWordForward","isEscape","isExtendBackward","isExtendDownward","isExtendForward","isExtendLineBackward","isExtendLineForward","isExtendUpward","isItalic","isMoveBackward","isMoveDownward","isMoveForward","isMoveLineBackward","isMoveLineForward","isMoveUpward","isMoveWordBackward","isMoveWordForward","isRedo","isSelectAll","isSoftBreak","isSplitBlock","isTab","isTransposeCharacter","isUndo","isUntab"],"sources":["../src/lib/utils/hotkeys.ts"],"sourcesContent":["import type { Editor } from '@platejs/slate';\n\nimport { IS_APPLE } from '@udecode/utils';\nimport { type KeyboardEventLike, isKeyHotkey } from 'is-hotkey';\n\nexport { isHotkey } from 'is-hotkey';\n\n/** Hotkey mappings for each platform. */\nconst HOTKEYS = {\n bold: 'mod+b',\n compose: ['down', 'left', 'right', 'up', 'backspace', 'enter'],\n deleteBackward: 'shift?+backspace',\n deleteForward: 'shift?+delete',\n escape: 'escape',\n extendBackward: 'shift+left',\n extendDownward: 'shift+down',\n extendForward: 'shift+right',\n extendUpward: 'shift+up',\n insertSoftBreak: 'shift+enter',\n italic: 'mod+i',\n moveBackward: 'left',\n moveDownward: 'down',\n moveForward: 'right',\n moveUpward: 'up',\n moveWordBackward: 'ctrl+left',\n moveWordForward: 'ctrl+right',\n selectAll: 'mod+a',\n splitBlock: 'enter',\n tab: 'tab',\n undo: 'mod+z',\n untab: 'shift+tab',\n};\n\nconst APPLE_HOTKEYS = {\n deleteBackward: ['ctrl+backspace', 'ctrl+h'],\n deleteForward: ['ctrl+delete', 'ctrl+d'],\n deleteLineBackward: 'cmd+shift?+backspace',\n deleteLineForward: ['cmd+shift?+delete', 'ctrl+k'],\n deleteWordBackward: 'opt+shift?+backspace',\n deleteWordForward: 'opt+shift?+delete',\n extendLineBackward: 'opt+shift+up',\n extendLineForward: 'opt+shift+down',\n moveLineBackward: 'opt+up',\n moveLineForward: 'opt+down',\n moveWordBackward: 'opt+left',\n moveWordForward: 'opt+right',\n redo: 'cmd+shift+z',\n transposeCharacter: 'ctrl+t',\n};\n\nconst WINDOWS_HOTKEYS = {\n deleteWordBackward: 'ctrl+shift?+backspace',\n deleteWordForward: 'ctrl+shift?+delete',\n redo: ['ctrl+y', 'ctrl+shift+z'],\n};\n\n/** Create a platform-aware hotkey checker. */\n\nexport const createHotkey = (key: string) => {\n const generic = (HOTKEYS as any)[key];\n const apple = (APPLE_HOTKEYS as any)[key];\n const windows = (WINDOWS_HOTKEYS as any)[key];\n const isGeneric = generic && isKeyHotkey(generic);\n const isApple = apple && isKeyHotkey(apple);\n const isWindows = windows && isKeyHotkey(windows);\n\n return (event: KeyboardEventLike) => {\n if (isGeneric?.(event)) return true;\n if (IS_APPLE && isApple?.(event)) return true;\n if (!IS_APPLE && isWindows?.(event)) return true;\n\n return false;\n };\n};\n\nconst createComposing =\n (key: string) =>\n (\n editor: Editor,\n event: React.KeyboardEvent,\n {\n composing,\n }: {\n /** Ignore the event if composing. */\n composing?: boolean;\n } = {}\n ) => {\n if (!createHotkey(key)(event)) return false;\n if (!!composing !== editor.api.isComposing()) return false;\n\n return true;\n };\n\nexport const Hotkeys = {\n isBold: createHotkey('bold'),\n isCompose: createHotkey('compose'),\n isDeleteBackward: createHotkey('deleteBackward'),\n isDeleteForward: createHotkey('deleteForward'),\n isDeleteLineBackward: createHotkey('deleteLineBackward'),\n isDeleteLineForward: createHotkey('deleteLineForward'),\n isDeleteWordBackward: createHotkey('deleteWordBackward'),\n isDeleteWordForward: createHotkey('deleteWordForward'),\n isEscape: createHotkey('escape'),\n isExtendBackward: createHotkey('extendBackward'),\n isExtendDownward: createHotkey('extendDownward'),\n isExtendForward: createHotkey('extendForward'),\n isExtendLineBackward: createHotkey('extendLineBackward'),\n isExtendLineForward: createHotkey('extendLineForward'),\n isExtendUpward: createHotkey('extendUpward'),\n isItalic: createHotkey('italic'),\n isMoveBackward: createHotkey('moveBackward'),\n isMoveDownward: createHotkey('moveDownward'),\n isMoveForward: createHotkey('moveForward'),\n isMoveLineBackward: createHotkey('moveLineBackward'),\n isMoveLineForward: createHotkey('moveLineForward'),\n isMoveUpward: createHotkey('moveUpward'),\n isMoveWordBackward: createHotkey('moveWordBackward'),\n isMoveWordForward: createHotkey('moveWordForward'),\n isRedo: createHotkey('redo'),\n isSelectAll: createHotkey('selectAll'),\n isSoftBreak: createHotkey('insertSoftBreak'),\n isSplitBlock: createHotkey('splitBlock'),\n isTab: createComposing('tab'),\n isTransposeCharacter: createHotkey('transposeCharacter'),\n isUndo: createHotkey('undo'),\n isUntab: createComposing('untab'),\n};\n"],"mappings":"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"}
|