@portabletext/editor 2.13.5 → 2.13.7

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/lib/index.js CHANGED
@@ -13,7 +13,7 @@ import { getBlockStartPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelec
13
13
  import isEqual from "lodash/isEqual.js";
14
14
  import { isTextBlock, isSpan, compileSchema } from "@portabletext/schema";
15
15
  import { defineSchema } from "@portabletext/schema";
16
- import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getMarkState, getActiveDecorators, getTrimmedSelection, isActiveAnnotation, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, getActiveAnnotationsMarks, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, getSelectionEndPoint as getSelectionEndPoint$1, isActiveDecorator, getActiveAnnotations, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-active-style.js";
16
+ import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getActiveDecorators, getTrimmedSelection, isActiveAnnotation, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, getMarkState, getActiveAnnotationsMarks, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, getSelectionEndPoint as getSelectionEndPoint$1, isActiveDecorator, getActiveAnnotations, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-active-style.js";
17
17
  import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusTextBlock, getFocusSpan as getFocusSpan$1, isSelectionExpanded, getFocusBlock as getFocusBlock$1, getSelectedValue, getSelectionStartPoint as getSelectionStartPoint$1, getFocusChild as getFocusChild$1 } from "./_chunks-es/selector.get-selection-text.js";
18
18
  import { defineBehavior, forward, raise, effect } from "./behaviors/index.js";
19
19
  import uniq from "lodash/uniq.js";
@@ -3114,71 +3114,6 @@ function createWithPortableTextMarkModel(editorActor) {
3114
3114
  !movedToNextSpan && !movedToPreviousSpan && (editor.decoratorState = {});
3115
3115
  }
3116
3116
  }
3117
- if (op.type === "insert_node") {
3118
- const {
3119
- selection
3120
- } = editor;
3121
- if (selection) {
3122
- const [_block, blockPath] = Editor.node(editor, selection, {
3123
- depth: 1
3124
- }), previousSpan = getPreviousSpan({
3125
- editor,
3126
- blockPath,
3127
- spanPath: op.path
3128
- }), previousSpanAnnotations = previousSpan ? previousSpan.marks?.filter((mark) => !decorators.includes(mark)) : [], nextSpan = getNextSpan({
3129
- editor,
3130
- blockPath,
3131
- spanPath: [op.path[0], op.path[1] - 1]
3132
- }), nextSpanAnnotations = nextSpan ? nextSpan.marks?.filter((mark) => !decorators.includes(mark)) : [], annotationsEnding = previousSpanAnnotations?.filter((annotation) => !nextSpanAnnotations?.includes(annotation)) ?? [], atTheEndOfAnnotation = annotationsEnding.length > 0;
3133
- if (atTheEndOfAnnotation && isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.some((mark) => annotationsEnding.includes(mark))) {
3134
- Transforms.insertNodes(editor, {
3135
- ...op.node,
3136
- _key: editorActor.getSnapshot().context.keyGenerator(),
3137
- marks: op.node.marks?.filter((mark) => !annotationsEnding.includes(mark)) ?? []
3138
- });
3139
- return;
3140
- }
3141
- const annotationsStarting = nextSpanAnnotations?.filter((annotation) => !previousSpanAnnotations?.includes(annotation)) ?? [], atTheStartOfAnnotation = annotationsStarting.length > 0;
3142
- if (atTheStartOfAnnotation && isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.some((mark) => annotationsStarting.includes(mark))) {
3143
- Transforms.insertNodes(editor, {
3144
- ...op.node,
3145
- _key: editorActor.getSnapshot().context.keyGenerator(),
3146
- marks: op.node.marks?.filter((mark) => !annotationsStarting.includes(mark)) ?? []
3147
- });
3148
- return;
3149
- }
3150
- const nextSpanDecorators = nextSpan?.marks?.filter((mark) => decorators.includes(mark)) ?? [];
3151
- if (nextSpanDecorators.length > 0 && atTheEndOfAnnotation && !atTheStartOfAnnotation && isSpan(editorActor.getSnapshot().context, op.node) && op.node.marks?.length === 0) {
3152
- Transforms.insertNodes(editor, {
3153
- ...op.node,
3154
- _key: editorActor.getSnapshot().context.keyGenerator(),
3155
- marks: nextSpanDecorators
3156
- });
3157
- return;
3158
- }
3159
- }
3160
- }
3161
- if (op.type === "insert_text") {
3162
- const snapshot = getEditorSnapshot({
3163
- editorActorSnapshot: editorActor.getSnapshot(),
3164
- slateEditorInstance: editor
3165
- }), markState = getMarkState(snapshot);
3166
- if (!markState) {
3167
- apply2(op);
3168
- return;
3169
- }
3170
- if (markState.state === "unchanged") {
3171
- apply2(op);
3172
- return;
3173
- }
3174
- Transforms.insertNodes(editor, {
3175
- _type: "span",
3176
- _key: editorActor.getSnapshot().context.keyGenerator(),
3177
- text: op.text,
3178
- marks: markState.marks
3179
- });
3180
- return;
3181
- }
3182
3117
  if (op.type === "remove_text") {
3183
3118
  const {
3184
3119
  selection