@portabletext/editor 1.45.4 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/behavior.core.cjs +20 -0
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +25 -25
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +37 -3
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +20 -0
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +26 -26
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +37 -3
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
- package/lib/behaviors/index.cjs +37 -53
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +26 -1
- package/lib/behaviors/index.d.ts +26 -1
- package/lib/behaviors/index.js +38 -54
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.d.cts +7 -1
- package/lib/index.d.ts +7 -1
- package/lib/plugins/index.cjs +23 -29
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +7 -1
- package/lib/plugins/index.d.ts +7 -1
- package/lib/plugins/index.js +24 -30
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +7 -1
- package/lib/selectors/index.d.ts +7 -1
- package/lib/utils/index.d.cts +7 -1
- package/lib/utils/index.d.ts +7 -1
- package/package.json +1 -1
- package/src/behaviors/behavior.decorator-pair.ts +16 -19
- package/src/behaviors/behavior.emoji-picker.ts +26 -45
- package/src/behaviors/behavior.links.ts +5 -4
- package/src/behaviors/behavior.markdown.ts +37 -34
- package/src/behaviors/behavior.perform-event.ts +53 -2
- package/src/behaviors/behavior.types.action.ts +38 -7
- package/src/behaviors/index.ts +3 -0
- package/src/editor/editor-machine.ts +2 -2
- package/src/plugins/plugin.decorator-shortcut.ts +6 -8
- package/src/plugins/plugin.one-line.tsx +4 -4
|
@@ -5993,6 +5993,7 @@ function eventCategory(event) {
|
|
|
5993
5993
|
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "abstract" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
|
|
5994
5994
|
}
|
|
5995
5995
|
function performEvent({
|
|
5996
|
+
mode,
|
|
5996
5997
|
behaviors,
|
|
5997
5998
|
event,
|
|
5998
5999
|
editor,
|
|
@@ -6006,7 +6007,7 @@ function performEvent({
|
|
|
6006
6007
|
const defaultAction = isCustomBehaviorEvent(event) || isNativeBehaviorEvent(event) || isAbstractBehaviorEvent(event) ? void 0 : {
|
|
6007
6008
|
...event,
|
|
6008
6009
|
editor
|
|
6009
|
-
}, eventBehaviors = behaviors.filter((behavior) => {
|
|
6010
|
+
}, eventBehaviors = (mode === "raise" ? [...behaviors, ...defaultBehaviors] : behaviors).filter((behavior) => {
|
|
6010
6011
|
if (behavior.on === "*")
|
|
6011
6012
|
return !0;
|
|
6012
6013
|
const [listenedNamespace] = behavior.on.includes("*") && behavior.on.includes(".") ? behavior.on.split(".") : [void 0], [eventNamespace] = event.type.includes(".") ? event.type.split(".") : [void 0];
|
|
@@ -6057,7 +6058,8 @@ function performEvent({
|
|
|
6057
6058
|
for (const action of actions) {
|
|
6058
6059
|
if (action.type === "raise") {
|
|
6059
6060
|
performEvent({
|
|
6060
|
-
|
|
6061
|
+
mode,
|
|
6062
|
+
behaviors: mode === "execute" ? isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors : [...behaviors, ...defaultBehaviors],
|
|
6061
6063
|
event: action.event,
|
|
6062
6064
|
editor,
|
|
6063
6065
|
keyGenerator,
|
|
@@ -6068,6 +6070,37 @@ function performEvent({
|
|
|
6068
6070
|
});
|
|
6069
6071
|
continue;
|
|
6070
6072
|
}
|
|
6073
|
+
if (action.type === "execute") {
|
|
6074
|
+
if (isAbstractBehaviorEvent(action.event) || isCustomBehaviorEvent(action.event))
|
|
6075
|
+
performEvent({
|
|
6076
|
+
mode: "execute",
|
|
6077
|
+
behaviors: isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors,
|
|
6078
|
+
event: action.event,
|
|
6079
|
+
editor,
|
|
6080
|
+
keyGenerator,
|
|
6081
|
+
schema,
|
|
6082
|
+
getSnapshot,
|
|
6083
|
+
defaultActionCallback: void 0,
|
|
6084
|
+
nativeEvent: void 0
|
|
6085
|
+
});
|
|
6086
|
+
else
|
|
6087
|
+
try {
|
|
6088
|
+
performAction({
|
|
6089
|
+
context: {
|
|
6090
|
+
keyGenerator,
|
|
6091
|
+
schema
|
|
6092
|
+
},
|
|
6093
|
+
action: {
|
|
6094
|
+
...action.event,
|
|
6095
|
+
editor
|
|
6096
|
+
}
|
|
6097
|
+
});
|
|
6098
|
+
} catch (error) {
|
|
6099
|
+
console.error(new Error(`Performing action "${action.event.type}" as a result of "${event.type}" failed due to: ${error.message}`));
|
|
6100
|
+
break;
|
|
6101
|
+
}
|
|
6102
|
+
continue;
|
|
6103
|
+
}
|
|
6071
6104
|
const internalAction = {
|
|
6072
6105
|
...action,
|
|
6073
6106
|
editor
|
|
@@ -6269,7 +6302,8 @@ const editorMachine = setup({
|
|
|
6269
6302
|
self
|
|
6270
6303
|
}) => {
|
|
6271
6304
|
assertEvent(event, ["behavior event"]), performEvent({
|
|
6272
|
-
|
|
6305
|
+
mode: "raise",
|
|
6306
|
+
behaviors: [...context.behaviors.values()],
|
|
6273
6307
|
event: event.behaviorEvent,
|
|
6274
6308
|
editor: event.editor,
|
|
6275
6309
|
keyGenerator: context.keyGenerator,
|