@portabletext/editor 7.10.8 → 7.10.9
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/_chunks-es/selector.is-at-the-start-of-block.js +12 -2
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/index.js +34 -4
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.d.ts +6 -3
- package/lib/selectors/index.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -11042,12 +11042,13 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
11042
11042
|
}), preventOverlappingAnnotations = defineBehavior({
|
|
11043
11043
|
// Given an `annotation.add` event
|
|
11044
11044
|
on: "annotation.add",
|
|
11045
|
-
// When the annotation
|
|
11045
|
+
// When the raised `annotation.remove` would strip the annotation from at
|
|
11046
|
+
// least one span
|
|
11046
11047
|
guard: ({
|
|
11047
11048
|
snapshot,
|
|
11048
11049
|
event
|
|
11049
11050
|
}) => {
|
|
11050
|
-
const at = event.at
|
|
11051
|
+
const at = resolveEffectiveSelection(snapshot, event.at);
|
|
11051
11052
|
if (!at)
|
|
11052
11053
|
return !1;
|
|
11053
11054
|
const adjustedSnapshot = {
|
|
@@ -11114,7 +11115,22 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
11114
11115
|
marks: activeDecorators
|
|
11115
11116
|
}
|
|
11116
11117
|
}), forward(event)]]
|
|
11117
|
-
}), coreAnnotationBehaviors = [addAnnotationOnCollapsedSelection, preventOverlappingAnnotations, stripAnnotationsOnFullSpanDeletion]
|
|
11118
|
+
}), coreAnnotationBehaviors = [addAnnotationOnCollapsedSelection, preventOverlappingAnnotations, stripAnnotationsOnFullSpanDeletion];
|
|
11119
|
+
function resolveEffectiveSelection(snapshot, at) {
|
|
11120
|
+
if (!at)
|
|
11121
|
+
return snapshot.context.selection;
|
|
11122
|
+
const resolvedAt = resolveSelection({
|
|
11123
|
+
snapshot
|
|
11124
|
+
}, at);
|
|
11125
|
+
return resolvedAt ? {
|
|
11126
|
+
anchor: resolvedAt.anchor,
|
|
11127
|
+
focus: resolvedAt.focus,
|
|
11128
|
+
// Resolving can move either point, so `at.backward` may no longer
|
|
11129
|
+
// match; derive the direction from the resolved points instead.
|
|
11130
|
+
backward: isBackwardRange(resolvedAt, snapshot.context)
|
|
11131
|
+
} : snapshot.context.selection;
|
|
11132
|
+
}
|
|
11133
|
+
const defaultKeyboardShortcuts = {
|
|
11118
11134
|
arrowDown: createKeyboardShortcut({
|
|
11119
11135
|
default: [{
|
|
11120
11136
|
key: "ArrowDown",
|
|
@@ -16704,7 +16720,21 @@ function isCustomBehaviorEvent(event) {
|
|
|
16704
16720
|
function eventCategory(event) {
|
|
16705
16721
|
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "synthetic" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
|
|
16706
16722
|
}
|
|
16707
|
-
|
|
16723
|
+
const maxEventDepth = 100, eventDepths = /* @__PURE__ */ new WeakMap();
|
|
16724
|
+
function performEvent(args) {
|
|
16725
|
+
const depth = (eventDepths.get(args.editor) ?? 0) + 1;
|
|
16726
|
+
if (depth > maxEventDepth) {
|
|
16727
|
+
console.error(new Error(`Performing "${args.event.type}" was aborted because the event chain exceeded a depth of ${maxEventDepth}. This usually means Behaviors keep raising events in a cycle.`));
|
|
16728
|
+
return;
|
|
16729
|
+
}
|
|
16730
|
+
eventDepths.set(args.editor, depth);
|
|
16731
|
+
try {
|
|
16732
|
+
performEventInternal(args);
|
|
16733
|
+
} finally {
|
|
16734
|
+
eventDepths.set(args.editor, depth - 1);
|
|
16735
|
+
}
|
|
16736
|
+
}
|
|
16737
|
+
function performEventInternal({
|
|
16708
16738
|
mode,
|
|
16709
16739
|
behaviors,
|
|
16710
16740
|
remainingEventBehaviors,
|