@contentful/field-editor-rich-text 3.3.5 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/ContentfulEditorProvider.d.ts +3 -3
- package/dist/field-editor-rich-text.cjs.development.js +803 -468
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +745 -410
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +15 -16
- package/dist/helpers/extractNodes.d.ts +2 -3
- package/dist/helpers/sanitizeIncomingSlateDoc.d.ts +1 -1
- package/dist/helpers/transformers.d.ts +6 -7
- package/dist/internal/constants.d.ts +1 -0
- package/dist/internal/hooks.d.ts +1 -0
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/misc.d.ts +35 -0
- package/dist/internal/queries.d.ts +78 -0
- package/dist/internal/transforms.d.ts +33 -0
- package/dist/internal/types/editor.d.ts +70 -0
- package/dist/internal/types/index.d.ts +2 -0
- package/dist/internal/types/plugins.d.ts +12 -0
- package/dist/plugins/Break/createExitBreakPlugin.d.ts +2 -2
- package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -2
- package/dist/plugins/Break/createSoftBreakPlugin.d.ts +2 -2
- package/dist/plugins/CommandPalette/components/CommandList.d.ts +2 -2
- package/dist/plugins/CommandPalette/components/CommandList.styles.d.ts +1 -0
- package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +4 -2
- package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +2 -2
- package/dist/plugins/CommandPalette/onKeyDown.d.ts +2 -3
- package/dist/plugins/CommandPalette/useCommands.d.ts +2 -2
- package/dist/plugins/DragAndDrop/index.d.ts +2 -2
- package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +1 -1
- package/dist/plugins/EmbeddedEntityBlock/Util.d.ts +2 -1
- package/dist/plugins/EmbeddedEntityBlock/index.d.ts +3 -3
- package/dist/plugins/EmbeddedEntityInline/index.d.ts +2 -2
- package/dist/plugins/Heading/createHeadingPlugin.d.ts +2 -2
- package/dist/plugins/Hr/index.d.ts +3 -3
- package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +2 -3
- package/dist/plugins/Hyperlink/components/EntityHyperlink.d.ts +1 -1
- package/dist/plugins/Hyperlink/components/UrlHyperlink.d.ts +1 -1
- package/dist/plugins/Hyperlink/createHyperlinkPlugin.d.ts +2 -2
- package/dist/plugins/Hyperlink/utils.d.ts +3 -3
- package/dist/plugins/List/createListPlugin.d.ts +2 -2
- package/dist/plugins/List/insertListBreak.d.ts +2 -2
- package/dist/plugins/List/insertListFragment.d.ts +2 -3
- package/dist/plugins/List/onKeyDownList.d.ts +3 -3
- package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -2
- package/dist/plugins/List/transforms/insertListItem.d.ts +2 -2
- package/dist/plugins/List/transforms/moveListItemDown.d.ts +3 -8
- package/dist/plugins/List/transforms/moveListItems.d.ts +2 -6
- package/dist/plugins/List/transforms/toggleList.d.ts +2 -2
- package/dist/plugins/List/transforms/unwrapList.d.ts +2 -3
- package/dist/plugins/List/utils.d.ts +8 -9
- package/dist/plugins/List/withList.d.ts +2 -4
- package/dist/plugins/Marks/Bold.d.ts +3 -4
- package/dist/plugins/Marks/Code.d.ts +3 -4
- package/dist/plugins/Marks/Italic.d.ts +3 -4
- package/dist/plugins/Marks/Subscript.d.ts +3 -4
- package/dist/plugins/Marks/Superscript.d.ts +3 -4
- package/dist/plugins/Marks/Underline.d.ts +3 -4
- package/dist/plugins/Marks/helpers.d.ts +3 -5
- package/dist/plugins/Marks/index.d.ts +2 -2
- package/dist/plugins/Normalizer/createNormalizerPlugin.d.ts +2 -2
- package/dist/plugins/Normalizer/types.d.ts +3 -5
- package/dist/plugins/Normalizer/utils.d.ts +0 -3
- package/dist/plugins/Normalizer/withNormalizer.d.ts +2 -2
- package/dist/plugins/Paragraph/Paragraph.d.ts +1 -1
- package/dist/plugins/Paragraph/createParagraphPlugin.d.ts +2 -2
- package/dist/plugins/PasteHTML/createPasteHTMLPlugin.d.ts +2 -2
- package/dist/plugins/Quote/components/Quote.d.ts +1 -1
- package/dist/plugins/Quote/createQuotePlugin.d.ts +2 -2
- package/dist/plugins/Quote/shouldResetQuote.d.ts +1 -1
- package/dist/plugins/Quote/toggleQuote.d.ts +2 -3
- package/dist/plugins/Quote/withQuote.d.ts +2 -3
- package/dist/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.d.ts +2 -2
- package/dist/plugins/Table/actions/addColumn.d.ts +7 -4
- package/dist/plugins/Table/actions/addRow.d.ts +3 -3
- package/dist/plugins/Table/actions/setHeader.d.ts +2 -2
- package/dist/plugins/Table/components/Cell.d.ts +2 -2
- package/dist/plugins/Table/components/HeaderCell.d.ts +2 -2
- package/dist/plugins/Table/createTablePlugin.d.ts +2 -2
- package/dist/plugins/Table/helpers.d.ts +8 -9
- package/dist/plugins/Table/insertTableFragment.d.ts +3 -3
- package/dist/plugins/Table/onKeyDownTable.d.ts +2 -3
- package/dist/plugins/Table/tableTracking.d.ts +2 -2
- package/dist/plugins/Text/createTextPlugin.d.ts +2 -2
- package/dist/plugins/Tracking/createTrackingPlugin.d.ts +2 -2
- package/dist/plugins/Tracking/utils.d.ts +2 -2
- package/dist/plugins/TrailingParagraph/index.d.ts +2 -2
- package/dist/plugins/Voids/createVoidsPlugin.d.ts +2 -2
- package/dist/plugins/Voids/transformVoid.d.ts +2 -3
- package/dist/plugins/index.d.ts +2 -2
- package/dist/prepareDocument.d.ts +5 -6
- package/dist/test-utils/assertOutput.d.ts +2 -2
- package/dist/test-utils/createEditor.d.ts +22 -4
- package/dist/test-utils/jsx.d.ts +1 -1
- package/dist/test-utils/mockPlugin.d.ts +2 -2
- package/dist/test-utils/setEmptyDataAttribute.d.ts +2 -2
- package/package.json +17 -16
- package/dist/types.d.ts +0 -52
|
@@ -2,7 +2,7 @@ import React__default, { createContext, useContext, useMemo, useState, useEffect
|
|
|
2
2
|
import { MissingEntityCard, WrappedAssetCard, useEntity, useEntityLoader, WrappedEntryCard, ScheduledIconWithTooltip, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
3
3
|
import { entityHelpers, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import { BLOCKS, INLINES, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
|
|
5
|
-
import { usePlateEditorRef, usePlateEditorState,
|
|
5
|
+
import { usePlateEditorRef, usePlateEditorState, getPlateSelectors as getPlateSelectors$1, withoutNormalizing as withoutNormalizing$1, createPlateEditor as createPlateEditor$1, blurEditor as blurEditor$1, toSlatePoint, mockPlugin as mockPlugin$1, focusEditor as focusEditor$1, selectEditor as selectEditor$1, getNodeEntries as getNodeEntries$1, isMarkActive as isMarkActive$1, getAboveNode as getAboveNode$1, getRange as getRange$1, isText as isText$1, isElement as isElement$1, getEditorString, getBlockAbove as getBlockAbove$1, getParentNode as getParentNode$1, getLastChildPath as getLastChildPath$1, someHtmlElement as someHtmlElement$1, isCollapsed, isInline as isInline$2, isEndPoint as isEndPoint$1, getPointAfter as getPointAfter$1, isFirstChild as isFirstChild$1, getNodeEntry as getNodeEntry$1, isEditor as isEditor$1, isEditorReadOnly as isEditorReadOnly$1, isRangeAcrossBlocks as isRangeAcrossBlocks$1, getPluginType as getPluginType$1, getCommonNode as getCommonNode$1, findNode as findNode$1, isBlock, match as match$1, isAncestorEmpty as isAncestorEmpty$1, isLastChild, getPointBefore as getPointBefore$1, queryNode as queryNode$1, isNode as isNode$1, getEndPoint as getEndPoint$1, getChildren as getChildren$1, findNodePath as findNodePath$1, getLastNodeByLevel as getLastNodeByLevel$1, createPathRef as createPathRef$1, getNodeTexts as getNodeTexts$1, isSelectionAtBlockStart as isSelectionAtBlockStart$1, getNodeChildren as getNodeChildren$1, isExpanded, isSelectionAtBlockEnd as isSelectionAtBlockEnd$1, someNode as someNode$1, getStartPoint as getStartPoint$1, getMarks as getMarks$1, wrapNodes as wrapNodes$1, insertNodes as insertNodes$1, unhangRange as unhangRange$1, setSelection as setSelection$1, unsetNodes as unsetNodes$1, removeMark as removeMark$1, addMark as addMark$1, removeNodes as removeNodes$1, unwrapNodes as unwrapNodes$1, liftNodes as liftNodes$1, select as select$1, toggleMark as toggleMark$1, normalizeEditor, setNodes as setNodes$1, toggleNodeType as toggleNodeType$1, deleteText as deleteText$1, deleteFragment as deleteFragment$1, splitNodes as splitNodes$1, moveSelection as moveSelection$1, insertText as insertText$1, collapseSelection as collapseSelection$1, moveChildren as moveChildren$1, moveNodes as moveNodes$1, ELEMENT_DEFAULT as ELEMENT_DEFAULT$1, isBlockAboveEmpty, KEY_DESERIALIZE_HTML, hasSingleChild, createDeserializeHtmlPlugin, createDeserializeAstPlugin, getPlateActions, Plate } from '@udecode/plate-core';
|
|
6
6
|
import { css, cx } from 'emotion';
|
|
7
7
|
import areEqual from 'fast-deep-equal';
|
|
8
8
|
import noop from 'lodash-es/noop';
|
|
@@ -14,20 +14,20 @@ import { ScreenReaderOnly, Popover, SectionHeading, Stack, Flex, AssetCard, Entr
|
|
|
14
14
|
import { Portal } from '@contentful/f36-utils';
|
|
15
15
|
import constate from 'constate';
|
|
16
16
|
import isHotkey from 'is-hotkey';
|
|
17
|
-
import {
|
|
18
|
-
import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
|
|
17
|
+
import { Path, Range, Text, Node, Element, Point } from 'slate';
|
|
19
18
|
import find from 'lodash-es/find';
|
|
20
19
|
import flow from 'lodash-es/flow';
|
|
21
20
|
import get from 'lodash-es/get';
|
|
22
21
|
import tokens from '@contentful/f36-tokens';
|
|
23
|
-
import {
|
|
22
|
+
import { useSelected, useReadOnly as useReadOnly$1, useFocused } from 'slate-react';
|
|
23
|
+
import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, SubscriptIcon, SuperscriptIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon, MoreHorizontalIcon } from '@contentful/f36-icons';
|
|
24
24
|
import { getListTypes, ELEMENT_LIC, getListItemEntry, isListNested, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL } from '@udecode/plate-list';
|
|
25
25
|
import castArray from 'lodash-es/castArray';
|
|
26
|
-
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1,
|
|
26
|
+
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createSubscriptPlugin as createSubscriptPlugin$1, createSuperscriptPlugin as createSuperscriptPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
|
|
27
27
|
import isPlainObject from 'is-plain-obj';
|
|
28
28
|
import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
|
|
29
29
|
import { createSelectOnBackspacePlugin as createSelectOnBackspacePlugin$1 } from '@udecode/plate-select';
|
|
30
|
-
import {
|
|
30
|
+
import { getEmptyRowNode, getEmptyCellNode, ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD, deleteRow, deleteColumn, deleteTable, onKeyDownTable as onKeyDownTable$1, getTableEntries, createTablePlugin as createTablePlugin$1, withTable } from '@udecode/plate-table';
|
|
31
31
|
import { toContentfulDocument, toSlatejsDocument } from '@contentful/contentful-slatejs-adapter';
|
|
32
32
|
import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';
|
|
33
33
|
import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
|
|
@@ -276,6 +276,43 @@ function useContentfulEditorRef(id) {
|
|
|
276
276
|
return editor;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
var createPlateEditor = function createPlateEditor(options) {
|
|
280
|
+
if (options === void 0) {
|
|
281
|
+
options = {};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return createPlateEditor$1(options);
|
|
285
|
+
};
|
|
286
|
+
var withoutNormalizing = function withoutNormalizing(editor, fn) {
|
|
287
|
+
return withoutNormalizing$1(editor, fn);
|
|
288
|
+
};
|
|
289
|
+
var focusEditor = function focusEditor(editor, target) {
|
|
290
|
+
focusEditor$1(editor, target);
|
|
291
|
+
};
|
|
292
|
+
var blurEditor = function blurEditor(editor) {
|
|
293
|
+
blurEditor$1(editor);
|
|
294
|
+
};
|
|
295
|
+
var selectEditor = function selectEditor(editor, opts) {
|
|
296
|
+
selectEditor$1(editor, opts);
|
|
297
|
+
};
|
|
298
|
+
var fromDOMPoint = function fromDOMPoint(editor, domPoint, opts) {
|
|
299
|
+
if (opts === void 0) {
|
|
300
|
+
opts = {
|
|
301
|
+
exactMatch: false,
|
|
302
|
+
suppressThrow: false
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return toSlatePoint(editor, domPoint, opts);
|
|
307
|
+
};
|
|
308
|
+
var mockPlugin = function mockPlugin(plugin) {
|
|
309
|
+
return mockPlugin$1( // TODO check if there is a way around this ugly casting
|
|
310
|
+
plugin);
|
|
311
|
+
};
|
|
312
|
+
var getPlateSelectors = function getPlateSelectors(id) {
|
|
313
|
+
return getPlateSelectors$1(id);
|
|
314
|
+
};
|
|
315
|
+
|
|
279
316
|
var createSoftBreakPlugin = function createSoftBreakPlugin() {
|
|
280
317
|
return createSoftBreakPlugin$1({
|
|
281
318
|
then: function then(editor) {
|
|
@@ -465,14 +502,280 @@ var useCommandList = function useCommandList(commandItems, container) {
|
|
|
465
502
|
};
|
|
466
503
|
};
|
|
467
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Get text content at location
|
|
507
|
+
*/
|
|
508
|
+
|
|
509
|
+
var getText = function getText(editor, at) {
|
|
510
|
+
return getEditorString(editor, at);
|
|
511
|
+
};
|
|
512
|
+
var isText = function isText(value) {
|
|
513
|
+
return isText$1(value);
|
|
514
|
+
};
|
|
515
|
+
var getEndPoint = function getEndPoint(editor, at) {
|
|
516
|
+
return getEndPoint$1(editor, at);
|
|
517
|
+
};
|
|
518
|
+
var getStartPoint = function getStartPoint(editor, at) {
|
|
519
|
+
return getStartPoint$1(editor, at);
|
|
520
|
+
};
|
|
521
|
+
var isNode = function isNode(value) {
|
|
522
|
+
return isNode$1(value);
|
|
523
|
+
};
|
|
524
|
+
var isSelectionAtBlockEnd = function isSelectionAtBlockEnd(editor, options) {
|
|
525
|
+
return isSelectionAtBlockEnd$1(editor, options);
|
|
526
|
+
};
|
|
527
|
+
var isSelectionAtBlockStart = function isSelectionAtBlockStart(editor, options) {
|
|
528
|
+
return isSelectionAtBlockStart$1(editor, options);
|
|
529
|
+
};
|
|
530
|
+
var getBlockAbove = function getBlockAbove(editor, options) {
|
|
531
|
+
return getBlockAbove$1(editor, options);
|
|
532
|
+
};
|
|
533
|
+
var getNodeEntry = function getNodeEntry(editor, at, options) {
|
|
534
|
+
return getNodeEntry$1(editor, at, options);
|
|
535
|
+
};
|
|
536
|
+
var getNodeEntries = function getNodeEntries(editor, options) {
|
|
537
|
+
return getNodeEntries$1(editor, options);
|
|
538
|
+
}; // TODO: Ancestor may not be the correct type for root
|
|
539
|
+
|
|
540
|
+
var getNodeChildren = function getNodeChildren(root, path, options) {
|
|
541
|
+
return getNodeChildren$1(root, path, options);
|
|
542
|
+
};
|
|
543
|
+
var getParentNode = function getParentNode(editor, at, options) {
|
|
544
|
+
return getParentNode$1(editor, at, options);
|
|
545
|
+
};
|
|
546
|
+
var someNode = function someNode(editor, options) {
|
|
547
|
+
return someNode$1(editor, options);
|
|
548
|
+
};
|
|
549
|
+
var getChildren = function getChildren(entry) {
|
|
550
|
+
// Node.children crashes when given a text node
|
|
551
|
+
if (Text.isText(entry[0])) {
|
|
552
|
+
return [];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return getChildren$1(entry);
|
|
556
|
+
};
|
|
557
|
+
var isFirstChild = function isFirstChild(path) {
|
|
558
|
+
return isFirstChild$1(path);
|
|
559
|
+
};
|
|
560
|
+
var getDescendantNodeByPath = function getDescendantNodeByPath(root, path) {
|
|
561
|
+
// @ts-expect-error
|
|
562
|
+
return Node.get(root, path);
|
|
563
|
+
};
|
|
564
|
+
var isRangeCollapsed = function isRangeCollapsed(range) {
|
|
565
|
+
return isCollapsed(range);
|
|
566
|
+
}; // TODO: simplify
|
|
567
|
+
|
|
568
|
+
var isRangeAcrossBlocks = function isRangeAcrossBlocks(editor, options) {
|
|
569
|
+
return isRangeAcrossBlocks$1(editor, options);
|
|
570
|
+
};
|
|
571
|
+
var isRangeExpanded = function isRangeExpanded(range) {
|
|
572
|
+
return isExpanded(range);
|
|
573
|
+
};
|
|
574
|
+
var getRange = function getRange(editor, at, to) {
|
|
575
|
+
return getRange$1(editor, at, to);
|
|
576
|
+
};
|
|
577
|
+
var getRangeEdges = function getRangeEdges(range) {
|
|
578
|
+
return Range.edges(range);
|
|
579
|
+
};
|
|
580
|
+
var getRangeStart = function getRangeStart(range) {
|
|
581
|
+
return Range.start(range);
|
|
582
|
+
};
|
|
583
|
+
var getRangeEnd = function getRangeEnd(range) {
|
|
584
|
+
return Range.end(range);
|
|
585
|
+
};
|
|
586
|
+
var getAboveNode = function getAboveNode(editor, opts) {
|
|
587
|
+
return getAboveNode$1(editor, opts);
|
|
588
|
+
};
|
|
589
|
+
var getCommonNode = function getCommonNode(root, path, another) {
|
|
590
|
+
return getCommonNode$1(root, path, another);
|
|
591
|
+
};
|
|
592
|
+
var getNodeTexts = function getNodeTexts(root, opts) {
|
|
593
|
+
return getNodeTexts$1(root, opts);
|
|
594
|
+
};
|
|
595
|
+
var findNode = function findNode(editor, options) {
|
|
596
|
+
return findNode$1(editor, options);
|
|
597
|
+
};
|
|
598
|
+
var isMarkActive = function isMarkActive(editor, type) {
|
|
599
|
+
return isMarkActive$1(editor, type);
|
|
600
|
+
};
|
|
601
|
+
var getMarks = function getMarks(editor) {
|
|
602
|
+
return getMarks$1(editor);
|
|
603
|
+
};
|
|
604
|
+
var isEditor = function isEditor(value) {
|
|
605
|
+
return isEditor$1(value);
|
|
606
|
+
};
|
|
607
|
+
var isEditorReadOnly = function isEditorReadOnly(editor) {
|
|
608
|
+
return isEditorReadOnly$1(editor);
|
|
609
|
+
};
|
|
610
|
+
var isElement = function isElement(value) {
|
|
611
|
+
return isElement$1(value);
|
|
612
|
+
};
|
|
613
|
+
var isBlockNode = function isBlockNode(editor, value) {
|
|
614
|
+
return isBlock(editor, value);
|
|
615
|
+
};
|
|
616
|
+
var findNodePath = function findNodePath(editor, node) {
|
|
617
|
+
return findNodePath$1(editor, node);
|
|
618
|
+
};
|
|
619
|
+
var isAncestorPath = function isAncestorPath(path, another) {
|
|
620
|
+
return Path.isAncestor(path, another);
|
|
621
|
+
};
|
|
622
|
+
var isAncestorEmpty = function isAncestorEmpty(editor, node) {
|
|
623
|
+
return isAncestorEmpty$1(editor, node);
|
|
624
|
+
};
|
|
625
|
+
var getParentPath = function getParentPath(path) {
|
|
626
|
+
return Path.parent(path);
|
|
627
|
+
};
|
|
628
|
+
var getNextPath = function getNextPath(path) {
|
|
629
|
+
return Path.next(path);
|
|
630
|
+
};
|
|
631
|
+
var getPreviousPath = function getPreviousPath(path) {
|
|
632
|
+
return Path.previous(path);
|
|
633
|
+
};
|
|
634
|
+
var getLastChildPath = function getLastChildPath(nodeEntry) {
|
|
635
|
+
return getLastChildPath$1(nodeEntry);
|
|
636
|
+
};
|
|
637
|
+
var getPathLevels = function getPathLevels(path, options) {
|
|
638
|
+
return Path.levels(path, options);
|
|
639
|
+
};
|
|
640
|
+
var isFirstChildPath = function isFirstChildPath(path) {
|
|
641
|
+
return isFirstChild$1(path);
|
|
642
|
+
};
|
|
643
|
+
var isLastChildPath = function isLastChildPath(entry, childPath) {
|
|
644
|
+
return isLastChild(entry, childPath);
|
|
645
|
+
};
|
|
646
|
+
var matchNode = function matchNode(node, path, fn) {
|
|
647
|
+
return match$1(node, path, fn);
|
|
648
|
+
};
|
|
649
|
+
var someHtmlElement = function someHtmlElement(rootNode, predicate) {
|
|
650
|
+
return someHtmlElement$1(rootNode, predicate);
|
|
651
|
+
};
|
|
652
|
+
var getPointBefore = function getPointBefore(editor, at, options) {
|
|
653
|
+
return getPointBefore$1(editor, at, options);
|
|
654
|
+
};
|
|
655
|
+
var getPointAfter = function getPointAfter(editor, at, options) {
|
|
656
|
+
return getPointAfter$1(editor, at, options);
|
|
657
|
+
};
|
|
658
|
+
var isEndPoint = function isEndPoint(editor, point, at) {
|
|
659
|
+
return isEndPoint$1(editor, point, at);
|
|
660
|
+
};
|
|
661
|
+
var isInline = function isInline(editor, value) {
|
|
662
|
+
return isInline$2(editor, value);
|
|
663
|
+
};
|
|
664
|
+
var queryNode = function queryNode(entry, options) {
|
|
665
|
+
return queryNode$1(entry, options);
|
|
666
|
+
};
|
|
667
|
+
var getPluginType = function getPluginType(editor, key) {
|
|
668
|
+
return getPluginType$1(editor, key);
|
|
669
|
+
};
|
|
670
|
+
var createPathRef = function createPathRef(editor, at) {
|
|
671
|
+
return createPathRef$1(editor, at);
|
|
672
|
+
};
|
|
673
|
+
var match = function match(obj, path, predicate) {
|
|
674
|
+
return match$1(obj, path, predicate);
|
|
675
|
+
};
|
|
676
|
+
var getLastNodeByLevel = function getLastNodeByLevel(editor, level) {
|
|
677
|
+
return getLastNodeByLevel$1(editor, level);
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Apply editor normalization rules
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
var normalize = function normalize(editor, options) {
|
|
685
|
+
if (options === void 0) {
|
|
686
|
+
options = {
|
|
687
|
+
force: true
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return normalizeEditor(editor, options);
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* Set the selection to a location
|
|
695
|
+
*/
|
|
696
|
+
|
|
697
|
+
var setSelection = function setSelection(editor, props) {
|
|
698
|
+
return setSelection$1(editor, props);
|
|
699
|
+
};
|
|
700
|
+
var select = function select(editor, location) {
|
|
701
|
+
return select$1(editor, location);
|
|
702
|
+
};
|
|
703
|
+
var moveSelection = function moveSelection(editor, options) {
|
|
704
|
+
return moveSelection$1(editor, options);
|
|
705
|
+
};
|
|
706
|
+
var moveChildren = function moveChildren(editor, options) {
|
|
707
|
+
return moveChildren$1(editor, options);
|
|
708
|
+
};
|
|
709
|
+
var collapseSelection = function collapseSelection(editor, options) {
|
|
710
|
+
return collapseSelection$1(editor, options);
|
|
711
|
+
};
|
|
712
|
+
var setNodes = function setNodes(editor, attrs, opts) {
|
|
713
|
+
setNodes$1(editor, attrs, opts);
|
|
714
|
+
};
|
|
715
|
+
var unsetNodes = function unsetNodes(editor, props, options) {
|
|
716
|
+
unsetNodes$1(editor, props, options);
|
|
717
|
+
};
|
|
718
|
+
var insertNodes = function insertNodes(editor, nodes, opts) {
|
|
719
|
+
return insertNodes$1(editor, nodes, opts);
|
|
720
|
+
};
|
|
721
|
+
var splitNodes = function splitNodes(editor, options) {
|
|
722
|
+
return splitNodes$1(editor, options);
|
|
723
|
+
};
|
|
724
|
+
var liftNodes = function liftNodes(editor, options) {
|
|
725
|
+
return liftNodes$1(editor, options);
|
|
726
|
+
};
|
|
727
|
+
var unwrapNodes = function unwrapNodes(editor, options) {
|
|
728
|
+
return unwrapNodes$1(editor, options);
|
|
729
|
+
};
|
|
730
|
+
var wrapNodes = function wrapNodes(editor, element, options) {
|
|
731
|
+
return wrapNodes$1(editor, element, options);
|
|
732
|
+
};
|
|
733
|
+
var toggleNodeType = function toggleNodeType(editor, options, editorOptions) {
|
|
734
|
+
toggleNodeType$1(editor, options, editorOptions);
|
|
735
|
+
};
|
|
736
|
+
var removeMark = function removeMark(editor, type, at) {
|
|
737
|
+
removeMark$1(editor, {
|
|
738
|
+
key: type,
|
|
739
|
+
at: at
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
var unhangRange = function unhangRange(editor, range, options) {
|
|
743
|
+
return unhangRange$1(editor, range, options);
|
|
744
|
+
};
|
|
745
|
+
var toggleMark = function toggleMark(editor, options) {
|
|
746
|
+
return toggleMark$1(editor, options);
|
|
747
|
+
};
|
|
748
|
+
var addMark = function addMark(editor, type, value) {
|
|
749
|
+
if (value === void 0) {
|
|
750
|
+
value = true;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
addMark$1(editor, type, value);
|
|
754
|
+
};
|
|
755
|
+
var insertText = function insertText(editor, text, options) {
|
|
756
|
+
return insertText$1(editor, text, options);
|
|
757
|
+
};
|
|
758
|
+
var deleteText = function deleteText(editor, opts) {
|
|
759
|
+
deleteText$1(editor, opts);
|
|
760
|
+
};
|
|
761
|
+
var removeNodes = function removeNodes(editor, opts) {
|
|
762
|
+
removeNodes$1(editor, opts);
|
|
763
|
+
};
|
|
764
|
+
var moveNodes = function moveNodes(editor, opts) {
|
|
765
|
+
moveNodes$1(editor, opts);
|
|
766
|
+
};
|
|
767
|
+
var deleteFragment = function deleteFragment(editor, options) {
|
|
768
|
+
return deleteFragment$1(editor, options);
|
|
769
|
+
};
|
|
770
|
+
|
|
468
771
|
var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
469
772
|
var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
|
|
470
773
|
|
|
471
774
|
var LINK_TYPES = [INLINES.HYPERLINK, INLINES.ENTRY_HYPERLINK, INLINES.ASSET_HYPERLINK];
|
|
472
775
|
function isBlockSelected(editor, type) {
|
|
473
|
-
var _Array$from = Array.from(
|
|
776
|
+
var _Array$from = Array.from(getNodeEntries(editor, {
|
|
474
777
|
match: function match(node) {
|
|
475
|
-
return
|
|
778
|
+
return isElement(node) && node.type === type;
|
|
476
779
|
}
|
|
477
780
|
})),
|
|
478
781
|
match = _Array$from[0];
|
|
@@ -490,7 +793,7 @@ function getNodeEntryFromSelection(editor, nodeTypeOrTypes, path) {
|
|
|
490
793
|
var nodeTypes = Array.isArray(nodeTypeOrTypes) ? nodeTypeOrTypes : [nodeTypeOrTypes];
|
|
491
794
|
|
|
492
795
|
for (var i = 0; i < path.length; i++) {
|
|
493
|
-
var nodeEntry =
|
|
796
|
+
var nodeEntry = getNodeEntry(editor, path.slice(0, i + 1));
|
|
494
797
|
if (nodeTypes.includes(nodeEntry[0].type)) return nodeEntry;
|
|
495
798
|
}
|
|
496
799
|
|
|
@@ -505,13 +808,13 @@ function isNodeTypeSelected(editor, nodeType) {
|
|
|
505
808
|
return !!node;
|
|
506
809
|
}
|
|
507
810
|
function moveToTheNextLine(editor) {
|
|
508
|
-
|
|
811
|
+
moveSelection(editor, {
|
|
509
812
|
distance: 1,
|
|
510
813
|
unit: 'line'
|
|
511
814
|
});
|
|
512
815
|
}
|
|
513
816
|
function moveToTheNextChar(editor) {
|
|
514
|
-
|
|
817
|
+
moveSelection(editor, {
|
|
515
818
|
distance: 1,
|
|
516
819
|
unit: 'offset'
|
|
517
820
|
});
|
|
@@ -525,11 +828,11 @@ function insertEmptyParagraph(editor, options) {
|
|
|
525
828
|
data: {},
|
|
526
829
|
isVoid: false
|
|
527
830
|
};
|
|
528
|
-
|
|
831
|
+
insertNodes(editor, emptyParagraph, options);
|
|
529
832
|
}
|
|
530
833
|
function getElementFromCurrentSelection(editor) {
|
|
531
834
|
if (!editor.selection) return [];
|
|
532
|
-
return Array.from(
|
|
835
|
+
return Array.from(getNodeEntries(editor, {
|
|
533
836
|
/**
|
|
534
837
|
* editor.select is a Range, which includes anchor and focus, the beginning and the end of a selection
|
|
535
838
|
* when using only editor.selection.focus, we might get only the end of the selection, or where the text cursor is
|
|
@@ -537,7 +840,7 @@ function getElementFromCurrentSelection(editor) {
|
|
|
537
840
|
**/
|
|
538
841
|
at: editor.selection,
|
|
539
842
|
match: function match(node) {
|
|
540
|
-
return
|
|
843
|
+
return isElement(node);
|
|
541
844
|
}
|
|
542
845
|
})).flat();
|
|
543
846
|
}
|
|
@@ -566,9 +869,9 @@ function isLinkActive(editor) {
|
|
|
566
869
|
return false;
|
|
567
870
|
}
|
|
568
871
|
|
|
569
|
-
var _Array$from2 = Array.from(
|
|
872
|
+
var _Array$from2 = Array.from(getNodeEntries(editor, {
|
|
570
873
|
match: function match(node) {
|
|
571
|
-
return !
|
|
874
|
+
return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
|
|
572
875
|
}
|
|
573
876
|
})),
|
|
574
877
|
link = _Array$from2[0];
|
|
@@ -577,9 +880,9 @@ function isLinkActive(editor) {
|
|
|
577
880
|
} // TODO: move to hyperlink plugin
|
|
578
881
|
|
|
579
882
|
function unwrapLink(editor) {
|
|
580
|
-
|
|
883
|
+
unwrapNodes(editor, {
|
|
581
884
|
match: function match(node) {
|
|
582
|
-
return !
|
|
885
|
+
return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
|
|
583
886
|
}
|
|
584
887
|
});
|
|
585
888
|
} // TODO: move to hyperlink plugin
|
|
@@ -596,7 +899,7 @@ function wrapLink(editor, _ref) {
|
|
|
596
899
|
}
|
|
597
900
|
|
|
598
901
|
var selection = editor.selection;
|
|
599
|
-
var isCollapsed = selection &&
|
|
902
|
+
var isCollapsed = selection && isRangeCollapsed(selection);
|
|
600
903
|
var link = {
|
|
601
904
|
type: type,
|
|
602
905
|
data: {},
|
|
@@ -619,41 +922,41 @@ function wrapLink(editor, _ref) {
|
|
|
619
922
|
|
|
620
923
|
|
|
621
924
|
if (path) {
|
|
622
|
-
|
|
925
|
+
setNodes(editor, link, {
|
|
623
926
|
at: path
|
|
624
927
|
});
|
|
625
|
-
|
|
928
|
+
insertText(editor, text, {
|
|
626
929
|
at: path
|
|
627
930
|
});
|
|
628
|
-
|
|
931
|
+
select(editor, path);
|
|
629
932
|
} else if (isCollapsed) {
|
|
630
|
-
|
|
933
|
+
insertNodes(editor, link);
|
|
631
934
|
} else {
|
|
632
|
-
|
|
935
|
+
wrapNodes(editor, link, {
|
|
633
936
|
split: true
|
|
634
937
|
});
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
938
|
+
deleteText(editor);
|
|
939
|
+
insertText(editor, text);
|
|
940
|
+
collapseSelection(editor, {
|
|
638
941
|
edge: 'end'
|
|
639
942
|
});
|
|
640
943
|
}
|
|
641
944
|
}
|
|
642
945
|
function getAncestorPathFromSelection(editor) {
|
|
643
946
|
if (!editor.selection) return undefined;
|
|
644
|
-
return
|
|
947
|
+
return getPathLevels(editor.selection.focus.path).find(function (level) {
|
|
645
948
|
return level.length === 1;
|
|
646
949
|
});
|
|
647
950
|
}
|
|
648
951
|
var INLINE_TYPES = /*#__PURE__*/Object.values(INLINES);
|
|
649
952
|
var isInlineOrText = function isInlineOrText(node) {
|
|
650
953
|
// either text or inline elements
|
|
651
|
-
return
|
|
954
|
+
return isText(node) || isElement(node) && INLINE_TYPES.includes(node.type);
|
|
652
955
|
};
|
|
653
956
|
var focus = function focus(editor) {
|
|
654
957
|
var x = window.scrollX;
|
|
655
958
|
var y = window.scrollY;
|
|
656
|
-
|
|
959
|
+
focusEditor(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
|
|
657
960
|
|
|
658
961
|
if (IS_SAFARI) {
|
|
659
962
|
setTimeout(function () {
|
|
@@ -664,7 +967,7 @@ var focus = function focus(editor) {
|
|
|
664
967
|
function toggleElement(editor, options, editorOptions) {
|
|
665
968
|
toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
|
|
666
969
|
|
|
667
|
-
|
|
970
|
+
setNodes(editor, {
|
|
668
971
|
data: {}
|
|
669
972
|
});
|
|
670
973
|
}
|
|
@@ -1573,35 +1876,32 @@ function insertBlock(editor, nodeType, entity) {
|
|
|
1573
1876
|
var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
|
|
1574
1877
|
|
|
1575
1878
|
if (hasText) {
|
|
1576
|
-
|
|
1879
|
+
insertNodes(editor, linkedEntityBlock);
|
|
1577
1880
|
} else {
|
|
1578
|
-
|
|
1881
|
+
setNodes(editor, linkedEntityBlock);
|
|
1579
1882
|
}
|
|
1580
1883
|
|
|
1581
1884
|
focus(editor);
|
|
1582
1885
|
}
|
|
1583
1886
|
|
|
1584
1887
|
var removeCommand = function removeCommand(editor) {
|
|
1585
|
-
var
|
|
1586
|
-
path =
|
|
1888
|
+
var _getAboveNode = getAboveNode(editor),
|
|
1889
|
+
path = _getAboveNode[1];
|
|
1587
1890
|
|
|
1588
|
-
var range =
|
|
1589
|
-
|
|
1590
|
-
removeMark(editor,
|
|
1591
|
-
|
|
1592
|
-
at: range
|
|
1593
|
-
});
|
|
1594
|
-
Transforms["delete"](editor);
|
|
1891
|
+
var range = getRange(editor, path);
|
|
1892
|
+
select(editor, range.focus.path);
|
|
1893
|
+
removeMark(editor, COMMAND_PROMPT, range);
|
|
1894
|
+
deleteText(editor);
|
|
1595
1895
|
};
|
|
1596
1896
|
|
|
1597
1897
|
var removeQuery = function removeQuery(editor) {
|
|
1598
|
-
var
|
|
1599
|
-
path =
|
|
1898
|
+
var _getAboveNode2 = getAboveNode(editor),
|
|
1899
|
+
path = _getAboveNode2[1];
|
|
1600
1900
|
|
|
1601
|
-
var range =
|
|
1901
|
+
var range = getRange(editor, path);
|
|
1602
1902
|
|
|
1603
1903
|
if (range.focus.offset - range.anchor.offset > 1) {
|
|
1604
|
-
|
|
1904
|
+
deleteText(editor, {
|
|
1605
1905
|
at: range.focus,
|
|
1606
1906
|
distance: range.focus.offset - 1,
|
|
1607
1907
|
reverse: true
|
|
@@ -1642,7 +1942,7 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1642
1942
|
var selection = editor.selection;
|
|
1643
1943
|
editor.insertSoftBreak();
|
|
1644
1944
|
insertBlock(editor, BLOCKS.EMBEDDED_ENTRY, entry.entry);
|
|
1645
|
-
|
|
1945
|
+
select(editor, selection);
|
|
1646
1946
|
editor.tracking.onCommandPaletteAction('insert', {
|
|
1647
1947
|
nodeType: BLOCKS.EMBEDDED_ENTRY
|
|
1648
1948
|
});
|
|
@@ -1677,7 +1977,7 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1677
1977
|
callback: function callback() {
|
|
1678
1978
|
var inlineNode = createInlineEntryNode(entry.id);
|
|
1679
1979
|
removeCommand(editor);
|
|
1680
|
-
|
|
1980
|
+
insertNodes(editor, inlineNode);
|
|
1681
1981
|
editor.insertText('');
|
|
1682
1982
|
editor.tracking.onCommandPaletteAction('insert', {
|
|
1683
1983
|
nodeType: INLINES.EMBEDDED_ENTRY
|
|
@@ -1726,7 +2026,7 @@ var useCommands = function useCommands(sdk, query, editor) {
|
|
|
1726
2026
|
var selection = editor.selection;
|
|
1727
2027
|
editor.insertSoftBreak();
|
|
1728
2028
|
insertBlock(editor, BLOCKS.EMBEDDED_ASSET, asset.entity);
|
|
1729
|
-
|
|
2029
|
+
select(editor, selection);
|
|
1730
2030
|
editor.tracking.onCommandPaletteAction('insert', {
|
|
1731
2031
|
nodeType: BLOCKS.EMBEDDED_ASSET
|
|
1732
2032
|
});
|
|
@@ -1780,6 +2080,9 @@ var styles = {
|
|
|
1780
2080
|
marginLeft: 0
|
|
1781
2081
|
}
|
|
1782
2082
|
}),
|
|
2083
|
+
menuPoper: /*#__PURE__*/css({
|
|
2084
|
+
zIndex: tokens.zIndexModal
|
|
2085
|
+
}),
|
|
1783
2086
|
menuContent: /*#__PURE__*/css({
|
|
1784
2087
|
width: '400px',
|
|
1785
2088
|
maxHeight: '300px'
|
|
@@ -1952,6 +2255,7 @@ var CommandList = function CommandList(_ref5) {
|
|
|
1952
2255
|
}, /*#__PURE__*/createElement(ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/createElement(Portal, null, /*#__PURE__*/createElement("div", _extends({
|
|
1953
2256
|
"aria-hidden": true,
|
|
1954
2257
|
ref: popoverContainer,
|
|
2258
|
+
className: styles.menuPoper,
|
|
1955
2259
|
style: popper.styles.popper
|
|
1956
2260
|
}, popper.attributes.popper), /*#__PURE__*/createElement(Popover, {
|
|
1957
2261
|
isOpen: isOpen,
|
|
@@ -2007,43 +2311,43 @@ var CommandPrompt = function CommandPrompt(props) {
|
|
|
2007
2311
|
var createOnKeyDown = function createOnKeyDown() {
|
|
2008
2312
|
return function (editor) {
|
|
2009
2313
|
return function (event) {
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2314
|
+
// Support for different keyboard layouts:
|
|
2315
|
+
// `isHotKey` uses by default `event.which`, which will never generates a match for all layouts (QWERTY: `/`, QWERTZ: `shift+7`)
|
|
2316
|
+
// with `byKey: true` `isHotKey` uses `event.key` which will return the interpreted key '/'
|
|
2317
|
+
// It would still fail without the the optional `shift?` param, as it first checks the modKeys (`shiftKey` would be true on QWERTZ)
|
|
2318
|
+
if (isHotkey('shift?+/', {
|
|
2319
|
+
byKey: true
|
|
2320
|
+
}, event)) {
|
|
2321
|
+
addMark(editor, COMMAND_PROMPT);
|
|
2014
2322
|
editor.tracking.onCommandPaletteAction('openRichTextCommandPalette');
|
|
2015
2323
|
}
|
|
2016
2324
|
|
|
2017
2325
|
var isActive = isMarkActive(editor, COMMAND_PROMPT);
|
|
2018
2326
|
|
|
2019
|
-
if (isActive) {
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
} else if (isHotkey('backspace', event)) {
|
|
2023
|
-
var _getAbove = getAbove(editor),
|
|
2024
|
-
path = _getAbove[1];
|
|
2327
|
+
if (!isActive) {
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2025
2330
|
|
|
2026
|
-
|
|
2331
|
+
if (isHotkey('enter', event)) {
|
|
2332
|
+
return event.preventDefault();
|
|
2333
|
+
}
|
|
2027
2334
|
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
key: COMMAND_PROMPT,
|
|
2031
|
-
at: range
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
} else if (isHotkey('escape', event)) {
|
|
2035
|
-
var _getAbove2 = getAbove(editor),
|
|
2036
|
-
_path = _getAbove2[1];
|
|
2335
|
+
var _getAboveNode = getAboveNode(editor),
|
|
2336
|
+
path = _getAboveNode[1];
|
|
2037
2337
|
|
|
2038
|
-
|
|
2338
|
+
var range = getRange(editor, path);
|
|
2039
2339
|
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
|
|
2340
|
+
if (isHotkey('backspace', event)) {
|
|
2341
|
+
// if it is the last character in the command string
|
|
2342
|
+
if (range.focus.offset - range.anchor.offset === 1) {
|
|
2343
|
+
removeMark(editor, COMMAND_PROMPT, range);
|
|
2045
2344
|
}
|
|
2046
2345
|
}
|
|
2346
|
+
|
|
2347
|
+
if (isHotkey('escape', event)) {
|
|
2348
|
+
removeMark(editor, COMMAND_PROMPT, range);
|
|
2349
|
+
editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
|
|
2350
|
+
}
|
|
2047
2351
|
};
|
|
2048
2352
|
};
|
|
2049
2353
|
};
|
|
@@ -2089,9 +2393,9 @@ function createDragAndDropPlugin() {
|
|
|
2089
2393
|
// If true, the next handlers will be skipped.
|
|
2090
2394
|
onDrop: function onDrop(editor) {
|
|
2091
2395
|
return function (event) {
|
|
2092
|
-
var _Array$from = Array.from(
|
|
2396
|
+
var _Array$from = Array.from(getNodeEntries(editor, {
|
|
2093
2397
|
match: function match(node) {
|
|
2094
|
-
return DRAGGABLE_TYPES.includes(node
|
|
2398
|
+
return DRAGGABLE_TYPES.includes(node.type);
|
|
2095
2399
|
}
|
|
2096
2400
|
})),
|
|
2097
2401
|
draggingBlock = _Array$from[0];
|
|
@@ -2135,7 +2439,7 @@ function withLinkTracking(Component) {
|
|
|
2135
2439
|
return function ComponentWithTracking(props) {
|
|
2136
2440
|
var editor = useContentfulEditorRef();
|
|
2137
2441
|
var onEntityFetchComplete = React__default.useCallback(function () {
|
|
2138
|
-
return editor.tracking.onViewportAction('linkRendered');
|
|
2442
|
+
return editor == null ? void 0 : editor.tracking.onViewportAction('linkRendered');
|
|
2139
2443
|
}, [editor]);
|
|
2140
2444
|
return /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
|
|
2141
2445
|
onEntityFetchComplete: onEntityFetchComplete
|
|
@@ -2293,7 +2597,7 @@ function LinkedEntityBlock(props) {
|
|
|
2293
2597
|
var isSelected = useSelected();
|
|
2294
2598
|
var editor = useContentfulEditor();
|
|
2295
2599
|
var sdk = useSdkContext();
|
|
2296
|
-
var isDisabled = useReadOnly();
|
|
2600
|
+
var isDisabled = useReadOnly$1();
|
|
2297
2601
|
var _element$data$target$ = element.data.target.sys,
|
|
2298
2602
|
entityId = _element$data$target$.id,
|
|
2299
2603
|
entityType = _element$data$target$.linkType;
|
|
@@ -2305,8 +2609,8 @@ function LinkedEntityBlock(props) {
|
|
|
2305
2609
|
}, [sdk, entityId, entityType]);
|
|
2306
2610
|
var handleRemoveClick = React__default.useCallback(function () {
|
|
2307
2611
|
if (!editor) return;
|
|
2308
|
-
var pathToElement =
|
|
2309
|
-
|
|
2612
|
+
var pathToElement = findNodePath(editor, element);
|
|
2613
|
+
removeNodes(editor, {
|
|
2310
2614
|
at: pathToElement
|
|
2311
2615
|
});
|
|
2312
2616
|
}, [editor, element]);
|
|
@@ -2416,7 +2720,7 @@ function getEntityTypeFromRichTextNode(nodeType) {
|
|
|
2416
2720
|
|
|
2417
2721
|
function selectEntityAndInsert(_x, _x2, _x3, _x4) {
|
|
2418
2722
|
return _selectEntityAndInsert.apply(this, arguments);
|
|
2419
|
-
}
|
|
2723
|
+
} // TODO: incorporate this logic inside the trailingParagraph plugin instead
|
|
2420
2724
|
|
|
2421
2725
|
function _selectEntityAndInsert() {
|
|
2422
2726
|
_selectEntityAndInsert = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(nodeType, sdk, editor, logAction) {
|
|
@@ -2452,7 +2756,7 @@ function _selectEntityAndInsert() {
|
|
|
2452
2756
|
return _context.abrupt("return");
|
|
2453
2757
|
|
|
2454
2758
|
case 12:
|
|
2455
|
-
|
|
2759
|
+
select(editor, selection);
|
|
2456
2760
|
insertBlock$1(editor, nodeType, entity);
|
|
2457
2761
|
ensureFollowingParagraph(editor);
|
|
2458
2762
|
logAction('insert', {
|
|
@@ -2470,37 +2774,25 @@ function _selectEntityAndInsert() {
|
|
|
2470
2774
|
}
|
|
2471
2775
|
|
|
2472
2776
|
function ensureFollowingParagraph(editor) {
|
|
2473
|
-
|
|
2474
|
-
If the new block isn't followed by a sibling paragraph we insert a new empty one
|
|
2475
|
-
*/
|
|
2476
|
-
var next = Editor.next(editor);
|
|
2477
|
-
|
|
2478
|
-
if (!next) {
|
|
2479
|
-
return insertEmptyParagraph(editor);
|
|
2480
|
-
}
|
|
2777
|
+
var _lastNode$0$type;
|
|
2481
2778
|
|
|
2482
|
-
var
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
return !Element.isElement(e) || ![BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY].includes(e.type);
|
|
2779
|
+
var entityBlock = getAboveNode(editor, {
|
|
2780
|
+
match: {
|
|
2781
|
+
type: [BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY]
|
|
2486
2782
|
}
|
|
2487
2783
|
});
|
|
2488
2784
|
|
|
2489
|
-
if (
|
|
2490
|
-
// at level 0, a following paragraph is handled by the tralingParagraph plugin
|
|
2491
|
-
moveToTheNextChar(editor);
|
|
2785
|
+
if (!entityBlock) {
|
|
2492
2786
|
return;
|
|
2493
2787
|
}
|
|
2494
2788
|
|
|
2495
|
-
var
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
}
|
|
2500
|
-
});
|
|
2789
|
+
var level = entityBlock[1].length - 1;
|
|
2790
|
+
var lastNode = getLastNodeByLevel(editor, level);
|
|
2791
|
+
var isTextContainer = TEXT_CONTAINERS.includes((_lastNode$0$type = lastNode == null ? void 0 : lastNode[0].type) != null ? _lastNode$0$type : ''); // If the new block isn't followed by a sibling text container (e.g. paragraph)
|
|
2792
|
+
// we insert a new empty one. Level 0 is handled by the trailingParagraph plugin
|
|
2501
2793
|
|
|
2502
|
-
if (
|
|
2503
|
-
|
|
2794
|
+
if (level !== 0 && !isTextContainer) {
|
|
2795
|
+
insertEmptyParagraph(editor);
|
|
2504
2796
|
}
|
|
2505
2797
|
|
|
2506
2798
|
moveToTheNextChar(editor);
|
|
@@ -2532,9 +2824,9 @@ function insertBlock$1(editor, nodeType, entity) {
|
|
|
2532
2824
|
var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
|
|
2533
2825
|
|
|
2534
2826
|
if (hasText) {
|
|
2535
|
-
|
|
2827
|
+
insertNodes(editor, linkedEntityBlock);
|
|
2536
2828
|
} else {
|
|
2537
|
-
|
|
2829
|
+
setNodes(editor, linkedEntityBlock);
|
|
2538
2830
|
}
|
|
2539
2831
|
|
|
2540
2832
|
focus(editor);
|
|
@@ -2559,11 +2851,20 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
|
|
|
2559
2851
|
switch (_context.prev = _context.next) {
|
|
2560
2852
|
case 0:
|
|
2561
2853
|
event.preventDefault();
|
|
2854
|
+
|
|
2855
|
+
if (editor) {
|
|
2856
|
+
_context.next = 3;
|
|
2857
|
+
break;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
return _context.abrupt("return");
|
|
2861
|
+
|
|
2862
|
+
case 3:
|
|
2562
2863
|
onClose();
|
|
2563
|
-
_context.next =
|
|
2864
|
+
_context.next = 6;
|
|
2564
2865
|
return selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onToolbarAction);
|
|
2565
2866
|
|
|
2566
|
-
case
|
|
2867
|
+
case 6:
|
|
2567
2868
|
case "end":
|
|
2568
2869
|
return _context.stop();
|
|
2569
2870
|
}
|
|
@@ -2623,7 +2924,7 @@ function getWithEmbeddedEntityEvents(nodeType, sdk) {
|
|
|
2623
2924
|
|
|
2624
2925
|
if (isDelete || isBackspace) {
|
|
2625
2926
|
event.preventDefault();
|
|
2626
|
-
|
|
2927
|
+
removeNodes(editor, {
|
|
2627
2928
|
at: pathToSelectedElement
|
|
2628
2929
|
});
|
|
2629
2930
|
}
|
|
@@ -2822,7 +3123,7 @@ function EmbeddedEntityInline(props) {
|
|
|
2822
3123
|
var sdk = useSdkContext();
|
|
2823
3124
|
var isSelected = useSelected();
|
|
2824
3125
|
var entryId = props.element.data.target.sys.id;
|
|
2825
|
-
var isDisabled = useReadOnly();
|
|
3126
|
+
var isDisabled = useReadOnly$1();
|
|
2826
3127
|
|
|
2827
3128
|
function handleEditClick() {
|
|
2828
3129
|
return sdk.navigator.openEntry(entryId, {
|
|
@@ -2832,8 +3133,8 @@ function EmbeddedEntityInline(props) {
|
|
|
2832
3133
|
|
|
2833
3134
|
function handleRemoveClick() {
|
|
2834
3135
|
if (!editor) return;
|
|
2835
|
-
var pathToElement =
|
|
2836
|
-
|
|
3136
|
+
var pathToElement = findNodePath(editor, props.element);
|
|
3137
|
+
removeNodes(editor, {
|
|
2837
3138
|
at: pathToElement
|
|
2838
3139
|
});
|
|
2839
3140
|
}
|
|
@@ -2902,8 +3203,8 @@ function _selectEntityAndInsert$1() {
|
|
|
2902
3203
|
|
|
2903
3204
|
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
2904
3205
|
setTimeout(function () {
|
|
2905
|
-
|
|
2906
|
-
|
|
3206
|
+
setSelection(editor, selection);
|
|
3207
|
+
insertNodes(editor, inlineEntryNode);
|
|
2907
3208
|
resolve();
|
|
2908
3209
|
}, 0);
|
|
2909
3210
|
}));
|
|
@@ -3114,7 +3415,7 @@ function ToolbarHeadingButton(props) {
|
|
|
3114
3415
|
}
|
|
3115
3416
|
|
|
3116
3417
|
function extractNodes(editor, path, match) {
|
|
3117
|
-
return Array.from(
|
|
3418
|
+
return Array.from(getNodeEntries(editor, {
|
|
3118
3419
|
match: match,
|
|
3119
3420
|
at: path,
|
|
3120
3421
|
mode: 'lowest'
|
|
@@ -3140,7 +3441,7 @@ function extractParagraphs(editor, path) {
|
|
|
3140
3441
|
|
|
3141
3442
|
var transformRemove = function transformRemove(editor, _ref) {
|
|
3142
3443
|
var path = _ref[1];
|
|
3143
|
-
|
|
3444
|
+
removeNodes(editor, {
|
|
3144
3445
|
at: path
|
|
3145
3446
|
});
|
|
3146
3447
|
};
|
|
@@ -3148,20 +3449,20 @@ var transformParagraphs = function transformParagraphs(editor, entry) {
|
|
|
3148
3449
|
var path = entry[1];
|
|
3149
3450
|
var nodes = extractParagraphs(editor, path);
|
|
3150
3451
|
transformRemove(editor, entry);
|
|
3151
|
-
|
|
3452
|
+
insertNodes(editor, nodes, {
|
|
3152
3453
|
at: path
|
|
3153
3454
|
});
|
|
3154
3455
|
};
|
|
3155
3456
|
var transformUnwrap = function transformUnwrap(editor, _ref2) {
|
|
3156
3457
|
var path = _ref2[1];
|
|
3157
|
-
|
|
3458
|
+
unwrapNodes(editor, {
|
|
3158
3459
|
at: path
|
|
3159
3460
|
});
|
|
3160
3461
|
};
|
|
3161
3462
|
var transformWrapIn = function transformWrapIn(type) {
|
|
3162
3463
|
return function (editor, _ref3) {
|
|
3163
3464
|
var path = _ref3[1];
|
|
3164
|
-
|
|
3465
|
+
wrapNodes(editor, {
|
|
3165
3466
|
type: type,
|
|
3166
3467
|
data: {},
|
|
3167
3468
|
children: []
|
|
@@ -3172,7 +3473,7 @@ var transformWrapIn = function transformWrapIn(type) {
|
|
|
3172
3473
|
};
|
|
3173
3474
|
var transformLift = function transformLift(editor, _ref4) {
|
|
3174
3475
|
var path = _ref4[1];
|
|
3175
|
-
|
|
3476
|
+
liftNodes(editor, {
|
|
3176
3477
|
at: path
|
|
3177
3478
|
});
|
|
3178
3479
|
};
|
|
@@ -3251,7 +3552,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
|
|
|
3251
3552
|
// insertBreak implementation
|
|
3252
3553
|
filter: function filter(_ref3) {
|
|
3253
3554
|
var path = _ref3[1];
|
|
3254
|
-
return !
|
|
3555
|
+
return !getAboveNode(editor, {
|
|
3255
3556
|
at: path,
|
|
3256
3557
|
match: {
|
|
3257
3558
|
type: BLOCKS.LIST_ITEM
|
|
@@ -3351,7 +3652,7 @@ function withHrEvents(editor) {
|
|
|
3351
3652
|
|
|
3352
3653
|
if (isBackspace || isDelete) {
|
|
3353
3654
|
event.preventDefault();
|
|
3354
|
-
|
|
3655
|
+
removeNodes(editor, {
|
|
3355
3656
|
at: pathToSelectedHr
|
|
3356
3657
|
});
|
|
3357
3658
|
}
|
|
@@ -3372,7 +3673,7 @@ function ToolbarHrButton(props) {
|
|
|
3372
3673
|
isVoid: true
|
|
3373
3674
|
};
|
|
3374
3675
|
var hasText = !!getText(editor, editor.selection.focus.path);
|
|
3375
|
-
hasText ?
|
|
3676
|
+
hasText ? insertNodes(editor, hr) : setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
|
|
3376
3677
|
|
|
3377
3678
|
moveToTheNextLine(editor);
|
|
3378
3679
|
focus(editor);
|
|
@@ -3658,7 +3959,7 @@ function _addOrEditLink() {
|
|
|
3658
3959
|
while (1) {
|
|
3659
3960
|
switch (_context3.prev = _context3.next) {
|
|
3660
3961
|
case 0:
|
|
3661
|
-
isReadOnly =
|
|
3962
|
+
isReadOnly = isEditorReadOnly(editor);
|
|
3662
3963
|
selectionBeforeBlur = editor.selection ? _extends({}, editor.selection) : undefined;
|
|
3663
3964
|
|
|
3664
3965
|
if (!(!targetPath && !selectionBeforeBlur)) {
|
|
@@ -3673,13 +3974,13 @@ function _addOrEditLink() {
|
|
|
3673
3974
|
|
|
3674
3975
|
if (node && path) {
|
|
3675
3976
|
linkType = node.type;
|
|
3676
|
-
linkText =
|
|
3977
|
+
linkText = getText(editor, path);
|
|
3677
3978
|
linkTarget = node.data.uri || '';
|
|
3678
3979
|
linkEntity = node.data.target;
|
|
3679
3980
|
}
|
|
3680
3981
|
|
|
3681
3982
|
selectionAfterFocus = targetPath != null ? targetPath : selectionBeforeBlur;
|
|
3682
|
-
currentLinkText = linkText || (editor.selection ?
|
|
3983
|
+
currentLinkText = linkText || (editor.selection ? getText(editor, editor.selection) : '');
|
|
3683
3984
|
isEditing = Boolean(node && path);
|
|
3684
3985
|
logAction(isEditing ? 'openEditHyperlinkDialog' : 'openCreateHyperlinkDialog');
|
|
3685
3986
|
_context3.next = 12;
|
|
@@ -3704,7 +4005,7 @@ function _addOrEditLink() {
|
|
|
3704
4005
|
|
|
3705
4006
|
case 12:
|
|
3706
4007
|
data = _context3.sent;
|
|
3707
|
-
|
|
4008
|
+
select(editor, selectionAfterFocus);
|
|
3708
4009
|
|
|
3709
4010
|
if (data) {
|
|
3710
4011
|
_context3.next = 18;
|
|
@@ -3717,7 +4018,7 @@ function _addOrEditLink() {
|
|
|
3717
4018
|
|
|
3718
4019
|
case 18:
|
|
3719
4020
|
text = data.linkText, url = data.linkTarget, type = data.linkType, target = data.linkEntity;
|
|
3720
|
-
|
|
4021
|
+
withoutNormalizing(editor, function () {
|
|
3721
4022
|
insertLink(editor, {
|
|
3722
4023
|
text: text,
|
|
3723
4024
|
url: url,
|
|
@@ -3794,8 +4095,9 @@ function ToolbarHyperlinkButton(props) {
|
|
|
3794
4095
|
}
|
|
3795
4096
|
|
|
3796
4097
|
var hasText = function hasText(editor, entry) {
|
|
3797
|
-
var node = entry[0]
|
|
3798
|
-
|
|
4098
|
+
var node = entry[0],
|
|
4099
|
+
path = entry[1];
|
|
4100
|
+
return !isAncestorEmpty$1(editor, node) && getText(editor, path).trim() !== '';
|
|
3799
4101
|
};
|
|
3800
4102
|
|
|
3801
4103
|
function truncate(str, length) {
|
|
@@ -3986,11 +4288,11 @@ function EntityHyperlink(props) {
|
|
|
3986
4288
|
event.preventDefault();
|
|
3987
4289
|
event.stopPropagation();
|
|
3988
4290
|
if (!editor) return;
|
|
3989
|
-
var p =
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4291
|
+
var p = fromDOMPoint(editor, [event.target, 0]);
|
|
4292
|
+
|
|
4293
|
+
if (p) {
|
|
4294
|
+
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
|
|
4295
|
+
}
|
|
3994
4296
|
}
|
|
3995
4297
|
|
|
3996
4298
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
@@ -4016,11 +4318,11 @@ function UrlHyperlink(props) {
|
|
|
4016
4318
|
event.preventDefault();
|
|
4017
4319
|
event.stopPropagation();
|
|
4018
4320
|
if (!editor) return;
|
|
4019
|
-
var p =
|
|
4321
|
+
var p = fromDOMPoint(editor, [event.target, 0], {
|
|
4020
4322
|
exactMatch: false,
|
|
4021
4323
|
suppressThrow: false
|
|
4022
4324
|
});
|
|
4023
|
-
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
|
|
4325
|
+
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p == null ? void 0 : p.path);
|
|
4024
4326
|
}
|
|
4025
4327
|
|
|
4026
4328
|
return /*#__PURE__*/createElement(Tooltip, {
|
|
@@ -4192,24 +4494,25 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
|
|
|
4192
4494
|
var previousListItemPath;
|
|
4193
4495
|
|
|
4194
4496
|
try {
|
|
4195
|
-
previousListItemPath =
|
|
4497
|
+
previousListItemPath = getPreviousPath(listItemPath);
|
|
4196
4498
|
} catch (e) {
|
|
4197
4499
|
return;
|
|
4198
4500
|
} // Previous sibling is the new parent
|
|
4199
4501
|
|
|
4200
4502
|
|
|
4201
|
-
var previousSiblingItem =
|
|
4503
|
+
var previousSiblingItem = getNodeEntry(editor, previousListItemPath);
|
|
4202
4504
|
|
|
4203
4505
|
if (previousSiblingItem) {
|
|
4204
4506
|
var previousPath = previousSiblingItem[1];
|
|
4205
|
-
var subList = Array.from(
|
|
4206
|
-
var n = _ref2[0]
|
|
4207
|
-
|
|
4507
|
+
var subList = Array.from(getNodeChildren(editor, previousPath)).find(function (_ref2) {
|
|
4508
|
+
var n = _ref2[0],
|
|
4509
|
+
path = _ref2[1];
|
|
4510
|
+
return match(n, path, {
|
|
4208
4511
|
type: getListTypes(editor)
|
|
4209
4512
|
});
|
|
4210
4513
|
});
|
|
4211
|
-
var newPath =
|
|
4212
|
-
|
|
4514
|
+
var newPath = getNextPath(getLastChildPath(subList != null ? subList : previousSiblingItem));
|
|
4515
|
+
withoutNormalizing(editor, function () {
|
|
4213
4516
|
if (!subList) {
|
|
4214
4517
|
// Create new sub-list
|
|
4215
4518
|
wrapNodes(editor, {
|
|
@@ -4222,7 +4525,7 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
|
|
|
4222
4525
|
} // Move the current item to the sub-list
|
|
4223
4526
|
|
|
4224
4527
|
|
|
4225
|
-
|
|
4528
|
+
moveNodes(editor, {
|
|
4226
4529
|
at: listItemPath,
|
|
4227
4530
|
to: newPath
|
|
4228
4531
|
});
|
|
@@ -4243,7 +4546,7 @@ var moveListItems = function moveListItems(editor, _temp) {
|
|
|
4243
4546
|
_ref$at = _ref.at,
|
|
4244
4547
|
at = _ref$at === void 0 ? (_editor$selection = editor.selection) != null ? _editor$selection : undefined : _ref$at;
|
|
4245
4548
|
|
|
4246
|
-
var _nodes =
|
|
4549
|
+
var _nodes = getNodeEntries(editor, {
|
|
4247
4550
|
at: at,
|
|
4248
4551
|
match: {
|
|
4249
4552
|
type: getPluginType(editor, ELEMENT_LIC)
|
|
@@ -4258,19 +4561,19 @@ var moveListItems = function moveListItems(editor, _temp) {
|
|
|
4258
4561
|
|
|
4259
4562
|
lics.forEach(function (lic) {
|
|
4260
4563
|
var licPath = lic[1];
|
|
4261
|
-
var liPath =
|
|
4564
|
+
var liPath = getParentPath(licPath);
|
|
4262
4565
|
var isAncestor = highestLicPaths.some(function (path) {
|
|
4263
|
-
var highestLiPath =
|
|
4264
|
-
return
|
|
4566
|
+
var highestLiPath = getParentPath(path);
|
|
4567
|
+
return isAncestorPath(highestLiPath, liPath);
|
|
4265
4568
|
});
|
|
4266
4569
|
|
|
4267
4570
|
if (!isAncestor) {
|
|
4268
4571
|
highestLicPaths.push(licPath);
|
|
4269
|
-
highestLicPathRefs.push(
|
|
4572
|
+
highestLicPathRefs.push(createPathRef(editor, licPath));
|
|
4270
4573
|
}
|
|
4271
4574
|
});
|
|
4272
4575
|
var licPathRefsToMove = increase ? highestLicPathRefs : highestLicPathRefs.reverse();
|
|
4273
|
-
|
|
4576
|
+
withoutNormalizing(editor, function () {
|
|
4274
4577
|
licPathRefsToMove.forEach(function (licPathRef) {
|
|
4275
4578
|
var licPath = licPathRef.unref();
|
|
4276
4579
|
if (!licPath) return;
|
|
@@ -4291,16 +4594,18 @@ var moveListItems = function moveListItems(editor, _temp) {
|
|
|
4291
4594
|
});
|
|
4292
4595
|
};
|
|
4293
4596
|
|
|
4597
|
+
var ELEMENT_DEFAULT = ELEMENT_DEFAULT$1;
|
|
4598
|
+
|
|
4294
4599
|
/**
|
|
4295
4600
|
* Credit: Modified version of Plate's list plugin
|
|
4296
4601
|
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4297
4602
|
*/
|
|
4298
4603
|
|
|
4299
4604
|
function hasUnliftedListItems(editor, at) {
|
|
4300
|
-
return
|
|
4605
|
+
return getNodeEntries(editor, {
|
|
4301
4606
|
at: at,
|
|
4302
4607
|
match: function match(node, path) {
|
|
4303
|
-
return
|
|
4608
|
+
return isElement(node) && node.type === BLOCKS.LIST_ITEM && path.length >= 2;
|
|
4304
4609
|
}
|
|
4305
4610
|
}).next().done;
|
|
4306
4611
|
}
|
|
@@ -4309,13 +4614,13 @@ var unwrapList = function unwrapList(editor, _temp) {
|
|
|
4309
4614
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
4310
4615
|
at = _ref.at;
|
|
4311
4616
|
|
|
4312
|
-
|
|
4617
|
+
withoutNormalizing(editor, function () {
|
|
4313
4618
|
do {
|
|
4314
4619
|
// lift list items to the root level
|
|
4315
|
-
|
|
4620
|
+
liftNodes(editor, {
|
|
4316
4621
|
at: at,
|
|
4317
4622
|
match: function match(node) {
|
|
4318
|
-
return
|
|
4623
|
+
return isElement(node) && node.type === BLOCKS.LIST_ITEM;
|
|
4319
4624
|
},
|
|
4320
4625
|
mode: 'lowest'
|
|
4321
4626
|
});
|
|
@@ -4335,12 +4640,12 @@ var unwrapList = function unwrapList(editor, _temp) {
|
|
|
4335
4640
|
var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
|
|
4336
4641
|
var toggleList = function toggleList(editor, _ref) {
|
|
4337
4642
|
var type = _ref.type;
|
|
4338
|
-
return
|
|
4643
|
+
return withoutNormalizing(editor, function () {
|
|
4339
4644
|
if (!editor.selection) {
|
|
4340
4645
|
return;
|
|
4341
4646
|
}
|
|
4342
4647
|
|
|
4343
|
-
if (
|
|
4648
|
+
if (isRangeCollapsed(editor.selection) || !isRangeAcrossBlocks(editor)) {
|
|
4344
4649
|
// selection is collapsed
|
|
4345
4650
|
var res = getListItemEntry(editor);
|
|
4346
4651
|
|
|
@@ -4367,7 +4672,7 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
4367
4672
|
data: {}
|
|
4368
4673
|
};
|
|
4369
4674
|
wrapNodes(editor, _list);
|
|
4370
|
-
var nodes = [].concat(
|
|
4675
|
+
var nodes = [].concat(getNodeEntries(editor, {
|
|
4371
4676
|
match: {
|
|
4372
4677
|
type: getPluginType(editor, ELEMENT_DEFAULT)
|
|
4373
4678
|
}
|
|
@@ -4388,29 +4693,31 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
4388
4693
|
}
|
|
4389
4694
|
} else {
|
|
4390
4695
|
// selection is a range
|
|
4391
|
-
var
|
|
4392
|
-
startPoint =
|
|
4393
|
-
endPoint =
|
|
4696
|
+
var _getRangeEdges = getRangeEdges(editor.selection),
|
|
4697
|
+
startPoint = _getRangeEdges[0],
|
|
4698
|
+
endPoint = _getRangeEdges[1];
|
|
4394
4699
|
|
|
4395
|
-
var commonEntry =
|
|
4700
|
+
var commonEntry = getCommonNode(editor, startPoint.path, endPoint.path);
|
|
4396
4701
|
|
|
4397
4702
|
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4398
4703
|
var listType = commonEntry[0].type;
|
|
4399
4704
|
|
|
4400
4705
|
if (commonEntry[0].type === BLOCKS.LIST_ITEM) {
|
|
4401
|
-
|
|
4706
|
+
var _getParentNode, _getParentNode$;
|
|
4707
|
+
|
|
4708
|
+
listType = (_getParentNode = getParentNode(editor, commonEntry[1])) == null ? void 0 : (_getParentNode$ = _getParentNode[0]) == null ? void 0 : _getParentNode$.type;
|
|
4402
4709
|
}
|
|
4403
4710
|
|
|
4404
4711
|
if (listType !== type) {
|
|
4405
4712
|
var startList = findNode(editor, {
|
|
4406
|
-
at:
|
|
4713
|
+
at: getRangeStart(editor.selection),
|
|
4407
4714
|
match: {
|
|
4408
4715
|
type: listTypes
|
|
4409
4716
|
},
|
|
4410
4717
|
mode: 'lowest'
|
|
4411
4718
|
});
|
|
4412
4719
|
var endList = findNode(editor, {
|
|
4413
|
-
at:
|
|
4720
|
+
at: getRangeEnd(editor.selection),
|
|
4414
4721
|
match: {
|
|
4415
4722
|
type: listTypes
|
|
4416
4723
|
},
|
|
@@ -4437,7 +4744,7 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
4437
4744
|
} else {
|
|
4438
4745
|
var rootPathLength = commonEntry[1].length;
|
|
4439
4746
|
|
|
4440
|
-
var _nodes = Array.from(
|
|
4747
|
+
var _nodes = Array.from(getNodeEntries(editor, {
|
|
4441
4748
|
mode: 'all'
|
|
4442
4749
|
})).filter(function (_ref2) {
|
|
4443
4750
|
var path = _ref2[1];
|
|
@@ -4485,7 +4792,7 @@ var onKeyDownList = function onKeyDownList(editor, _ref) {
|
|
|
4485
4792
|
hotkey = _ref.options.hotkey;
|
|
4486
4793
|
return function (e) {
|
|
4487
4794
|
if (e.key === 'Tab' && editor.selection) {
|
|
4488
|
-
var listSelected =
|
|
4795
|
+
var listSelected = getAboveNode(editor, {
|
|
4489
4796
|
at: editor.selection,
|
|
4490
4797
|
match: {
|
|
4491
4798
|
type: type
|
|
@@ -4523,14 +4830,14 @@ var isList = function isList(node) {
|
|
|
4523
4830
|
var hasListAsDirectParent = function hasListAsDirectParent(editor, _ref) {
|
|
4524
4831
|
var path = _ref[1];
|
|
4525
4832
|
|
|
4526
|
-
var _ref2 =
|
|
4833
|
+
var _ref2 = getParentNode$1(editor, path) || [],
|
|
4527
4834
|
parentNode = _ref2[0];
|
|
4528
4835
|
|
|
4529
4836
|
return isList(parentNode);
|
|
4530
4837
|
};
|
|
4531
4838
|
|
|
4532
4839
|
var getNearestListAncestor = function getNearestListAncestor(editor, path) {
|
|
4533
|
-
return
|
|
4840
|
+
return getAboveNode$1(editor, {
|
|
4534
4841
|
at: path,
|
|
4535
4842
|
mode: 'lowest',
|
|
4536
4843
|
match: isList
|
|
@@ -4550,7 +4857,7 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
|
|
|
4550
4857
|
parentList = _getNearestListAncest[0];
|
|
4551
4858
|
|
|
4552
4859
|
var parentListType = parentList == null ? void 0 : parentList.type;
|
|
4553
|
-
|
|
4860
|
+
wrapNodes(editor, {
|
|
4554
4861
|
type: parentListType || BLOCKS.UL_LIST,
|
|
4555
4862
|
children: [],
|
|
4556
4863
|
data: {}
|
|
@@ -4558,24 +4865,23 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
|
|
|
4558
4865
|
at: path
|
|
4559
4866
|
});
|
|
4560
4867
|
};
|
|
4561
|
-
var isNonEmptyListItem = function isNonEmptyListItem(
|
|
4562
|
-
var
|
|
4563
|
-
var listItemChildren = Array.from(Node.children(editor, path));
|
|
4868
|
+
var isNonEmptyListItem = function isNonEmptyListItem(_, entry) {
|
|
4869
|
+
var listItemChildren = getChildren(entry);
|
|
4564
4870
|
return listItemChildren.length !== 0;
|
|
4565
4871
|
};
|
|
4566
|
-
var firstNodeIsNotList = function firstNodeIsNotList(_editor,
|
|
4567
|
-
var node =
|
|
4872
|
+
var firstNodeIsNotList = function firstNodeIsNotList(_editor, _ref4) {
|
|
4873
|
+
var node = _ref4[0];
|
|
4568
4874
|
|
|
4569
4875
|
if (node.children.length === 1) {
|
|
4570
4876
|
var firstNode = node.children[0];
|
|
4571
|
-
return !
|
|
4877
|
+
return !isText(firstNode) && !isList(firstNode);
|
|
4572
4878
|
}
|
|
4573
4879
|
|
|
4574
4880
|
return true;
|
|
4575
4881
|
};
|
|
4576
|
-
var insertParagraphAsChild = function insertParagraphAsChild(editor,
|
|
4577
|
-
var path =
|
|
4578
|
-
|
|
4882
|
+
var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref5) {
|
|
4883
|
+
var path = _ref5[1];
|
|
4884
|
+
insertNodes(editor, [{
|
|
4579
4885
|
type: BLOCKS.PARAGRAPH,
|
|
4580
4886
|
data: {},
|
|
4581
4887
|
children: [{
|
|
@@ -4588,10 +4894,10 @@ var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref6) {
|
|
|
4588
4894
|
var replaceNodeWithListItems = function replaceNodeWithListItems(editor, entry) {
|
|
4589
4895
|
var node = entry[0],
|
|
4590
4896
|
path = entry[1];
|
|
4591
|
-
|
|
4897
|
+
removeNodes(editor, {
|
|
4592
4898
|
at: path
|
|
4593
4899
|
});
|
|
4594
|
-
|
|
4900
|
+
insertNodes(editor, node.children[0].children, {
|
|
4595
4901
|
at: path
|
|
4596
4902
|
});
|
|
4597
4903
|
};
|
|
@@ -4602,12 +4908,12 @@ var isListTypeActive = function isListTypeActive(editor, type) {
|
|
|
4602
4908
|
return false;
|
|
4603
4909
|
}
|
|
4604
4910
|
|
|
4605
|
-
if (
|
|
4606
|
-
var
|
|
4607
|
-
start =
|
|
4608
|
-
end =
|
|
4911
|
+
if (isRangeExpanded(selection)) {
|
|
4912
|
+
var _getRangeEdges = getRangeEdges(selection),
|
|
4913
|
+
start = _getRangeEdges[0],
|
|
4914
|
+
end = _getRangeEdges[1];
|
|
4609
4915
|
|
|
4610
|
-
var node =
|
|
4916
|
+
var node = getCommonNode(editor, start.path, end.path);
|
|
4611
4917
|
|
|
4612
4918
|
if (node[0].type === type) {
|
|
4613
4919
|
return true;
|
|
@@ -4615,7 +4921,7 @@ var isListTypeActive = function isListTypeActive(editor, type) {
|
|
|
4615
4921
|
} // Lists can be nested. Here, we take the list type at the lowest level
|
|
4616
4922
|
|
|
4617
4923
|
|
|
4618
|
-
var listNode = getBlockAbove(editor, {
|
|
4924
|
+
var listNode = getBlockAbove$1(editor, {
|
|
4619
4925
|
match: {
|
|
4620
4926
|
type: [BLOCKS.OL_LIST, BLOCKS.UL_LIST]
|
|
4621
4927
|
},
|
|
@@ -4636,7 +4942,7 @@ var emptyListItemNode = function emptyListItemNode(editor, withChildren) {
|
|
|
4636
4942
|
var children = [];
|
|
4637
4943
|
|
|
4638
4944
|
if (withChildren) {
|
|
4639
|
-
var marks =
|
|
4945
|
+
var marks = getMarks(editor) || {};
|
|
4640
4946
|
children = [{
|
|
4641
4947
|
type: BLOCKS.PARAGRAPH,
|
|
4642
4948
|
data: {},
|
|
@@ -4663,7 +4969,7 @@ var insertListItem = function insertListItem(editor) {
|
|
|
4663
4969
|
} // Naming it paragraph for simplicity but can be a heading as well
|
|
4664
4970
|
|
|
4665
4971
|
|
|
4666
|
-
var paragraph =
|
|
4972
|
+
var paragraph = getAboveNode(editor, {
|
|
4667
4973
|
match: {
|
|
4668
4974
|
type: TEXT_CONTAINERS
|
|
4669
4975
|
}
|
|
@@ -4674,7 +4980,7 @@ var insertListItem = function insertListItem(editor) {
|
|
|
4674
4980
|
}
|
|
4675
4981
|
|
|
4676
4982
|
var paragraphPath = paragraph[1];
|
|
4677
|
-
var listItem =
|
|
4983
|
+
var listItem = getParentNode(editor, paragraphPath);
|
|
4678
4984
|
|
|
4679
4985
|
if (!listItem) {
|
|
4680
4986
|
return false;
|
|
@@ -4688,7 +4994,7 @@ var insertListItem = function insertListItem(editor) {
|
|
|
4688
4994
|
} // We are in a li>p (or heading)
|
|
4689
4995
|
|
|
4690
4996
|
|
|
4691
|
-
|
|
4997
|
+
withoutNormalizing(editor, function () {
|
|
4692
4998
|
if (!editor.selection) {
|
|
4693
4999
|
return;
|
|
4694
5000
|
} // Check the cursor position in the current paragraph
|
|
@@ -4696,22 +5002,22 @@ var insertListItem = function insertListItem(editor) {
|
|
|
4696
5002
|
|
|
4697
5003
|
var isAtStart = isSelectionAtBlockStart(editor);
|
|
4698
5004
|
var isAtEnd = isSelectionAtBlockEnd(editor);
|
|
4699
|
-
var isAtStartOfListItem = isAtStart &&
|
|
5005
|
+
var isAtStartOfListItem = isAtStart && isFirstChildPath(paragraphPath);
|
|
4700
5006
|
var shouldSplit = !isAtStart && !isAtEnd; // Split the current paragraph content if necessary
|
|
4701
5007
|
|
|
4702
5008
|
if (shouldSplit) {
|
|
4703
|
-
|
|
5009
|
+
splitNodes(editor);
|
|
4704
5010
|
} // Insert the new li
|
|
4705
5011
|
|
|
4706
5012
|
|
|
4707
|
-
var newListItemPath = isAtStartOfListItem ? listItemPath :
|
|
5013
|
+
var newListItemPath = isAtStartOfListItem ? listItemPath : getNextPath(listItemPath);
|
|
4708
5014
|
insertNodes(editor, // Add an empty paragraph to the new li if We will not move some
|
|
4709
5015
|
// paragraphs over there.
|
|
4710
5016
|
emptyListItemNode(editor, !shouldSplit), {
|
|
4711
5017
|
at: newListItemPath
|
|
4712
5018
|
}); // Move children *after* selection to the new li
|
|
4713
5019
|
|
|
4714
|
-
var fromPath = isAtStart ? paragraphPath :
|
|
5020
|
+
var fromPath = isAtStart ? paragraphPath : getNextPath(paragraphPath);
|
|
4715
5021
|
var fromStartIndex = fromPath[fromPath.length - 1] || 0; // On split we don't add paragraph to the new li so we move
|
|
4716
5022
|
// content to the very beginning. Otherwise, account for the empty
|
|
4717
5023
|
// paragraph at the beginning by moving the content after
|
|
@@ -4727,8 +5033,8 @@ var insertListItem = function insertListItem(editor) {
|
|
|
4727
5033
|
} // Move cursor to the start of the new li
|
|
4728
5034
|
|
|
4729
5035
|
|
|
4730
|
-
|
|
4731
|
-
|
|
5036
|
+
select(editor, newListItemPath);
|
|
5037
|
+
collapseSelection(editor, {
|
|
4732
5038
|
edge: 'start'
|
|
4733
5039
|
});
|
|
4734
5040
|
}); // Returning True skips processing other editor.insertBreak handlers
|
|
@@ -4762,11 +5068,11 @@ var listBreak = function listBreak(editor) {
|
|
|
4762
5068
|
}
|
|
4763
5069
|
}
|
|
4764
5070
|
|
|
4765
|
-
var didReset = onKeyDownResetNode(editor, mockPlugin({
|
|
5071
|
+
var didReset = onKeyDownResetNode(editor, mockPlugin$1({
|
|
4766
5072
|
options: {
|
|
4767
5073
|
rules: [{
|
|
4768
|
-
types: [getPluginType(editor, ELEMENT_LI)],
|
|
4769
|
-
defaultType: getPluginType(editor, ELEMENT_DEFAULT),
|
|
5074
|
+
types: [getPluginType$1(editor, ELEMENT_LI)],
|
|
5075
|
+
defaultType: getPluginType$1(editor, ELEMENT_DEFAULT$1),
|
|
4770
5076
|
predicate: function predicate() {
|
|
4771
5077
|
return !moved && isBlockAboveEmpty(editor);
|
|
4772
5078
|
},
|
|
@@ -4807,13 +5113,13 @@ var insertListBreak = function insertListBreak(editor) {
|
|
|
4807
5113
|
*/
|
|
4808
5114
|
|
|
4809
5115
|
var getFirstAncestorOfType = function getFirstAncestorOfType(root, entry) {
|
|
4810
|
-
var ancestor =
|
|
5116
|
+
var ancestor = getParentPath(entry[1]);
|
|
4811
5117
|
|
|
4812
|
-
while (
|
|
4813
|
-
ancestor =
|
|
5118
|
+
while (getDescendantNodeByPath(root, ancestor).type !== BLOCKS.LIST_ITEM) {
|
|
5119
|
+
ancestor = getParentPath(ancestor);
|
|
4814
5120
|
}
|
|
4815
5121
|
|
|
4816
|
-
return [
|
|
5122
|
+
return [getDescendantNodeByPath(root, ancestor), ancestor];
|
|
4817
5123
|
};
|
|
4818
5124
|
|
|
4819
5125
|
var isListRoot = function isListRoot(node) {
|
|
@@ -4831,9 +5137,9 @@ var trimList = function trimList(listRoot) {
|
|
|
4831
5137
|
return [listRoot];
|
|
4832
5138
|
}
|
|
4833
5139
|
|
|
4834
|
-
var textEntries = Array.from(
|
|
5140
|
+
var textEntries = Array.from(getNodeTexts(listRoot));
|
|
4835
5141
|
var commonAncestorEntry = textEntries.reduce(function (commonAncestor, textEntry) {
|
|
4836
|
-
return
|
|
5142
|
+
return isAncestorPath(commonAncestor[1], textEntry[1]) ? commonAncestor : getCommonNode(listRoot, textEntry[1], commonAncestor[1]);
|
|
4837
5143
|
}, // any list item would do, we grab the first one
|
|
4838
5144
|
getFirstAncestorOfType(listRoot, textEntries[0]));
|
|
4839
5145
|
return isListRoot(commonAncestorEntry[0]) ? commonAncestorEntry[0].children : [commonAncestorEntry[0]];
|
|
@@ -4874,7 +5180,7 @@ var insertListFragment = function insertListFragment(editor) {
|
|
|
4874
5180
|
return;
|
|
4875
5181
|
}
|
|
4876
5182
|
|
|
4877
|
-
var liEntry = findNode(editor, {
|
|
5183
|
+
var liEntry = findNode$1(editor, {
|
|
4878
5184
|
match: {
|
|
4879
5185
|
type: BLOCKS.LIST_ITEM
|
|
4880
5186
|
},
|
|
@@ -4886,7 +5192,7 @@ var insertListFragment = function insertListFragment(editor) {
|
|
|
4886
5192
|
return trimList(node);
|
|
4887
5193
|
})));
|
|
4888
5194
|
var firstBlockIndex = nodes.findIndex(function (node) {
|
|
4889
|
-
return
|
|
5195
|
+
return isBlockNode(editor, node);
|
|
4890
5196
|
});
|
|
4891
5197
|
|
|
4892
5198
|
if (firstBlockIndex < 0) {
|
|
@@ -4898,11 +5204,11 @@ var insertListFragment = function insertListFragment(editor) {
|
|
|
4898
5204
|
// after a text or inline element occurrence will be unwrapped for
|
|
4899
5205
|
// some reason.
|
|
4900
5206
|
|
|
4901
|
-
|
|
5207
|
+
insertNodes(editor, inlines, {
|
|
4902
5208
|
at: editor.selection,
|
|
4903
5209
|
select: true
|
|
4904
5210
|
});
|
|
4905
|
-
return
|
|
5211
|
+
return insertNodes(editor, blocks, {
|
|
4906
5212
|
at: editor.selection,
|
|
4907
5213
|
select: true
|
|
4908
5214
|
});
|
|
@@ -4932,7 +5238,7 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
|
|
|
4932
5238
|
return node.type === BLOCKS.LIST_ITEM;
|
|
4933
5239
|
}
|
|
4934
5240
|
})) {
|
|
4935
|
-
|
|
5241
|
+
withoutNormalizing(editor, function () {
|
|
4936
5242
|
moved = removeFirstListItem(editor, {
|
|
4937
5243
|
list: list,
|
|
4938
5244
|
listItem: listItem
|
|
@@ -4945,7 +5251,9 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
|
|
|
4945
5251
|
if (moved) return;
|
|
4946
5252
|
|
|
4947
5253
|
if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
|
|
4948
|
-
onKeyDownResetNode(editor,
|
|
5254
|
+
onKeyDownResetNode(editor, // TODO look into this
|
|
5255
|
+
// @ts-expect-error
|
|
5256
|
+
mockPlugin({
|
|
4949
5257
|
options: {
|
|
4950
5258
|
rules: [{
|
|
4951
5259
|
types: [BLOCKS.LIST_ITEM],
|
|
@@ -4965,6 +5273,8 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
|
|
|
4965
5273
|
}
|
|
4966
5274
|
|
|
4967
5275
|
deleteFragment(editor, {
|
|
5276
|
+
// FIXME: see if we can remove unit
|
|
5277
|
+
// @ts-expect-error
|
|
4968
5278
|
unit: unit,
|
|
4969
5279
|
reverse: true
|
|
4970
5280
|
});
|
|
@@ -5002,7 +5312,7 @@ var withList = function withList(editor) {
|
|
|
5002
5312
|
};
|
|
5003
5313
|
|
|
5004
5314
|
editor.insertBreak = insertListBreak(editor);
|
|
5005
|
-
editor.insertFragment = insertListFragment(editor); // TODO: replace with Normalizer rules
|
|
5315
|
+
editor.insertFragment = insertListFragment(editor); // TODO: replace with our own Normalizer rules
|
|
5006
5316
|
|
|
5007
5317
|
editor.normalizeNode = normalizeList(editor, {
|
|
5008
5318
|
validLiChildrenTypes: validLiChildrenTypes
|
|
@@ -5234,7 +5544,13 @@ var createCodePlugin = function createCodePlugin() {
|
|
|
5234
5544
|
type: MARKS.CODE,
|
|
5235
5545
|
component: Code,
|
|
5236
5546
|
options: {
|
|
5237
|
-
|
|
5547
|
+
// We need to define multiple hotkeys here,
|
|
5548
|
+
// - mod+/ -> QWERTY keyboard layout
|
|
5549
|
+
// - mod+shift+7 -> QWERTZ keyboard layout
|
|
5550
|
+
// The workaround like in packages/rich-text/src/plugins/CommandPalette/onKeyDown.ts is sadly not working here,
|
|
5551
|
+
// as `shift+7` is not interpreted as `/` with the `mod` key by the OS.
|
|
5552
|
+
// TODO: there are a lot more different keyboard layouts out there
|
|
5553
|
+
hotkey: ['mod+/', 'mod+shift+7']
|
|
5238
5554
|
},
|
|
5239
5555
|
handlers: {
|
|
5240
5556
|
onKeyDown: buildMarkEventHandler(MARKS.CODE)
|
|
@@ -5293,42 +5609,44 @@ var createItalicPlugin = function createItalicPlugin() {
|
|
|
5293
5609
|
});
|
|
5294
5610
|
};
|
|
5295
5611
|
|
|
5296
|
-
var
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5612
|
+
var styles$g = {
|
|
5613
|
+
subscript: /*#__PURE__*/css({
|
|
5614
|
+
verticalAlign: 'sub',
|
|
5615
|
+
fontSize: 'smaller'
|
|
5616
|
+
})
|
|
5617
|
+
};
|
|
5618
|
+
var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5619
|
+
title: 'Subscript',
|
|
5620
|
+
mark: MARKS.SUBSCRIPT,
|
|
5621
|
+
icon: /*#__PURE__*/createElement(SubscriptIcon, {
|
|
5622
|
+
viewBox: "0 0 23 18"
|
|
5623
|
+
})
|
|
5300
5624
|
});
|
|
5301
|
-
|
|
5302
|
-
|
|
5625
|
+
var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5626
|
+
title: 'Subscript',
|
|
5627
|
+
mark: MARKS.SUBSCRIPT
|
|
5628
|
+
});
|
|
5629
|
+
function Subscript(props) {
|
|
5630
|
+
return /*#__PURE__*/createElement("sub", _extends({}, props.attributes, {
|
|
5631
|
+
className: styles$g.subscript
|
|
5632
|
+
}), props.children);
|
|
5303
5633
|
}
|
|
5304
|
-
var
|
|
5305
|
-
return
|
|
5306
|
-
type: MARKS.
|
|
5307
|
-
component:
|
|
5308
|
-
options: {
|
|
5309
|
-
hotkey: ['mod+u']
|
|
5310
|
-
},
|
|
5634
|
+
var createSubscriptPlugin = function createSubscriptPlugin() {
|
|
5635
|
+
return createSubscriptPlugin$1({
|
|
5636
|
+
type: MARKS.SUBSCRIPT,
|
|
5637
|
+
component: Subscript,
|
|
5311
5638
|
handlers: {
|
|
5312
|
-
onKeyDown: buildMarkEventHandler(MARKS.
|
|
5639
|
+
onKeyDown: buildMarkEventHandler(MARKS.SUBSCRIPT)
|
|
5313
5640
|
},
|
|
5314
5641
|
deserializeHtml: {
|
|
5315
5642
|
rules: [{
|
|
5316
|
-
validNodeName: ['
|
|
5317
|
-
}
|
|
5318
|
-
validStyle: {
|
|
5319
|
-
textDecoration: ['underline']
|
|
5320
|
-
}
|
|
5321
|
-
}],
|
|
5322
|
-
query: function query(el) {
|
|
5323
|
-
return !someHtmlElement(el, function (node) {
|
|
5324
|
-
return node.style.textDecoration === 'none';
|
|
5325
|
-
});
|
|
5326
|
-
}
|
|
5643
|
+
validNodeName: ['SUB']
|
|
5644
|
+
}]
|
|
5327
5645
|
}
|
|
5328
5646
|
});
|
|
5329
5647
|
};
|
|
5330
5648
|
|
|
5331
|
-
var styles$
|
|
5649
|
+
var styles$h = {
|
|
5332
5650
|
superscript: /*#__PURE__*/css({
|
|
5333
5651
|
verticalAlign: 'super',
|
|
5334
5652
|
fontSize: 'smaller'
|
|
@@ -5345,7 +5663,7 @@ var ToolbarDropdownSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5345
5663
|
});
|
|
5346
5664
|
function Superscript(props) {
|
|
5347
5665
|
return /*#__PURE__*/createElement("sup", _extends({}, props.attributes, {
|
|
5348
|
-
className: styles$
|
|
5666
|
+
className: styles$h.superscript
|
|
5349
5667
|
}), props.children);
|
|
5350
5668
|
}
|
|
5351
5669
|
var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
@@ -5363,39 +5681,37 @@ var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
|
5363
5681
|
});
|
|
5364
5682
|
};
|
|
5365
5683
|
|
|
5366
|
-
var
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
})
|
|
5371
|
-
};
|
|
5372
|
-
var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5373
|
-
title: 'Subscript',
|
|
5374
|
-
mark: MARKS.SUBSCRIPT,
|
|
5375
|
-
icon: /*#__PURE__*/createElement(SubscriptIcon, {
|
|
5376
|
-
viewBox: "0 0 23 18"
|
|
5377
|
-
})
|
|
5378
|
-
});
|
|
5379
|
-
var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5380
|
-
title: 'Subscript',
|
|
5381
|
-
mark: MARKS.SUBSCRIPT
|
|
5684
|
+
var ToolbarUnderlineButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5685
|
+
title: 'Underline',
|
|
5686
|
+
mark: MARKS.UNDERLINE,
|
|
5687
|
+
icon: /*#__PURE__*/createElement(FormatUnderlinedIcon, null)
|
|
5382
5688
|
});
|
|
5383
|
-
function
|
|
5384
|
-
return /*#__PURE__*/createElement("
|
|
5385
|
-
className: styles$h.subscript
|
|
5386
|
-
}), props.children);
|
|
5689
|
+
function Underline(props) {
|
|
5690
|
+
return /*#__PURE__*/createElement("u", _extends({}, props.attributes), props.children);
|
|
5387
5691
|
}
|
|
5388
|
-
var
|
|
5389
|
-
return
|
|
5390
|
-
type: MARKS.
|
|
5391
|
-
component:
|
|
5692
|
+
var createUnderlinePlugin = function createUnderlinePlugin() {
|
|
5693
|
+
return createUnderlinePlugin$1({
|
|
5694
|
+
type: MARKS.UNDERLINE,
|
|
5695
|
+
component: Underline,
|
|
5696
|
+
options: {
|
|
5697
|
+
hotkey: ['mod+u']
|
|
5698
|
+
},
|
|
5392
5699
|
handlers: {
|
|
5393
|
-
onKeyDown: buildMarkEventHandler(MARKS.
|
|
5700
|
+
onKeyDown: buildMarkEventHandler(MARKS.UNDERLINE)
|
|
5394
5701
|
},
|
|
5395
5702
|
deserializeHtml: {
|
|
5396
5703
|
rules: [{
|
|
5397
|
-
validNodeName: ['
|
|
5398
|
-
}
|
|
5704
|
+
validNodeName: ['U']
|
|
5705
|
+
}, {
|
|
5706
|
+
validStyle: {
|
|
5707
|
+
textDecoration: ['underline']
|
|
5708
|
+
}
|
|
5709
|
+
}],
|
|
5710
|
+
query: function query(el) {
|
|
5711
|
+
return !someHtmlElement(el, function (node) {
|
|
5712
|
+
return node.style.textDecoration === 'none';
|
|
5713
|
+
});
|
|
5714
|
+
}
|
|
5399
5715
|
}
|
|
5400
5716
|
});
|
|
5401
5717
|
};
|
|
@@ -5407,7 +5723,7 @@ var createMarksPlugin = function createMarksPlugin() {
|
|
|
5407
5723
|
};
|
|
5408
5724
|
};
|
|
5409
5725
|
|
|
5410
|
-
var isInline = function isInline(node) {
|
|
5726
|
+
var isInline$1 = function isInline(node) {
|
|
5411
5727
|
return INLINE_TYPES.includes(node.type);
|
|
5412
5728
|
};
|
|
5413
5729
|
|
|
@@ -5419,13 +5735,13 @@ var isTextContainer = function isTextContainer(node) {
|
|
|
5419
5735
|
|
|
5420
5736
|
var baseRules = [{
|
|
5421
5737
|
// Wrap orphaned text nodes in a paragraph
|
|
5422
|
-
match:
|
|
5738
|
+
match: isText,
|
|
5423
5739
|
validNode: function validNode(editor, _ref) {
|
|
5424
|
-
var
|
|
5740
|
+
var _getParentNode;
|
|
5425
5741
|
|
|
5426
5742
|
var path = _ref[1];
|
|
5427
|
-
var parent = (
|
|
5428
|
-
return !!parent && (isTextContainer(parent) || isInline(parent) || editor.isVoid(parent));
|
|
5743
|
+
var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
|
|
5744
|
+
return !!parent && (isTextContainer(parent) || isInline$1(parent) || editor.isVoid(parent));
|
|
5429
5745
|
},
|
|
5430
5746
|
transform: function transform(editor, entry) {
|
|
5431
5747
|
return transformWrapIn(BLOCKS.PARAGRAPH)(editor, entry);
|
|
@@ -5436,10 +5752,10 @@ var baseRules = [{
|
|
|
5436
5752
|
type: INLINE_TYPES
|
|
5437
5753
|
},
|
|
5438
5754
|
validNode: function validNode(editor, _ref2) {
|
|
5439
|
-
var
|
|
5755
|
+
var _getParentNode2;
|
|
5440
5756
|
|
|
5441
5757
|
var path = _ref2[1];
|
|
5442
|
-
var parent = (
|
|
5758
|
+
var parent = (_getParentNode2 = getParentNode(editor, path)) == null ? void 0 : _getParentNode2[0];
|
|
5443
5759
|
return !!parent && isTextContainer(parent);
|
|
5444
5760
|
},
|
|
5445
5761
|
transform: /*#__PURE__*/transformWrapIn(BLOCKS.PARAGRAPH)
|
|
@@ -5457,19 +5773,9 @@ var NormalizerError = /*#__PURE__*/function (_Error) {
|
|
|
5457
5773
|
var createValidatorFromTypes = function createValidatorFromTypes(types) {
|
|
5458
5774
|
return function (_, _ref) {
|
|
5459
5775
|
var node = _ref[0];
|
|
5460
|
-
return
|
|
5776
|
+
return isElement(node) && types.includes(node.type);
|
|
5461
5777
|
};
|
|
5462
5778
|
};
|
|
5463
|
-
var getChildren = function getChildren(editor, _ref2) {
|
|
5464
|
-
var node = _ref2[0],
|
|
5465
|
-
path = _ref2[1];
|
|
5466
|
-
|
|
5467
|
-
if (Text.isText(node)) {
|
|
5468
|
-
return [];
|
|
5469
|
-
}
|
|
5470
|
-
|
|
5471
|
-
return Array.from(Node.children(editor, path));
|
|
5472
|
-
};
|
|
5473
5779
|
var createTransformerFromObject = function createTransformerFromObject(transforms) {
|
|
5474
5780
|
// A default transformer must always be provided
|
|
5475
5781
|
var fallback = transforms['default'];
|
|
@@ -5480,7 +5786,7 @@ var createTransformerFromObject = function createTransformerFromObject(transform
|
|
|
5480
5786
|
|
|
5481
5787
|
return function (editor, entry) {
|
|
5482
5788
|
var node = entry[0];
|
|
5483
|
-
var key =
|
|
5789
|
+
var key = isElement(node) ? node.type : 'default';
|
|
5484
5790
|
var transformer = transforms[key] || fallback;
|
|
5485
5791
|
return transformer(editor, entry);
|
|
5486
5792
|
};
|
|
@@ -5510,7 +5816,7 @@ var withNormalizer = function withNormalizer(editor) {
|
|
|
5510
5816
|
|
|
5511
5817
|
if (!rule.match) {
|
|
5512
5818
|
rule.match = {
|
|
5513
|
-
type: getPluginType(editor, p.key)
|
|
5819
|
+
type: getPluginType$1(editor, p.key)
|
|
5514
5820
|
};
|
|
5515
5821
|
} // Conditional transformation e.g.
|
|
5516
5822
|
// {
|
|
@@ -5548,22 +5854,23 @@ var withNormalizer = function withNormalizer(editor) {
|
|
|
5548
5854
|
|
|
5549
5855
|
|
|
5550
5856
|
var _transform = function _transform(tr, entry) {
|
|
5551
|
-
|
|
5857
|
+
withoutNormalizing(editor, function () {
|
|
5552
5858
|
tr(editor, entry);
|
|
5553
5859
|
});
|
|
5554
5860
|
};
|
|
5555
5861
|
|
|
5556
|
-
var normalizeNode = editor.normalizeNode;
|
|
5862
|
+
var normalizeNode = editor.normalizeNode; // @ts-expect-error
|
|
5557
5863
|
|
|
5558
5864
|
editor.normalizeNode = function (entry) {
|
|
5559
|
-
var node = entry[0]
|
|
5560
|
-
|
|
5865
|
+
var node = entry[0],
|
|
5866
|
+
path = entry[1];
|
|
5867
|
+
var children = getChildren(entry); // The order of validNode rules Vs validChildren doesn't matter. Slate
|
|
5561
5868
|
// will always perform normalization in a depth-first fashion.
|
|
5562
5869
|
|
|
5563
5870
|
for (var _iterator2 = _createForOfIteratorHelperLoose(rules), _step2; !(_step2 = _iterator2()).done;) {
|
|
5564
5871
|
var rule = _step2.value;
|
|
5565
5872
|
|
|
5566
|
-
if (!
|
|
5873
|
+
if (!matchNode(node, path, rule.match)) {
|
|
5567
5874
|
continue;
|
|
5568
5875
|
} // Normalize node
|
|
5569
5876
|
|
|
@@ -5605,7 +5912,6 @@ var withNormalizer = function withNormalizer(editor) {
|
|
|
5605
5912
|
var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
5606
5913
|
return {
|
|
5607
5914
|
key: 'NormalizerPlugin',
|
|
5608
|
-
// @ts-expect-error
|
|
5609
5915
|
withOverrides: withNormalizer
|
|
5610
5916
|
};
|
|
5611
5917
|
};
|
|
@@ -5846,7 +6152,7 @@ function Quote(props) {
|
|
|
5846
6152
|
*/
|
|
5847
6153
|
|
|
5848
6154
|
var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
|
|
5849
|
-
var container =
|
|
6155
|
+
var container = getAboveNode(editor, {
|
|
5850
6156
|
match: {
|
|
5851
6157
|
type: TEXT_CONTAINERS
|
|
5852
6158
|
},
|
|
@@ -5885,11 +6191,11 @@ function toggleQuote(editor, logAction) {
|
|
|
5885
6191
|
logAction == null ? void 0 : logAction(isActive ? 'remove' : 'insert', {
|
|
5886
6192
|
nodeType: BLOCKS.QUOTE
|
|
5887
6193
|
});
|
|
5888
|
-
|
|
6194
|
+
withoutNormalizing(editor, function () {
|
|
5889
6195
|
if (!editor.selection) return;
|
|
5890
|
-
|
|
6196
|
+
unwrapNodes(editor, {
|
|
5891
6197
|
match: function match(node) {
|
|
5892
|
-
return
|
|
6198
|
+
return isElement(node) && node.type === BLOCKS.QUOTE;
|
|
5893
6199
|
},
|
|
5894
6200
|
split: true
|
|
5895
6201
|
});
|
|
@@ -5900,7 +6206,7 @@ function toggleQuote(editor, logAction) {
|
|
|
5900
6206
|
data: {},
|
|
5901
6207
|
children: []
|
|
5902
6208
|
};
|
|
5903
|
-
|
|
6209
|
+
wrapNodes(editor, quote);
|
|
5904
6210
|
}
|
|
5905
6211
|
});
|
|
5906
6212
|
}
|
|
@@ -5921,12 +6227,12 @@ var withQuote = function withQuote(editor) {
|
|
|
5921
6227
|
editor.insertFragment = function (fragment) {
|
|
5922
6228
|
var startingNode = fragment.length && fragment[0];
|
|
5923
6229
|
var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
|
|
5924
|
-
var containerEntry =
|
|
6230
|
+
var containerEntry = getAboveNode(editor, {
|
|
5925
6231
|
match: {
|
|
5926
6232
|
type: TEXT_CONTAINERS
|
|
5927
6233
|
}
|
|
5928
6234
|
});
|
|
5929
|
-
var containerIsNotEmpty = containerEntry &&
|
|
6235
|
+
var containerIsNotEmpty = containerEntry && getText(editor, containerEntry[1]) !== '';
|
|
5930
6236
|
|
|
5931
6237
|
if (startsWithBlockquote && containerIsNotEmpty) {
|
|
5932
6238
|
var selection = editor.selection;
|
|
@@ -5937,22 +6243,22 @@ var withQuote = function withQuote(editor) {
|
|
|
5937
6243
|
|
|
5938
6244
|
|
|
5939
6245
|
if (isContentSelected(selection)) {
|
|
5940
|
-
|
|
6246
|
+
deleteText(editor, {
|
|
5941
6247
|
at: selection
|
|
5942
6248
|
});
|
|
5943
6249
|
} // get the cursor entry again, it may be different after deletion
|
|
5944
6250
|
|
|
5945
6251
|
|
|
5946
|
-
var _containerEntry =
|
|
6252
|
+
var _containerEntry = getAboveNode(editor, {
|
|
5947
6253
|
match: {
|
|
5948
6254
|
type: TEXT_CONTAINERS
|
|
5949
6255
|
}
|
|
5950
6256
|
});
|
|
5951
6257
|
|
|
5952
|
-
var _containerIsNotEmpty = _containerEntry &&
|
|
6258
|
+
var _containerIsNotEmpty = _containerEntry && getText(editor, _containerEntry[1]) !== '';
|
|
5953
6259
|
|
|
5954
6260
|
if (_containerIsNotEmpty) {
|
|
5955
|
-
|
|
6261
|
+
insertNodes(editor, fragment);
|
|
5956
6262
|
return;
|
|
5957
6263
|
}
|
|
5958
6264
|
}
|
|
@@ -6027,15 +6333,17 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
6027
6333
|
});
|
|
6028
6334
|
};
|
|
6029
6335
|
|
|
6336
|
+
var useReadOnly = useReadOnly$1;
|
|
6337
|
+
|
|
6030
6338
|
var addRow = function addRow(editor, getNextRowPath) {
|
|
6031
6339
|
if (someNode(editor, {
|
|
6032
6340
|
match: {
|
|
6033
|
-
type:
|
|
6341
|
+
type: BLOCKS.TABLE
|
|
6034
6342
|
}
|
|
6035
6343
|
})) {
|
|
6036
|
-
var currentRowItem =
|
|
6344
|
+
var currentRowItem = getAboveNode(editor, {
|
|
6037
6345
|
match: {
|
|
6038
|
-
type:
|
|
6346
|
+
type: BLOCKS.TABLE_ROW
|
|
6039
6347
|
}
|
|
6040
6348
|
});
|
|
6041
6349
|
|
|
@@ -6043,8 +6351,7 @@ var addRow = function addRow(editor, getNextRowPath) {
|
|
|
6043
6351
|
var currentRowElem = currentRowItem[0],
|
|
6044
6352
|
currentRowPath = currentRowItem[1];
|
|
6045
6353
|
var nextRowPath = getNextRowPath(currentRowPath);
|
|
6046
|
-
insertNodes(editor,
|
|
6047
|
-
getEmptyRowNode(editor, {
|
|
6354
|
+
insertNodes(editor, getEmptyRowNode(editor, {
|
|
6048
6355
|
header: false,
|
|
6049
6356
|
colCount: currentRowElem.children.length
|
|
6050
6357
|
}), {
|
|
@@ -6053,14 +6360,14 @@ var addRow = function addRow(editor, getNextRowPath) {
|
|
|
6053
6360
|
select: true
|
|
6054
6361
|
}); // Select the first cell in the current row
|
|
6055
6362
|
|
|
6056
|
-
|
|
6363
|
+
select(editor, getStartPoint(editor, nextRowPath));
|
|
6057
6364
|
}
|
|
6058
6365
|
}
|
|
6059
6366
|
};
|
|
6060
6367
|
|
|
6061
6368
|
var addRowBelow = function addRowBelow(editor) {
|
|
6062
6369
|
addRow(editor, function (currentRowPath) {
|
|
6063
|
-
return
|
|
6370
|
+
return getNextPath(currentRowPath);
|
|
6064
6371
|
});
|
|
6065
6372
|
};
|
|
6066
6373
|
var addRowAbove = function addRowAbove(editor) {
|
|
@@ -6075,17 +6382,17 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
|
|
|
6075
6382
|
|
|
6076
6383
|
if (someNode(editor, {
|
|
6077
6384
|
match: {
|
|
6078
|
-
type:
|
|
6385
|
+
type: BLOCKS.TABLE
|
|
6079
6386
|
}
|
|
6080
6387
|
})) {
|
|
6081
|
-
var currentCellItem =
|
|
6388
|
+
var currentCellItem = getAboveNode(editor, {
|
|
6082
6389
|
match: {
|
|
6083
|
-
type: [
|
|
6390
|
+
type: [BLOCKS.TABLE_HEADER_CELL, BLOCKS.TABLE_CELL]
|
|
6084
6391
|
}
|
|
6085
6392
|
});
|
|
6086
|
-
var currentTableItem =
|
|
6393
|
+
var currentTableItem = getAboveNode(editor, {
|
|
6087
6394
|
match: {
|
|
6088
|
-
type:
|
|
6395
|
+
type: BLOCKS.TABLE
|
|
6089
6396
|
}
|
|
6090
6397
|
});
|
|
6091
6398
|
|
|
@@ -6095,8 +6402,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
|
|
|
6095
6402
|
var replacePathPos = newCellPath.length - 2;
|
|
6096
6403
|
currentTableItem[0].children.forEach(function (_, rowIdx) {
|
|
6097
6404
|
newCellPath[replacePathPos] = rowIdx;
|
|
6098
|
-
insertNodes(editor,
|
|
6099
|
-
getEmptyCellNode(editor, {
|
|
6405
|
+
insertNodes(editor, getEmptyCellNode(editor, {
|
|
6100
6406
|
header: header && rowIdx === 0
|
|
6101
6407
|
}), {
|
|
6102
6408
|
at: newCellPath,
|
|
@@ -6110,7 +6416,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
|
|
|
6110
6416
|
|
|
6111
6417
|
var addColumnRight = function addColumnRight(editor, options) {
|
|
6112
6418
|
addColumn(editor, options, function (currentCellPath) {
|
|
6113
|
-
return
|
|
6419
|
+
return getNextPath(currentCellPath);
|
|
6114
6420
|
});
|
|
6115
6421
|
};
|
|
6116
6422
|
var addColumnLeft = function addColumnLeft(editor, options) {
|
|
@@ -6120,7 +6426,7 @@ var addColumnLeft = function addColumnLeft(editor, options) {
|
|
|
6120
6426
|
};
|
|
6121
6427
|
|
|
6122
6428
|
var setHeader = function setHeader(editor, enable) {
|
|
6123
|
-
var tableItem =
|
|
6429
|
+
var tableItem = getAboveNode(editor, {
|
|
6124
6430
|
match: {
|
|
6125
6431
|
type: BLOCKS.TABLE
|
|
6126
6432
|
}
|
|
@@ -6130,13 +6436,13 @@ var setHeader = function setHeader(editor, enable) {
|
|
|
6130
6436
|
return;
|
|
6131
6437
|
}
|
|
6132
6438
|
|
|
6133
|
-
var firstRow = getChildren
|
|
6439
|
+
var firstRow = getChildren(tableItem)[0];
|
|
6134
6440
|
|
|
6135
6441
|
if (!firstRow) {
|
|
6136
6442
|
return;
|
|
6137
6443
|
}
|
|
6138
6444
|
|
|
6139
|
-
getChildren
|
|
6445
|
+
getChildren(firstRow).forEach(function (_ref) {
|
|
6140
6446
|
var path = _ref[1];
|
|
6141
6447
|
setNodes(editor, {
|
|
6142
6448
|
type: enable ? BLOCKS.TABLE_HEADER_CELL : BLOCKS.TABLE_CELL
|
|
@@ -6147,9 +6453,30 @@ var setHeader = function setHeader(editor, enable) {
|
|
|
6147
6453
|
};
|
|
6148
6454
|
|
|
6149
6455
|
function insertTableAndFocusFirstCell(editor) {
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6456
|
+
var table = {
|
|
6457
|
+
type: BLOCKS.TABLE,
|
|
6458
|
+
data: {},
|
|
6459
|
+
children: [getEmptyRowNode(editor, {
|
|
6460
|
+
colCount: 2,
|
|
6461
|
+
header: true
|
|
6462
|
+
}), getEmptyRowNode(editor, {
|
|
6463
|
+
colCount: 2
|
|
6464
|
+
})]
|
|
6465
|
+
};
|
|
6466
|
+
insertNodes(editor, table);
|
|
6467
|
+
|
|
6468
|
+
if (editor.selection) {
|
|
6469
|
+
var tableEntry = getBlockAbove(editor, {
|
|
6470
|
+
match: {
|
|
6471
|
+
type: BLOCKS.TABLE
|
|
6472
|
+
}
|
|
6473
|
+
});
|
|
6474
|
+
if (!tableEntry) return;
|
|
6475
|
+
selectEditor(editor, {
|
|
6476
|
+
at: getStartPoint(editor, tableEntry[1])
|
|
6477
|
+
});
|
|
6478
|
+
}
|
|
6479
|
+
|
|
6153
6480
|
replaceEmptyParagraphWithTable(editor);
|
|
6154
6481
|
}
|
|
6155
6482
|
function isTableActive(editor) {
|
|
@@ -6159,7 +6486,7 @@ function isTableActive(editor) {
|
|
|
6159
6486
|
});
|
|
6160
6487
|
}
|
|
6161
6488
|
function isTableHeaderEnabled(editor) {
|
|
6162
|
-
var tableItem =
|
|
6489
|
+
var tableItem = getAboveNode(editor, {
|
|
6163
6490
|
match: {
|
|
6164
6491
|
type: BLOCKS.TABLE
|
|
6165
6492
|
}
|
|
@@ -6169,30 +6496,30 @@ function isTableHeaderEnabled(editor) {
|
|
|
6169
6496
|
return false;
|
|
6170
6497
|
}
|
|
6171
6498
|
|
|
6172
|
-
var firstRow = getChildren
|
|
6499
|
+
var firstRow = getChildren(tableItem)[0];
|
|
6173
6500
|
|
|
6174
6501
|
if (!firstRow) {
|
|
6175
6502
|
return false;
|
|
6176
6503
|
}
|
|
6177
6504
|
|
|
6178
|
-
return getChildren
|
|
6505
|
+
return getChildren(firstRow).every(function (_ref) {
|
|
6179
6506
|
var node = _ref[0];
|
|
6180
6507
|
return node.type === BLOCKS.TABLE_HEADER_CELL;
|
|
6181
6508
|
});
|
|
6182
6509
|
}
|
|
6183
6510
|
function replaceEmptyParagraphWithTable(editor) {
|
|
6184
6511
|
var tablePath = getAncestorPathFromSelection(editor);
|
|
6185
|
-
if (!tablePath ||
|
|
6186
|
-
var previousPath =
|
|
6512
|
+
if (!tablePath || isFirstChildPath(tablePath)) return;
|
|
6513
|
+
var previousPath = getPreviousPath(tablePath);
|
|
6187
6514
|
if (!previousPath) return;
|
|
6188
6515
|
|
|
6189
|
-
var
|
|
6516
|
+
var _getNodeEntries = getNodeEntries(editor, {
|
|
6190
6517
|
at: previousPath,
|
|
6191
6518
|
match: function match(node) {
|
|
6192
6519
|
return node.type === BLOCKS.PARAGRAPH;
|
|
6193
6520
|
}
|
|
6194
6521
|
}),
|
|
6195
|
-
nodes =
|
|
6522
|
+
nodes = _getNodeEntries[0];
|
|
6196
6523
|
|
|
6197
6524
|
if (!nodes) return;
|
|
6198
6525
|
var previousNode = nodes[0];
|
|
@@ -6200,12 +6527,12 @@ function replaceEmptyParagraphWithTable(editor) {
|
|
|
6200
6527
|
|
|
6201
6528
|
if (isPreviousNodeTextEmpty) {
|
|
6202
6529
|
// Switch table with previous empty paragraph
|
|
6203
|
-
|
|
6530
|
+
moveNodes(editor, {
|
|
6204
6531
|
at: tablePath,
|
|
6205
6532
|
to: previousPath
|
|
6206
6533
|
}); // Remove previous paragraph that now is under the table
|
|
6207
6534
|
|
|
6208
|
-
|
|
6535
|
+
removeNodes(editor, {
|
|
6209
6536
|
at: tablePath
|
|
6210
6537
|
});
|
|
6211
6538
|
}
|
|
@@ -6217,21 +6544,19 @@ function replaceEmptyParagraphWithTable(editor) {
|
|
|
6217
6544
|
* normalization cycles.
|
|
6218
6545
|
*/
|
|
6219
6546
|
|
|
6220
|
-
var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor,
|
|
6221
|
-
var rowPath =
|
|
6222
|
-
var parent =
|
|
6547
|
+
var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor, rowEntry) {
|
|
6548
|
+
var rowPath = rowEntry[1];
|
|
6549
|
+
var parent = getParentNode(editor, rowPath); // This is ensured by normalization. The error is here just in case
|
|
6223
6550
|
|
|
6224
6551
|
if (!parent) {
|
|
6225
6552
|
throw new Error('table rows must be wrapped in a table node');
|
|
6226
|
-
}
|
|
6553
|
+
} // The longest table row determines its width
|
|
6227
6554
|
|
|
6228
|
-
var tablePath = parent[1]; // The longest table row determines its width
|
|
6229
6555
|
|
|
6230
|
-
var tableWidth = Math.max.apply(Math,
|
|
6231
|
-
|
|
6232
|
-
return Array.from(Node.children(editor, path)).length;
|
|
6556
|
+
var tableWidth = Math.max.apply(Math, getChildren(parent).map(function (entry) {
|
|
6557
|
+
return getChildren(entry).length;
|
|
6233
6558
|
}));
|
|
6234
|
-
var rowWidth =
|
|
6559
|
+
var rowWidth = getChildren(rowEntry).length;
|
|
6235
6560
|
return tableWidth - rowWidth;
|
|
6236
6561
|
};
|
|
6237
6562
|
var createEmptyTableCells = function createEmptyTableCells(count) {
|
|
@@ -6248,12 +6573,11 @@ var createEmptyTableCells = function createEmptyTableCells(count) {
|
|
|
6248
6573
|
};
|
|
6249
6574
|
return new Array(count).fill(emptyTableCell);
|
|
6250
6575
|
};
|
|
6251
|
-
var isNotEmpty = function isNotEmpty(
|
|
6252
|
-
|
|
6253
|
-
return Array.from(Node.children(editor, path)).length !== 0;
|
|
6576
|
+
var isNotEmpty = function isNotEmpty(_, entry) {
|
|
6577
|
+
return getChildren(entry).length !== 0;
|
|
6254
6578
|
};
|
|
6255
6579
|
var isTable = function isTable(node) {
|
|
6256
|
-
return
|
|
6580
|
+
return isElement(node) && node.type === BLOCKS.TABLE;
|
|
6257
6581
|
};
|
|
6258
6582
|
|
|
6259
6583
|
var styles$j = {
|
|
@@ -6294,7 +6618,7 @@ var TableActions = function TableActions() {
|
|
|
6294
6618
|
return false;
|
|
6295
6619
|
}
|
|
6296
6620
|
|
|
6297
|
-
var headerCell =
|
|
6621
|
+
var headerCell = getAboveNode(editor, {
|
|
6298
6622
|
match: {
|
|
6299
6623
|
type: BLOCKS.TABLE_HEADER_CELL
|
|
6300
6624
|
}
|
|
@@ -6317,7 +6641,7 @@ var TableActions = function TableActions() {
|
|
|
6317
6641
|
if (!(editor != null && editor.selection)) return;
|
|
6318
6642
|
close();
|
|
6319
6643
|
var tableSize = getCurrentTableSize(editor);
|
|
6320
|
-
|
|
6644
|
+
withoutNormalizing(editor, function () {
|
|
6321
6645
|
cb(editor, {
|
|
6322
6646
|
header: isHeaderEnabled
|
|
6323
6647
|
});
|
|
@@ -6419,7 +6743,7 @@ var Table = function Table(props) {
|
|
|
6419
6743
|
var trimUnnecessaryTableWrapper = function trimUnnecessaryTableWrapper(node) {
|
|
6420
6744
|
var _node$children, _row$children;
|
|
6421
6745
|
|
|
6422
|
-
if (!
|
|
6746
|
+
if (!isElement(node)) {
|
|
6423
6747
|
return [node];
|
|
6424
6748
|
} // must be a table with a single row
|
|
6425
6749
|
|
|
@@ -6469,20 +6793,21 @@ var insertTableFragment = function insertTableFragment(editor) {
|
|
|
6469
6793
|
var onKeyDownTable = function onKeyDownTable(editor, plugin) {
|
|
6470
6794
|
var defaultHandler = onKeyDownTable$1(editor, plugin);
|
|
6471
6795
|
return function (event) {
|
|
6472
|
-
// This fixes `Cannot resolve a Slate point from DOM point:
|
|
6796
|
+
// This fixes `Cannot resolve a Slate point from DOM point:
|
|
6797
|
+
// [object HTMLDivElement]` when typing while the cursor is before table
|
|
6473
6798
|
var windowSelection = window.getSelection();
|
|
6474
6799
|
|
|
6475
6800
|
if (windowSelection) {
|
|
6476
6801
|
var _windowSelection$anch, _windowSelection$anch2;
|
|
6477
6802
|
|
|
6478
6803
|
// @ts-expect-error
|
|
6479
|
-
|
|
6480
|
-
|
|
6804
|
+
// this attribute comes from `plugins/Table/components/Table.tsx`
|
|
6805
|
+
var blockType = (_windowSelection$anch = windowSelection.anchorNode.attributes) == null ? void 0 : (_windowSelection$anch2 = _windowSelection$anch['data-block-type']) == null ? void 0 : _windowSelection$anch2.value;
|
|
6481
6806
|
var isBeforeTable = blockType === BLOCKS.TABLE;
|
|
6482
6807
|
|
|
6483
6808
|
if (isBeforeTable) {
|
|
6484
6809
|
if (event.key === 'Enter') {
|
|
6485
|
-
var above =
|
|
6810
|
+
var above = getAboveNode(editor, {
|
|
6486
6811
|
match: {
|
|
6487
6812
|
type: BLOCKS.TABLE
|
|
6488
6813
|
}
|
|
@@ -6504,15 +6829,15 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
|
|
|
6504
6829
|
|
|
6505
6830
|
|
|
6506
6831
|
if (event.key === 'Tab' && !event.shiftKey) {
|
|
6507
|
-
|
|
6832
|
+
event.preventDefault();
|
|
6833
|
+
var entry = getTableEntries(editor, {});
|
|
6508
6834
|
|
|
6509
|
-
if (
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
var
|
|
6515
|
-
var isLastRow = isLastChild(tableElement, tableRow[1]);
|
|
6835
|
+
if (entry) {
|
|
6836
|
+
var table = entry.table,
|
|
6837
|
+
row = entry.row,
|
|
6838
|
+
cell = entry.cell;
|
|
6839
|
+
var isLastCell = isLastChildPath(row, cell[1]);
|
|
6840
|
+
var isLastRow = isLastChildPath(table, row[1]);
|
|
6516
6841
|
|
|
6517
6842
|
if (isLastRow && isLastCell) {
|
|
6518
6843
|
addRowBelow(editor); // skip default handler
|
|
@@ -6525,7 +6850,7 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
|
|
|
6525
6850
|
}
|
|
6526
6851
|
|
|
6527
6852
|
if (event.key === 'Escape') {
|
|
6528
|
-
|
|
6853
|
+
blurEditor(editor);
|
|
6529
6854
|
}
|
|
6530
6855
|
};
|
|
6531
6856
|
};
|
|
@@ -6808,7 +7133,7 @@ var withInvalidCellChildrenTracking = function withInvalidCellChildrenTracking(t
|
|
|
6808
7133
|
return function (editor, childEntry) {
|
|
6809
7134
|
var node = childEntry[0];
|
|
6810
7135
|
|
|
6811
|
-
if (
|
|
7136
|
+
if (isElement(node)) {
|
|
6812
7137
|
var _editor$tracking;
|
|
6813
7138
|
|
|
6814
7139
|
(_editor$tracking = editor.tracking) == null ? void 0 : _editor$tracking.onViewportAction('invalidTablePaste', {
|
|
@@ -6826,11 +7151,16 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
6826
7151
|
return createTablePlugin$1({
|
|
6827
7152
|
type: BLOCKS.TABLE,
|
|
6828
7153
|
handlers: {
|
|
7154
|
+
// @ts-expect-error
|
|
6829
7155
|
onKeyDown: onKeyDownTable
|
|
6830
7156
|
},
|
|
6831
7157
|
withOverrides: function withOverrides(editor, plugin) {
|
|
6832
|
-
// injects important fixes from plate's original table plugin
|
|
6833
|
-
|
|
7158
|
+
var normalizeNode = editor.normalizeNode; // injects important fixes from plate's original table plugin
|
|
7159
|
+
|
|
7160
|
+
withTable(editor, plugin); // Resets all normalization rules added by @udecode/plate-table as
|
|
7161
|
+
// they conflict with our own
|
|
7162
|
+
|
|
7163
|
+
editor.normalizeNode = normalizeNode;
|
|
6834
7164
|
addTableTrackingEvents(editor);
|
|
6835
7165
|
editor.insertFragment = insertTableFragment(editor);
|
|
6836
7166
|
return editor;
|
|
@@ -6844,6 +7174,8 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
6844
7174
|
// Move to root level unless nested
|
|
6845
7175
|
validNode: function validNode(editor, _ref) {
|
|
6846
7176
|
var path = _ref[1];
|
|
7177
|
+
// Nested tables are handled by another normalization
|
|
7178
|
+
// rule in a the table cell level
|
|
6847
7179
|
var isNestedTable = !!getBlockAbove(editor, {
|
|
6848
7180
|
at: path,
|
|
6849
7181
|
match: {
|
|
@@ -6868,10 +7200,10 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
6868
7200
|
}, {
|
|
6869
7201
|
// Parent must be a table
|
|
6870
7202
|
validNode: function validNode(editor, _ref2) {
|
|
6871
|
-
var
|
|
7203
|
+
var _getParentNode;
|
|
6872
7204
|
|
|
6873
7205
|
var path = _ref2[1];
|
|
6874
|
-
var parent = (
|
|
7206
|
+
var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
|
|
6875
7207
|
return parent && parent.type === BLOCKS.TABLE;
|
|
6876
7208
|
},
|
|
6877
7209
|
transform: transformWrapIn(BLOCKS.TABLE)
|
|
@@ -6882,8 +7214,8 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
6882
7214
|
},
|
|
6883
7215
|
transform: function transform(editor, entry) {
|
|
6884
7216
|
var howMany = getNoOfMissingTableCellsInRow(editor, entry);
|
|
6885
|
-
var at =
|
|
6886
|
-
|
|
7217
|
+
var at = getNextPath(getLastChildPath(entry));
|
|
7218
|
+
insertNodes(editor, createEmptyTableCells(howMany), {
|
|
6887
7219
|
at: at
|
|
6888
7220
|
});
|
|
6889
7221
|
}
|
|
@@ -6948,7 +7280,7 @@ function ToolbarTableButton(props) {
|
|
|
6948
7280
|
testId: "table-toolbar-button",
|
|
6949
7281
|
onClick: handleClick,
|
|
6950
7282
|
// TODO: active state looks off since the button will be disabled. Do we still need it?
|
|
6951
|
-
isActive: isActive,
|
|
7283
|
+
isActive: !!isActive,
|
|
6952
7284
|
isDisabled: props.isDisabled
|
|
6953
7285
|
}, /*#__PURE__*/createElement(TableIcon, null));
|
|
6954
7286
|
}
|
|
@@ -6970,7 +7302,7 @@ function createTextPlugin(restrictedMarks) {
|
|
|
6970
7302
|
return;
|
|
6971
7303
|
}
|
|
6972
7304
|
|
|
6973
|
-
|
|
7305
|
+
setSelection(editor, unhangRange(editor, editor.selection));
|
|
6974
7306
|
};
|
|
6975
7307
|
}
|
|
6976
7308
|
},
|
|
@@ -6986,19 +7318,19 @@ function createTextPlugin(restrictedMarks) {
|
|
|
6986
7318
|
var selection = editor.selection; // If the cursor is at the end of an inline, move it outside
|
|
6987
7319
|
// before inserting
|
|
6988
7320
|
|
|
6989
|
-
if (selection &&
|
|
6990
|
-
var
|
|
7321
|
+
if (selection && isRangeCollapsed(selection)) {
|
|
7322
|
+
var _getAboveNode;
|
|
6991
7323
|
|
|
6992
|
-
var inlinePath = (
|
|
7324
|
+
var inlinePath = (_getAboveNode = getAboveNode(editor, {
|
|
6993
7325
|
match: function match(n) {
|
|
6994
|
-
return
|
|
7326
|
+
return isInline(editor, n);
|
|
6995
7327
|
},
|
|
6996
7328
|
mode: 'highest'
|
|
6997
|
-
})) == null ? void 0 :
|
|
7329
|
+
})) == null ? void 0 : _getAboveNode[1];
|
|
6998
7330
|
|
|
6999
|
-
if (inlinePath &&
|
|
7000
|
-
var point =
|
|
7001
|
-
|
|
7331
|
+
if (inlinePath && isEndPoint(editor, selection.anchor, inlinePath)) {
|
|
7332
|
+
var point = getPointAfter(editor, inlinePath);
|
|
7333
|
+
setSelection(editor, {
|
|
7002
7334
|
anchor: point,
|
|
7003
7335
|
focus: point
|
|
7004
7336
|
});
|
|
@@ -7024,7 +7356,7 @@ function createTextPlugin(restrictedMarks) {
|
|
|
7024
7356
|
return editor;
|
|
7025
7357
|
},
|
|
7026
7358
|
normalizer: [{
|
|
7027
|
-
match:
|
|
7359
|
+
match: isText,
|
|
7028
7360
|
transform: function transform(editor, _ref) {
|
|
7029
7361
|
var path = _ref[1];
|
|
7030
7362
|
unsetNodes(editor, restrictedMarks, {
|
|
@@ -7042,7 +7374,7 @@ function createTextPlugin(restrictedMarks) {
|
|
|
7042
7374
|
}
|
|
7043
7375
|
|
|
7044
7376
|
function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
7045
|
-
var entry =
|
|
7377
|
+
var entry = getAboveNode(editor, {
|
|
7046
7378
|
match: {
|
|
7047
7379
|
type: TEXT_CONTAINERS
|
|
7048
7380
|
}
|
|
@@ -7057,15 +7389,15 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
7057
7389
|
var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
7058
7390
|
|
|
7059
7391
|
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
7060
|
-
|
|
7392
|
+
removeNodes(editor, {
|
|
7061
7393
|
at: path
|
|
7062
7394
|
});
|
|
7063
|
-
var prevNode =
|
|
7395
|
+
var prevNode = getPointBefore(editor, editor.selection, {
|
|
7064
7396
|
unit: unit
|
|
7065
7397
|
});
|
|
7066
7398
|
|
|
7067
7399
|
if (prevNode) {
|
|
7068
|
-
var
|
|
7400
|
+
var _getNodeEntries = getNodeEntries(editor, {
|
|
7069
7401
|
match: function match(node) {
|
|
7070
7402
|
return queryNode([node, prevNode.path], {
|
|
7071
7403
|
allow: [BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY, BLOCKS.HR]
|
|
@@ -7073,10 +7405,10 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
7073
7405
|
},
|
|
7074
7406
|
at: prevNode
|
|
7075
7407
|
}),
|
|
7076
|
-
prevCell =
|
|
7408
|
+
prevCell = _getNodeEntries[0];
|
|
7077
7409
|
|
|
7078
7410
|
if (prevCell) {
|
|
7079
|
-
|
|
7411
|
+
select(editor, prevNode);
|
|
7080
7412
|
}
|
|
7081
7413
|
}
|
|
7082
7414
|
} else {
|
|
@@ -7113,7 +7445,7 @@ function fixPasteAsPlainText(editor) {
|
|
|
7113
7445
|
}
|
|
7114
7446
|
|
|
7115
7447
|
if (split) {
|
|
7116
|
-
|
|
7448
|
+
splitNodes(editor, {
|
|
7117
7449
|
always: true
|
|
7118
7450
|
});
|
|
7119
7451
|
}
|
|
@@ -7147,7 +7479,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7147
7479
|
filter: function filter(_ref) {
|
|
7148
7480
|
var node = _ref[0],
|
|
7149
7481
|
path = _ref[1];
|
|
7150
|
-
return isRootLevel(path) &&
|
|
7482
|
+
return isRootLevel(path) && isFirstChildPath(path) && !!node.isVoid;
|
|
7151
7483
|
}
|
|
7152
7484
|
}
|
|
7153
7485
|
}, {
|
|
@@ -7160,7 +7492,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7160
7492
|
filter: function filter(_ref2) {
|
|
7161
7493
|
var node = _ref2[0],
|
|
7162
7494
|
path = _ref2[1];
|
|
7163
|
-
return !(isRootLevel(path) &&
|
|
7495
|
+
return !(isRootLevel(path) && isFirstChildPath(path)) && !!node.isVoid;
|
|
7164
7496
|
}
|
|
7165
7497
|
}
|
|
7166
7498
|
}]
|
|
@@ -7247,7 +7579,7 @@ var hasContent = function hasContent(doc) {
|
|
|
7247
7579
|
|
|
7248
7580
|
var setEditorContent = function setEditorContent(editor, nodes) {
|
|
7249
7581
|
// Replaces editor content while keeping change history
|
|
7250
|
-
|
|
7582
|
+
withoutNormalizing(editor, function () {
|
|
7251
7583
|
var children = [].concat(editor.children);
|
|
7252
7584
|
children.forEach(function (node) {
|
|
7253
7585
|
return editor.apply({
|
|
@@ -7258,9 +7590,9 @@ var setEditorContent = function setEditorContent(editor, nodes) {
|
|
|
7258
7590
|
});
|
|
7259
7591
|
|
|
7260
7592
|
if (nodes) {
|
|
7261
|
-
var nodesArray =
|
|
7593
|
+
var nodesArray = isNode(nodes) ? [nodes] : nodes;
|
|
7262
7594
|
nodesArray.forEach(function (node, i) {
|
|
7263
|
-
|
|
7595
|
+
editor.apply({
|
|
7264
7596
|
type: 'insert_node',
|
|
7265
7597
|
path: [i],
|
|
7266
7598
|
node: node
|
|
@@ -7268,10 +7600,10 @@ var setEditorContent = function setEditorContent(editor, nodes) {
|
|
|
7268
7600
|
});
|
|
7269
7601
|
}
|
|
7270
7602
|
|
|
7271
|
-
var point =
|
|
7603
|
+
var point = getEndPoint(editor, []);
|
|
7272
7604
|
|
|
7273
7605
|
if (point) {
|
|
7274
|
-
|
|
7606
|
+
select(editor, point);
|
|
7275
7607
|
}
|
|
7276
7608
|
});
|
|
7277
7609
|
};
|
|
@@ -7291,7 +7623,7 @@ var documentToEditorValue = function documentToEditorValue(doc) {
|
|
|
7291
7623
|
var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
7292
7624
|
var editor = createPlateEditor(options);
|
|
7293
7625
|
editor.children = value;
|
|
7294
|
-
|
|
7626
|
+
normalize(editor, {
|
|
7295
7627
|
force: true
|
|
7296
7628
|
});
|
|
7297
7629
|
return editor.children;
|
|
@@ -7399,7 +7731,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
7399
7731
|
nodeType: BLOCKS.EMBEDDED_ENTRY,
|
|
7400
7732
|
onClose: onCloseEntityDropdown
|
|
7401
7733
|
}), inlineEntryEmbedEnabled && /*#__PURE__*/React__default.createElement(ToolbarEmbeddedEntityInlineButton, {
|
|
7402
|
-
isDisabled: !!isDisabled || isLinkActive(editor),
|
|
7734
|
+
isDisabled: !!isDisabled || Boolean(isLinkActive(editor)),
|
|
7403
7735
|
onClose: onCloseEntityDropdown
|
|
7404
7736
|
}), blockAssetEmbedEnabled && /*#__PURE__*/React__default.createElement(EmbeddedEntityBlockToolbarIcon, {
|
|
7405
7737
|
isDisabled: !!isDisabled,
|
|
@@ -7457,7 +7789,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
7457
7789
|
var sdk = _ref.sdk,
|
|
7458
7790
|
isDisabled = _ref.isDisabled;
|
|
7459
7791
|
var editor = useContentfulEditor();
|
|
7460
|
-
var isActive = isMarkActive(editor, MARKS.SUPERSCRIPT) || isMarkActive(editor, MARKS.SUBSCRIPT) || isMarkActive(editor, MARKS.CODE);
|
|
7792
|
+
var isActive = editor && (isMarkActive(editor, MARKS.SUPERSCRIPT) || isMarkActive(editor, MARKS.SUBSCRIPT) || isMarkActive(editor, MARKS.CODE));
|
|
7461
7793
|
return /*#__PURE__*/React__default.createElement(Menu, null, /*#__PURE__*/React__default.createElement(Menu.Trigger, null, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
7462
7794
|
size: "small",
|
|
7463
7795
|
className: styles$l.toolbarBtn,
|
|
@@ -7611,7 +7943,7 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
7611
7943
|
}, 500);
|
|
7612
7944
|
}, [handler]);
|
|
7613
7945
|
return useCallback(function (value) {
|
|
7614
|
-
var editor = getPlateSelectors(editorId).editor();
|
|
7946
|
+
var editor = getPlateSelectors$1(editorId).editor();
|
|
7615
7947
|
|
|
7616
7948
|
if (!editor) {
|
|
7617
7949
|
throw new Error('Editor change callback called but editor not defined. Editor id: ' + editorId);
|
|
@@ -7684,7 +8016,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7684
8016
|
return;
|
|
7685
8017
|
}
|
|
7686
8018
|
|
|
7687
|
-
getPlateActions(id).value(
|
|
8019
|
+
getPlateActions(id).value( // FIXME: fix types here
|
|
8020
|
+
// @ts-expect-error
|
|
8021
|
+
normalizeEditorValue(documentToEditorValue(props.value), {
|
|
7688
8022
|
plugins: plugins,
|
|
7689
8023
|
disableCorePlugins: disableCorePlugins
|
|
7690
8024
|
}));
|
|
@@ -7704,12 +8038,13 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7704
8038
|
className: classNames,
|
|
7705
8039
|
readOnly: props.isDisabled
|
|
7706
8040
|
},
|
|
7707
|
-
onChange: onValueChanged
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
8041
|
+
onChange: onValueChanged,
|
|
8042
|
+
firstChildren: !props.isToolbarHidden && /*#__PURE__*/React__default.createElement(StickyToolbarWrapper, {
|
|
8043
|
+
isDisabled: props.isDisabled
|
|
8044
|
+
}, /*#__PURE__*/React__default.createElement(Toolbar, {
|
|
8045
|
+
isDisabled: props.isDisabled
|
|
8046
|
+
}))
|
|
8047
|
+
}))));
|
|
7713
8048
|
};
|
|
7714
8049
|
|
|
7715
8050
|
var RichTextEditor = function RichTextEditor(props) {
|