@portabletext/editor 1.47.13 → 1.47.15
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/editor-provider.cjs +19 -7
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +19 -7
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +6 -6
- package/lib/behaviors/index.d.ts +6 -6
- package/lib/index.d.cts +3 -2
- package/lib/index.d.ts +3 -2
- package/lib/plugins/index.d.cts +1 -1
- package/lib/plugins/index.d.ts +1 -1
- package/lib/selectors/index.d.cts +1 -1
- package/lib/selectors/index.d.ts +1 -1
- package/lib/utils/index.d.cts +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/package.json +10 -10
- package/src/behaviors/behavior.perform-event.ts +5 -2
- package/src/behaviors/behavior.types.event.ts +1 -1
- package/src/editor/editor-context.tsx +7 -0
- package/src/editor/editor-provider.tsx +1 -3
- package/src/internal-utils/global-scope.ts +19 -0
- package/src/internal-utils/globally-scoped-context.ts +39 -0
|
@@ -5798,7 +5798,20 @@ function createInternalEditor(editorActor) {
|
|
|
5798
5798
|
}
|
|
5799
5799
|
};
|
|
5800
5800
|
}
|
|
5801
|
-
const EditorActorContext = createContext({})
|
|
5801
|
+
const EditorActorContext = createContext({});
|
|
5802
|
+
function getGlobalScope() {
|
|
5803
|
+
if (typeof globalThis < "u") return globalThis;
|
|
5804
|
+
if (typeof window < "u") return window;
|
|
5805
|
+
if (typeof self < "u") return self;
|
|
5806
|
+
if (typeof global < "u") return global;
|
|
5807
|
+
throw new Error("@portabletext/editor: could not locate global scope");
|
|
5808
|
+
}
|
|
5809
|
+
const globalScope = getGlobalScope();
|
|
5810
|
+
function createGloballyScopedContext(key, defaultValue) {
|
|
5811
|
+
const symbol = Symbol.for(key);
|
|
5812
|
+
return typeof document > "u" ? createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] ?? createContext(defaultValue), globalScope[symbol]);
|
|
5813
|
+
}
|
|
5814
|
+
const EditorContext = createGloballyScopedContext("@portabletext/editor/context/editor", null), abstractAnnotationBehaviors = [defineBehavior({
|
|
5802
5815
|
on: "annotation.toggle",
|
|
5803
5816
|
guard: ({
|
|
5804
5817
|
snapshot,
|
|
@@ -6673,7 +6686,7 @@ function isCustomBehaviorEvent(event) {
|
|
|
6673
6686
|
}
|
|
6674
6687
|
const debug$2 = debugWithName("behaviors:event");
|
|
6675
6688
|
function eventCategory(event) {
|
|
6676
|
-
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "
|
|
6689
|
+
return isNativeBehaviorEvent(event) ? "native" : isAbstractBehaviorEvent(event) ? "synthetic" : isCustomBehaviorEvent(event) ? "custom" : "synthetic";
|
|
6677
6690
|
}
|
|
6678
6691
|
function performEvent({
|
|
6679
6692
|
mode,
|
|
@@ -6685,7 +6698,7 @@ function performEvent({
|
|
|
6685
6698
|
getSnapshot,
|
|
6686
6699
|
nativeEvent
|
|
6687
6700
|
}) {
|
|
6688
|
-
debug$2(`(${eventCategory(event)})`, JSON.stringify(event, null, 2));
|
|
6701
|
+
debug$2(`(${isNativeBehaviorEvent(event) ? "" : `${mode}:`}${eventCategory(event)})`, JSON.stringify(event, null, 2));
|
|
6689
6702
|
const defaultAction = isCustomBehaviorEvent(event) || isNativeBehaviorEvent(event) || isAbstractBehaviorEvent(event) ? void 0 : {
|
|
6690
6703
|
...event,
|
|
6691
6704
|
editor
|
|
@@ -6955,7 +6968,7 @@ const editorMachine = setup({
|
|
|
6955
6968
|
"handle behavior event": ({
|
|
6956
6969
|
context,
|
|
6957
6970
|
event,
|
|
6958
|
-
self
|
|
6971
|
+
self: self2
|
|
6959
6972
|
}) => {
|
|
6960
6973
|
assertEvent(event, ["behavior event"]), performEvent({
|
|
6961
6974
|
mode: "raise",
|
|
@@ -6968,11 +6981,11 @@ const editorMachine = setup({
|
|
|
6968
6981
|
converters: [...context.converters],
|
|
6969
6982
|
editor: event.editor,
|
|
6970
6983
|
keyGenerator: context.keyGenerator,
|
|
6971
|
-
readOnly:
|
|
6984
|
+
readOnly: self2.getSnapshot().matches({
|
|
6972
6985
|
"edit mode": "read only"
|
|
6973
6986
|
}),
|
|
6974
6987
|
schema: context.schema,
|
|
6975
|
-
hasTag: (tag) =>
|
|
6988
|
+
hasTag: (tag) => self2.getSnapshot().hasTag(tag),
|
|
6976
6989
|
internalDrag: context.internalDrag
|
|
6977
6990
|
}),
|
|
6978
6991
|
nativeEvent: event.nativeEvent
|
|
@@ -7849,7 +7862,6 @@ function RouteEventsToChanges(props) {
|
|
|
7849
7862
|
let t2;
|
|
7850
7863
|
return $[5] !== props.editorActor ? (t2 = [props.editorActor], $[5] = props.editorActor, $[6] = t2) : t2 = $[6], useEffect(t1, t2), null;
|
|
7851
7864
|
}
|
|
7852
|
-
const EditorContext = React.createContext(void 0);
|
|
7853
7865
|
function EditorProvider(props) {
|
|
7854
7866
|
const editorActor = useActorRef(editorMachine, {
|
|
7855
7867
|
input: editorConfigToMachineInput(props.initialConfig)
|