@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
|
@@ -5967,6 +5967,7 @@ function eventCategory(event) {
|
|
|
5967
5967
|
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "abstract" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
|
|
5968
5968
|
}
|
|
5969
5969
|
function performEvent({
|
|
5970
|
+
mode,
|
|
5970
5971
|
behaviors,
|
|
5971
5972
|
event,
|
|
5972
5973
|
editor,
|
|
@@ -5980,7 +5981,7 @@ function performEvent({
|
|
|
5980
5981
|
const defaultAction = isCustomBehaviorEvent(event) || isNativeBehaviorEvent(event) || isAbstractBehaviorEvent(event) ? void 0 : {
|
|
5981
5982
|
...event,
|
|
5982
5983
|
editor
|
|
5983
|
-
}, eventBehaviors = behaviors.filter((behavior) => {
|
|
5984
|
+
}, eventBehaviors = (mode === "raise" ? [...behaviors, ...defaultBehaviors] : behaviors).filter((behavior) => {
|
|
5984
5985
|
if (behavior.on === "*")
|
|
5985
5986
|
return !0;
|
|
5986
5987
|
const [listenedNamespace] = behavior.on.includes("*") && behavior.on.includes(".") ? behavior.on.split(".") : [void 0], [eventNamespace] = event.type.includes(".") ? event.type.split(".") : [void 0];
|
|
@@ -6031,7 +6032,8 @@ function performEvent({
|
|
|
6031
6032
|
for (const action of actions) {
|
|
6032
6033
|
if (action.type === "raise") {
|
|
6033
6034
|
performEvent({
|
|
6034
|
-
|
|
6035
|
+
mode,
|
|
6036
|
+
behaviors: mode === "execute" ? isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors : [...behaviors, ...defaultBehaviors],
|
|
6035
6037
|
event: action.event,
|
|
6036
6038
|
editor,
|
|
6037
6039
|
keyGenerator,
|
|
@@ -6042,6 +6044,37 @@ function performEvent({
|
|
|
6042
6044
|
});
|
|
6043
6045
|
continue;
|
|
6044
6046
|
}
|
|
6047
|
+
if (action.type === "execute") {
|
|
6048
|
+
if (isAbstractBehaviorEvent(action.event) || isCustomBehaviorEvent(action.event))
|
|
6049
|
+
performEvent({
|
|
6050
|
+
mode: "execute",
|
|
6051
|
+
behaviors: isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors,
|
|
6052
|
+
event: action.event,
|
|
6053
|
+
editor,
|
|
6054
|
+
keyGenerator,
|
|
6055
|
+
schema: schema2,
|
|
6056
|
+
getSnapshot,
|
|
6057
|
+
defaultActionCallback: void 0,
|
|
6058
|
+
nativeEvent: void 0
|
|
6059
|
+
});
|
|
6060
|
+
else
|
|
6061
|
+
try {
|
|
6062
|
+
performAction({
|
|
6063
|
+
context: {
|
|
6064
|
+
keyGenerator,
|
|
6065
|
+
schema: schema2
|
|
6066
|
+
},
|
|
6067
|
+
action: {
|
|
6068
|
+
...action.event,
|
|
6069
|
+
editor
|
|
6070
|
+
}
|
|
6071
|
+
});
|
|
6072
|
+
} catch (error) {
|
|
6073
|
+
console.error(new Error(`Performing action "${action.event.type}" as a result of "${event.type}" failed due to: ${error.message}`));
|
|
6074
|
+
break;
|
|
6075
|
+
}
|
|
6076
|
+
continue;
|
|
6077
|
+
}
|
|
6045
6078
|
const internalAction = {
|
|
6046
6079
|
...action,
|
|
6047
6080
|
editor
|
|
@@ -6243,7 +6276,8 @@ const editorMachine = xstate.setup({
|
|
|
6243
6276
|
self
|
|
6244
6277
|
}) => {
|
|
6245
6278
|
xstate.assertEvent(event, ["behavior event"]), performEvent({
|
|
6246
|
-
|
|
6279
|
+
mode: "raise",
|
|
6280
|
+
behaviors: [...context.behaviors.values()],
|
|
6247
6281
|
event: event.behaviorEvent,
|
|
6248
6282
|
editor: event.editor,
|
|
6249
6283
|
keyGenerator: context.keyGenerator,
|