@portabletext/editor 1.45.4 → 1.47.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 +69 -4
- 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 +69 -4
- 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 +546 -1
- package/lib/behaviors/index.d.ts +546 -1
- package/lib/behaviors/index.js +38 -54
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.d.cts +17 -1
- package/lib/index.d.ts +17 -1
- package/lib/plugins/index.cjs +23 -29
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +17 -1
- package/lib/plugins/index.d.ts +17 -1
- package/lib/plugins/index.js +24 -30
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +17 -1
- package/lib/selectors/index.d.ts +17 -1
- package/lib/utils/index.d.cts +17 -1
- package/lib/utils/index.d.ts +17 -1
- package/package.json +3 -3
- package/src/behavior-actions/behavior.action.move.backward.ts +12 -0
- package/src/behavior-actions/behavior.action.move.forward.ts +11 -0
- package/src/behavior-actions/behavior.actions.ts +18 -0
- 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/behavior.types.event.ts +10 -0
- 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
|
@@ -3984,7 +3984,15 @@ function insertBlock({
|
|
|
3984
3984
|
}
|
|
3985
3985
|
}
|
|
3986
3986
|
}
|
|
3987
|
-
const
|
|
3987
|
+
const moveBackwardActionImplementation = ({
|
|
3988
|
+
action
|
|
3989
|
+
}) => {
|
|
3990
|
+
slate.Transforms.move(action.editor, {
|
|
3991
|
+
unit: "character",
|
|
3992
|
+
distance: action.distance,
|
|
3993
|
+
reverse: !0
|
|
3994
|
+
});
|
|
3995
|
+
}, moveBlockActionImplementation = ({
|
|
3988
3996
|
action
|
|
3989
3997
|
}) => {
|
|
3990
3998
|
const at = [toSlatePath(action.at, action.editor)[0]], to = [toSlatePath(action.to, action.editor)[0]];
|
|
@@ -3993,6 +4001,13 @@ const moveBlockActionImplementation = ({
|
|
|
3993
4001
|
to,
|
|
3994
4002
|
mode: "highest"
|
|
3995
4003
|
});
|
|
4004
|
+
}, moveForwardActionImplementation = ({
|
|
4005
|
+
action
|
|
4006
|
+
}) => {
|
|
4007
|
+
slate.Transforms.move(action.editor, {
|
|
4008
|
+
unit: "character",
|
|
4009
|
+
distance: action.distance
|
|
4010
|
+
});
|
|
3996
4011
|
}, noopActionImplementation = () => {
|
|
3997
4012
|
}, selectActionImplementation = ({
|
|
3998
4013
|
action
|
|
@@ -4082,7 +4097,9 @@ const moveBlockActionImplementation = ({
|
|
|
4082
4097
|
"insert.span": insertSpanActionImplementation,
|
|
4083
4098
|
"insert.text": insertTextActionImplementation,
|
|
4084
4099
|
effect: effectActionImplementation,
|
|
4100
|
+
"move.backward": moveBackwardActionImplementation,
|
|
4085
4101
|
"move.block": moveBlockActionImplementation,
|
|
4102
|
+
"move.forward": moveForwardActionImplementation,
|
|
4086
4103
|
noop: noopActionImplementation,
|
|
4087
4104
|
select: selectActionImplementation,
|
|
4088
4105
|
"split.block": splitBlockActionImplementation
|
|
@@ -4225,6 +4242,13 @@ function performAction({
|
|
|
4225
4242
|
});
|
|
4226
4243
|
break;
|
|
4227
4244
|
}
|
|
4245
|
+
case "move.backward": {
|
|
4246
|
+
behaviorActionImplementations["move.backward"]({
|
|
4247
|
+
context,
|
|
4248
|
+
action
|
|
4249
|
+
});
|
|
4250
|
+
break;
|
|
4251
|
+
}
|
|
4228
4252
|
case "move.block": {
|
|
4229
4253
|
behaviorActionImplementations["move.block"]({
|
|
4230
4254
|
context,
|
|
@@ -4232,6 +4256,13 @@ function performAction({
|
|
|
4232
4256
|
});
|
|
4233
4257
|
break;
|
|
4234
4258
|
}
|
|
4259
|
+
case "move.forward": {
|
|
4260
|
+
behaviorActionImplementations["move.forward"]({
|
|
4261
|
+
context,
|
|
4262
|
+
action
|
|
4263
|
+
});
|
|
4264
|
+
break;
|
|
4265
|
+
}
|
|
4235
4266
|
case "noop":
|
|
4236
4267
|
break;
|
|
4237
4268
|
case "split.block": {
|
|
@@ -5967,6 +5998,7 @@ function eventCategory(event) {
|
|
|
5967
5998
|
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "abstract" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
|
|
5968
5999
|
}
|
|
5969
6000
|
function performEvent({
|
|
6001
|
+
mode,
|
|
5970
6002
|
behaviors,
|
|
5971
6003
|
event,
|
|
5972
6004
|
editor,
|
|
@@ -5980,7 +6012,7 @@ function performEvent({
|
|
|
5980
6012
|
const defaultAction = isCustomBehaviorEvent(event) || isNativeBehaviorEvent(event) || isAbstractBehaviorEvent(event) ? void 0 : {
|
|
5981
6013
|
...event,
|
|
5982
6014
|
editor
|
|
5983
|
-
}, eventBehaviors = behaviors.filter((behavior) => {
|
|
6015
|
+
}, eventBehaviors = (mode === "raise" ? [...behaviors, ...defaultBehaviors] : behaviors).filter((behavior) => {
|
|
5984
6016
|
if (behavior.on === "*")
|
|
5985
6017
|
return !0;
|
|
5986
6018
|
const [listenedNamespace] = behavior.on.includes("*") && behavior.on.includes(".") ? behavior.on.split(".") : [void 0], [eventNamespace] = event.type.includes(".") ? event.type.split(".") : [void 0];
|
|
@@ -6031,7 +6063,8 @@ function performEvent({
|
|
|
6031
6063
|
for (const action of actions) {
|
|
6032
6064
|
if (action.type === "raise") {
|
|
6033
6065
|
performEvent({
|
|
6034
|
-
|
|
6066
|
+
mode,
|
|
6067
|
+
behaviors: mode === "execute" ? isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors : [...behaviors, ...defaultBehaviors],
|
|
6035
6068
|
event: action.event,
|
|
6036
6069
|
editor,
|
|
6037
6070
|
keyGenerator,
|
|
@@ -6042,6 +6075,37 @@ function performEvent({
|
|
|
6042
6075
|
});
|
|
6043
6076
|
continue;
|
|
6044
6077
|
}
|
|
6078
|
+
if (action.type === "execute") {
|
|
6079
|
+
if (isAbstractBehaviorEvent(action.event) || isCustomBehaviorEvent(action.event))
|
|
6080
|
+
performEvent({
|
|
6081
|
+
mode: "execute",
|
|
6082
|
+
behaviors: isCustomBehaviorEvent(action.event) ? [...behaviors, ...defaultBehaviors] : defaultBehaviors,
|
|
6083
|
+
event: action.event,
|
|
6084
|
+
editor,
|
|
6085
|
+
keyGenerator,
|
|
6086
|
+
schema: schema2,
|
|
6087
|
+
getSnapshot,
|
|
6088
|
+
defaultActionCallback: void 0,
|
|
6089
|
+
nativeEvent: void 0
|
|
6090
|
+
});
|
|
6091
|
+
else
|
|
6092
|
+
try {
|
|
6093
|
+
performAction({
|
|
6094
|
+
context: {
|
|
6095
|
+
keyGenerator,
|
|
6096
|
+
schema: schema2
|
|
6097
|
+
},
|
|
6098
|
+
action: {
|
|
6099
|
+
...action.event,
|
|
6100
|
+
editor
|
|
6101
|
+
}
|
|
6102
|
+
});
|
|
6103
|
+
} catch (error) {
|
|
6104
|
+
console.error(new Error(`Performing action "${action.event.type}" as a result of "${event.type}" failed due to: ${error.message}`));
|
|
6105
|
+
break;
|
|
6106
|
+
}
|
|
6107
|
+
continue;
|
|
6108
|
+
}
|
|
6045
6109
|
const internalAction = {
|
|
6046
6110
|
...action,
|
|
6047
6111
|
editor
|
|
@@ -6243,7 +6307,8 @@ const editorMachine = xstate.setup({
|
|
|
6243
6307
|
self
|
|
6244
6308
|
}) => {
|
|
6245
6309
|
xstate.assertEvent(event, ["behavior event"]), performEvent({
|
|
6246
|
-
|
|
6310
|
+
mode: "raise",
|
|
6311
|
+
behaviors: [...context.behaviors.values()],
|
|
6247
6312
|
event: event.behaviorEvent,
|
|
6248
6313
|
editor: event.editor,
|
|
6249
6314
|
keyGenerator: context.keyGenerator,
|