oasis-editor 0.0.138 → 0.0.140
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/dist/{OasisEditorApp-DMI2ZfOd.js → OasisEditorApp-vqeSS8FT.js} +71 -8
- package/dist/adapters/mountController.d.ts +11 -0
- package/dist/adapters/react.d.ts +8 -0
- package/dist/adapters/ui.d.ts +1 -1
- package/dist/adapters/vue.d.ts +10 -0
- package/dist/app/bootstrap/createOasisEditorApp.d.ts +9 -0
- package/dist/app/bootstrap/createOasisEditorContainer.d.ts +9 -0
- package/dist/app/client/OasisEditorClient.d.ts +254 -1
- package/dist/app/client/publicDocumentApi.d.ts +223 -0
- package/dist/app/controllers/documentIO/DocumentExporter.d.ts +10 -2
- package/dist/app/controllers/documentIO/DocumentImporter.d.ts +6 -0
- package/dist/app/controllers/useEditorDocumentIO.d.ts +4 -2
- package/dist/app/controllers/useEditorFindReplace.d.ts +7 -0
- package/dist/app/controllers/useEditorPersistence.d.ts +10 -0
- package/dist/app/services/FindReplaceService.d.ts +9 -0
- package/dist/app/services/indexedDbPersistence.d.ts +10 -1
- package/dist/app/services/tablePropertiesService.d.ts +12 -3
- package/dist/app/services/userPreferences.d.ts +4 -0
- package/dist/assets/{importDocxWorker-DBjcGf-C.js → importDocxWorker-B1vHeo5L.js} +1 -1
- package/dist/core/Editor.d.ts +33 -1
- package/dist/core/commands/CommandBus.d.ts +26 -0
- package/dist/core/commands/publicCommandTypes.d.ts +53 -0
- package/dist/core/model/types/document.d.ts +2 -0
- package/dist/core/plugin.d.ts +60 -0
- package/dist/import/DocumentFormatImporter.d.ts +20 -4
- package/dist/import/documentImporterRegistry.d.ts +6 -2
- package/dist/{index-M7h7REmM.js → index-C_F1o38Z.js} +1191 -760
- package/dist/index.d.ts +3 -1
- package/dist/mountController.d.ts +11 -0
- package/dist/oasis-editor.js +44 -36
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/react.d.ts +8 -0
- package/dist/ui/OasisEditorAppProps.d.ts +8 -4
- package/dist/ui/app/connectEditorClientHost.d.ts +12 -2
- package/dist/ui/app/createEditorCommandRuntime.d.ts +8 -1
- package/dist/ui/app/createEditorDocumentRuntime.d.ts +4 -2
- package/dist/ui/app/essentials/types.d.ts +2 -2
- package/dist/ui/canvas/CanvasDebug.d.ts +15 -1
- package/dist/ui/components/Menubar/menuRegistry.d.ts +11 -0
- package/dist/ui/components/Toolbar/registry/ToolbarRegistry.d.ts +43 -7
- package/dist/ui/components/Toolbar/schema/items.d.ts +39 -7
- package/dist/ui/components/Toolbar/state/createToolbarApi.d.ts +8 -4
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +29 -30
- package/dist/vue.d.ts +10 -0
- package/package.json +2 -1
|
@@ -2731,7 +2731,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2731
2731
|
onCleanup(() => {
|
|
2732
2732
|
cancelled = true;
|
|
2733
2733
|
});
|
|
2734
|
-
import("./OasisEditorApp-
|
|
2734
|
+
import("./OasisEditorApp-vqeSS8FT.js").then((m) => {
|
|
2735
2735
|
cancelled = true;
|
|
2736
2736
|
setProgress(1);
|
|
2737
2737
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -2786,551 +2786,6 @@ function resolveCommandRef(ref, payloadOverride) {
|
|
|
2786
2786
|
payload: payloadOverride !== void 0 ? payloadOverride : ref.payload
|
|
2787
2787
|
};
|
|
2788
2788
|
}
|
|
2789
|
-
function disabledCommandState() {
|
|
2790
|
-
return { isEnabled: false, isActive: false, value: void 0 };
|
|
2791
|
-
}
|
|
2792
|
-
function createOasisEditorClient() {
|
|
2793
|
-
let host = null;
|
|
2794
|
-
let resolveReady;
|
|
2795
|
-
let rejectReady;
|
|
2796
|
-
const listeners = /* @__PURE__ */ new Map();
|
|
2797
|
-
let disposed = false;
|
|
2798
|
-
let disposeHost;
|
|
2799
|
-
let dirty = false;
|
|
2800
|
-
const ready = new Promise((resolve, reject) => {
|
|
2801
|
-
resolveReady = resolve;
|
|
2802
|
-
rejectReady = reject;
|
|
2803
|
-
});
|
|
2804
|
-
const emit = (event, payload) => {
|
|
2805
|
-
if (event === "change") {
|
|
2806
|
-
dirty = true;
|
|
2807
|
-
}
|
|
2808
|
-
const handlers = listeners.get(event);
|
|
2809
|
-
if (!handlers) return;
|
|
2810
|
-
for (const handler of [...handlers]) {
|
|
2811
|
-
handler(payload);
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
const addListener = (event, callback) => {
|
|
2815
|
-
const handlers = listeners.get(event) ?? /* @__PURE__ */ new Set();
|
|
2816
|
-
handlers.add(
|
|
2817
|
-
callback
|
|
2818
|
-
);
|
|
2819
|
-
listeners.set(event, handlers);
|
|
2820
|
-
return () => {
|
|
2821
|
-
handlers.delete(
|
|
2822
|
-
callback
|
|
2823
|
-
);
|
|
2824
|
-
if (handlers.size === 0) listeners.delete(event);
|
|
2825
|
-
};
|
|
2826
|
-
};
|
|
2827
|
-
const getRuntimeEditor = () => (host == null ? void 0 : host.getRuntimeEditor()) ?? null;
|
|
2828
|
-
const requireHost = () => {
|
|
2829
|
-
if (!host) throw new Error("Oasis editor client is not mounted.");
|
|
2830
|
-
return host;
|
|
2831
|
-
};
|
|
2832
|
-
const normalizePayload = (command, payloadOverride) => {
|
|
2833
|
-
const resolved = resolveCommandRef(command, payloadOverride);
|
|
2834
|
-
if (resolved.name === "insertTable" && resolved.payload && typeof resolved.payload === "object") {
|
|
2835
|
-
const payload = resolved.payload;
|
|
2836
|
-
return {
|
|
2837
|
-
...resolved,
|
|
2838
|
-
payload: {
|
|
2839
|
-
rows: payload.rows,
|
|
2840
|
-
cols: payload.cols ?? payload.columns
|
|
2841
|
-
}
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
if (resolved.name === "setFontSize" && resolved.payload && typeof resolved.payload === "object") {
|
|
2845
|
-
const payload = resolved.payload;
|
|
2846
|
-
return { ...resolved, payload: payload.size };
|
|
2847
|
-
}
|
|
2848
|
-
return resolved;
|
|
2849
|
-
};
|
|
2850
|
-
const commands = {
|
|
2851
|
-
execute(command, payloadOverride) {
|
|
2852
|
-
const editor = getRuntimeEditor();
|
|
2853
|
-
if (!editor) {
|
|
2854
|
-
throw new Error("Oasis editor runtime is not ready.");
|
|
2855
|
-
}
|
|
2856
|
-
const resolved = normalizePayload(command, payloadOverride);
|
|
2857
|
-
return editor.commands.execute(resolved.name, resolved.payload);
|
|
2858
|
-
},
|
|
2859
|
-
canExecute(command, payloadOverride) {
|
|
2860
|
-
const editor = getRuntimeEditor();
|
|
2861
|
-
if (!editor) return false;
|
|
2862
|
-
const resolved = normalizePayload(command, payloadOverride);
|
|
2863
|
-
return editor.commands.canExecute(resolved.name, resolved.payload);
|
|
2864
|
-
},
|
|
2865
|
-
state(command) {
|
|
2866
|
-
var _a2;
|
|
2867
|
-
const editor = getRuntimeEditor();
|
|
2868
|
-
if (!editor) return disabledCommandState();
|
|
2869
|
-
const resolved = resolveCommandRef(command);
|
|
2870
|
-
const registered = editor.commands.get(resolved.name);
|
|
2871
|
-
const state = (_a2 = registered == null ? void 0 : registered.refresh) == null ? void 0 : _a2.call(registered, resolved.payload);
|
|
2872
|
-
return {
|
|
2873
|
-
isEnabled: (state == null ? void 0 : state.isEnabled) ?? editor.commands.has(resolved.name) ?? false,
|
|
2874
|
-
isActive: Boolean(state == null ? void 0 : state.isActive),
|
|
2875
|
-
value: state == null ? void 0 : state.value
|
|
2876
|
-
};
|
|
2877
|
-
}
|
|
2878
|
-
};
|
|
2879
|
-
return {
|
|
2880
|
-
ready,
|
|
2881
|
-
commands,
|
|
2882
|
-
connectHost(nextHost) {
|
|
2883
|
-
host = nextHost;
|
|
2884
|
-
},
|
|
2885
|
-
setDispose(dispose2) {
|
|
2886
|
-
disposeHost = dispose2;
|
|
2887
|
-
},
|
|
2888
|
-
resolveReady(editor) {
|
|
2889
|
-
dirty = false;
|
|
2890
|
-
resolveReady(editor);
|
|
2891
|
-
emit("ready", editor);
|
|
2892
|
-
},
|
|
2893
|
-
rejectReady(error) {
|
|
2894
|
-
rejectReady(error);
|
|
2895
|
-
emit("error", error);
|
|
2896
|
-
},
|
|
2897
|
-
emit,
|
|
2898
|
-
dispose() {
|
|
2899
|
-
if (disposed) return;
|
|
2900
|
-
disposed = true;
|
|
2901
|
-
return disposeHost == null ? void 0 : disposeHost();
|
|
2902
|
-
},
|
|
2903
|
-
getState() {
|
|
2904
|
-
return requireHost().getState();
|
|
2905
|
-
},
|
|
2906
|
-
getDocument() {
|
|
2907
|
-
return requireHost().getDocument();
|
|
2908
|
-
},
|
|
2909
|
-
setDocument(document2) {
|
|
2910
|
-
requireHost().setDocument(document2);
|
|
2911
|
-
},
|
|
2912
|
-
loadDocument(document2) {
|
|
2913
|
-
requireHost().setDocument(document2);
|
|
2914
|
-
dirty = false;
|
|
2915
|
-
},
|
|
2916
|
-
updateDocument(updater) {
|
|
2917
|
-
const current = requireHost().getDocument();
|
|
2918
|
-
requireHost().setDocument(updater(current));
|
|
2919
|
-
},
|
|
2920
|
-
resetDocument() {
|
|
2921
|
-
requireHost().resetDocument();
|
|
2922
|
-
dirty = false;
|
|
2923
|
-
},
|
|
2924
|
-
async save() {
|
|
2925
|
-
await requireHost().saveDocument();
|
|
2926
|
-
dirty = false;
|
|
2927
|
-
},
|
|
2928
|
-
isDirty() {
|
|
2929
|
-
return dirty;
|
|
2930
|
-
},
|
|
2931
|
-
markClean() {
|
|
2932
|
-
dirty = false;
|
|
2933
|
-
},
|
|
2934
|
-
getSelection() {
|
|
2935
|
-
return requireHost().getSelection();
|
|
2936
|
-
},
|
|
2937
|
-
setSelection(selection) {
|
|
2938
|
-
requireHost().setSelection(selection);
|
|
2939
|
-
},
|
|
2940
|
-
focusEditor() {
|
|
2941
|
-
requireHost().focus();
|
|
2942
|
-
},
|
|
2943
|
-
blurEditor() {
|
|
2944
|
-
requireHost().blur();
|
|
2945
|
-
},
|
|
2946
|
-
document: {
|
|
2947
|
-
get: () => requireHost().getDocument(),
|
|
2948
|
-
set: (document2) => requireHost().setDocument(document2),
|
|
2949
|
-
load: (document2) => {
|
|
2950
|
-
requireHost().setDocument(document2);
|
|
2951
|
-
dirty = false;
|
|
2952
|
-
},
|
|
2953
|
-
update: (updater) => {
|
|
2954
|
-
const current = requireHost().getDocument();
|
|
2955
|
-
requireHost().setDocument(updater(current));
|
|
2956
|
-
},
|
|
2957
|
-
reset: () => {
|
|
2958
|
-
requireHost().resetDocument();
|
|
2959
|
-
dirty = false;
|
|
2960
|
-
},
|
|
2961
|
-
save: async () => {
|
|
2962
|
-
await requireHost().saveDocument();
|
|
2963
|
-
dirty = false;
|
|
2964
|
-
},
|
|
2965
|
-
isDirty: () => dirty,
|
|
2966
|
-
markClean: () => {
|
|
2967
|
-
dirty = false;
|
|
2968
|
-
}
|
|
2969
|
-
},
|
|
2970
|
-
selection: {
|
|
2971
|
-
get: () => requireHost().getSelection(),
|
|
2972
|
-
set: (selection) => requireHost().setSelection(selection)
|
|
2973
|
-
},
|
|
2974
|
-
focus: {
|
|
2975
|
-
focus: () => requireHost().focus(),
|
|
2976
|
-
blur: () => requireHost().blur()
|
|
2977
|
-
},
|
|
2978
|
-
history: {
|
|
2979
|
-
undo: () => commands.execute("undo"),
|
|
2980
|
-
redo: () => commands.execute("redo"),
|
|
2981
|
-
canUndo: () => commands.canExecute("undo"),
|
|
2982
|
-
canRedo: () => commands.canExecute("redo"),
|
|
2983
|
-
clear: () => requireHost().clearHistory()
|
|
2984
|
-
},
|
|
2985
|
-
import: {
|
|
2986
|
-
docx: (file) => requireHost().importDocx(file)
|
|
2987
|
-
},
|
|
2988
|
-
export: {
|
|
2989
|
-
docx: () => requireHost().exportDocx(),
|
|
2990
|
-
pdf: () => requireHost().exportPdf()
|
|
2991
|
-
},
|
|
2992
|
-
on: addListener,
|
|
2993
|
-
once(event, callback) {
|
|
2994
|
-
const unsubscribe = addListener(event, (payload) => {
|
|
2995
|
-
unsubscribe();
|
|
2996
|
-
callback(payload);
|
|
2997
|
-
});
|
|
2998
|
-
return unsubscribe;
|
|
2999
|
-
},
|
|
3000
|
-
off(event, callback) {
|
|
3001
|
-
const handlers = listeners.get(event);
|
|
3002
|
-
if (!handlers) return;
|
|
3003
|
-
handlers.delete(
|
|
3004
|
-
callback
|
|
3005
|
-
);
|
|
3006
|
-
if (handlers.size === 0) listeners.delete(event);
|
|
3007
|
-
}
|
|
3008
|
-
};
|
|
3009
|
-
}
|
|
3010
|
-
function createOasisEditor(container, props = {}) {
|
|
3011
|
-
const client = createOasisEditorClient();
|
|
3012
|
-
const dispose2 = render(
|
|
3013
|
-
() => OasisEditorAppLazy({ ...props, runtime: { ...props.runtime, client } }),
|
|
3014
|
-
container
|
|
3015
|
-
);
|
|
3016
|
-
client.setDispose(() => {
|
|
3017
|
-
dispose2();
|
|
3018
|
-
container.innerHTML = "";
|
|
3019
|
-
});
|
|
3020
|
-
return client;
|
|
3021
|
-
}
|
|
3022
|
-
function OasisEditorContainer(props) {
|
|
3023
|
-
return createComponent(OasisEditorAppLazy, mergeProps(props, {
|
|
3024
|
-
get ui() {
|
|
3025
|
-
return {
|
|
3026
|
-
...props.ui,
|
|
3027
|
-
showChrome: false
|
|
3028
|
-
};
|
|
3029
|
-
}
|
|
3030
|
-
}));
|
|
3031
|
-
}
|
|
3032
|
-
function createOasisEditorContainer(container, props = {}) {
|
|
3033
|
-
const client = createOasisEditorClient();
|
|
3034
|
-
const dispose2 = render(
|
|
3035
|
-
() => OasisEditorContainer({
|
|
3036
|
-
...props,
|
|
3037
|
-
runtime: { ...props.runtime, client }
|
|
3038
|
-
}),
|
|
3039
|
-
container
|
|
3040
|
-
);
|
|
3041
|
-
client.setDispose(() => {
|
|
3042
|
-
dispose2();
|
|
3043
|
-
container.innerHTML = "";
|
|
3044
|
-
});
|
|
3045
|
-
return client;
|
|
3046
|
-
}
|
|
3047
|
-
const $RAW = Symbol("store-raw"), $NODE = Symbol("store-node"), $HAS = Symbol("store-has"), $SELF = Symbol("store-self");
|
|
3048
|
-
function wrap$1(value) {
|
|
3049
|
-
let p = value[$PROXY];
|
|
3050
|
-
if (!p) {
|
|
3051
|
-
Object.defineProperty(value, $PROXY, {
|
|
3052
|
-
value: p = new Proxy(value, proxyTraps$1)
|
|
3053
|
-
});
|
|
3054
|
-
if (!Array.isArray(value)) {
|
|
3055
|
-
const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
|
|
3056
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
3057
|
-
const prop = keys[i];
|
|
3058
|
-
if (desc[prop].get) {
|
|
3059
|
-
Object.defineProperty(value, prop, {
|
|
3060
|
-
enumerable: desc[prop].enumerable,
|
|
3061
|
-
get: desc[prop].get.bind(p)
|
|
3062
|
-
});
|
|
3063
|
-
}
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
return p;
|
|
3068
|
-
}
|
|
3069
|
-
function isWrappable(obj) {
|
|
3070
|
-
let proto;
|
|
3071
|
-
return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
|
|
3072
|
-
}
|
|
3073
|
-
function unwrap(item, set = /* @__PURE__ */ new Set()) {
|
|
3074
|
-
let result, unwrapped, v, prop;
|
|
3075
|
-
if (result = item != null && item[$RAW]) return result;
|
|
3076
|
-
if (!isWrappable(item) || set.has(item)) return item;
|
|
3077
|
-
if (Array.isArray(item)) {
|
|
3078
|
-
if (Object.isFrozen(item)) item = item.slice(0);
|
|
3079
|
-
else set.add(item);
|
|
3080
|
-
for (let i = 0, l = item.length; i < l; i++) {
|
|
3081
|
-
v = item[i];
|
|
3082
|
-
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
|
|
3083
|
-
}
|
|
3084
|
-
} else {
|
|
3085
|
-
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
3086
|
-
else set.add(item);
|
|
3087
|
-
const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
|
|
3088
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
3089
|
-
prop = keys[i];
|
|
3090
|
-
if (desc[prop].get) continue;
|
|
3091
|
-
v = item[prop];
|
|
3092
|
-
if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
return item;
|
|
3096
|
-
}
|
|
3097
|
-
function getNodes(target, symbol) {
|
|
3098
|
-
let nodes = target[symbol];
|
|
3099
|
-
if (!nodes) Object.defineProperty(target, symbol, {
|
|
3100
|
-
value: nodes = /* @__PURE__ */ Object.create(null)
|
|
3101
|
-
});
|
|
3102
|
-
return nodes;
|
|
3103
|
-
}
|
|
3104
|
-
function getNode(nodes, property, value) {
|
|
3105
|
-
if (nodes[property]) return nodes[property];
|
|
3106
|
-
const [s, set] = createSignal(value, {
|
|
3107
|
-
equals: false,
|
|
3108
|
-
internal: true
|
|
3109
|
-
});
|
|
3110
|
-
s.$ = set;
|
|
3111
|
-
return nodes[property] = s;
|
|
3112
|
-
}
|
|
3113
|
-
function proxyDescriptor$1(target, property) {
|
|
3114
|
-
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
3115
|
-
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE) return desc;
|
|
3116
|
-
delete desc.value;
|
|
3117
|
-
delete desc.writable;
|
|
3118
|
-
desc.get = () => target[$PROXY][property];
|
|
3119
|
-
return desc;
|
|
3120
|
-
}
|
|
3121
|
-
function trackSelf(target) {
|
|
3122
|
-
getListener() && getNode(getNodes(target, $NODE), $SELF)();
|
|
3123
|
-
}
|
|
3124
|
-
function ownKeys(target) {
|
|
3125
|
-
trackSelf(target);
|
|
3126
|
-
return Reflect.ownKeys(target);
|
|
3127
|
-
}
|
|
3128
|
-
const proxyTraps$1 = {
|
|
3129
|
-
get(target, property, receiver) {
|
|
3130
|
-
if (property === $RAW) return target;
|
|
3131
|
-
if (property === $PROXY) return receiver;
|
|
3132
|
-
if (property === $TRACK) {
|
|
3133
|
-
trackSelf(target);
|
|
3134
|
-
return receiver;
|
|
3135
|
-
}
|
|
3136
|
-
const nodes = getNodes(target, $NODE);
|
|
3137
|
-
const tracked = nodes[property];
|
|
3138
|
-
let value = tracked ? tracked() : target[property];
|
|
3139
|
-
if (property === $NODE || property === $HAS || property === "__proto__") return value;
|
|
3140
|
-
if (!tracked) {
|
|
3141
|
-
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
3142
|
-
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
|
|
3143
|
-
}
|
|
3144
|
-
return isWrappable(value) ? wrap$1(value) : value;
|
|
3145
|
-
},
|
|
3146
|
-
has(target, property) {
|
|
3147
|
-
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
|
|
3148
|
-
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
3149
|
-
return property in target;
|
|
3150
|
-
},
|
|
3151
|
-
set() {
|
|
3152
|
-
return true;
|
|
3153
|
-
},
|
|
3154
|
-
deleteProperty() {
|
|
3155
|
-
return true;
|
|
3156
|
-
},
|
|
3157
|
-
ownKeys,
|
|
3158
|
-
getOwnPropertyDescriptor: proxyDescriptor$1
|
|
3159
|
-
};
|
|
3160
|
-
function setProperty(state, property, value, deleting = false) {
|
|
3161
|
-
if (!deleting && state[property] === value) return;
|
|
3162
|
-
const prev = state[property], len = state.length;
|
|
3163
|
-
if (value === void 0) {
|
|
3164
|
-
delete state[property];
|
|
3165
|
-
if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
|
|
3166
|
-
} else {
|
|
3167
|
-
state[property] = value;
|
|
3168
|
-
if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
|
|
3169
|
-
}
|
|
3170
|
-
let nodes = getNodes(state, $NODE), node;
|
|
3171
|
-
if (node = getNode(nodes, property, prev)) node.$(() => value);
|
|
3172
|
-
if (Array.isArray(state) && state.length !== len) {
|
|
3173
|
-
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
|
|
3174
|
-
(node = getNode(nodes, "length", len)) && node.$(state.length);
|
|
3175
|
-
}
|
|
3176
|
-
(node = nodes[$SELF]) && node.$();
|
|
3177
|
-
}
|
|
3178
|
-
function mergeStoreNode(state, value) {
|
|
3179
|
-
const keys = Object.keys(value);
|
|
3180
|
-
for (let i = 0; i < keys.length; i += 1) {
|
|
3181
|
-
const key = keys[i];
|
|
3182
|
-
setProperty(state, key, value[key]);
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
function updateArray(current, next) {
|
|
3186
|
-
if (typeof next === "function") next = next(current);
|
|
3187
|
-
next = unwrap(next);
|
|
3188
|
-
if (Array.isArray(next)) {
|
|
3189
|
-
if (current === next) return;
|
|
3190
|
-
let i = 0, len = next.length;
|
|
3191
|
-
for (; i < len; i++) {
|
|
3192
|
-
const value = next[i];
|
|
3193
|
-
if (current[i] !== value) setProperty(current, i, value);
|
|
3194
|
-
}
|
|
3195
|
-
setProperty(current, "length", len);
|
|
3196
|
-
} else mergeStoreNode(current, next);
|
|
3197
|
-
}
|
|
3198
|
-
function updatePath(current, path, traversed = []) {
|
|
3199
|
-
let part, prev = current;
|
|
3200
|
-
if (path.length > 1) {
|
|
3201
|
-
part = path.shift();
|
|
3202
|
-
const partType = typeof part, isArray = Array.isArray(current);
|
|
3203
|
-
if (Array.isArray(part)) {
|
|
3204
|
-
for (let i = 0; i < part.length; i++) {
|
|
3205
|
-
updatePath(current, [part[i]].concat(path), traversed);
|
|
3206
|
-
}
|
|
3207
|
-
return;
|
|
3208
|
-
} else if (isArray && partType === "function") {
|
|
3209
|
-
for (let i = 0; i < current.length; i++) {
|
|
3210
|
-
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
|
|
3211
|
-
}
|
|
3212
|
-
return;
|
|
3213
|
-
} else if (isArray && partType === "object") {
|
|
3214
|
-
const {
|
|
3215
|
-
from = 0,
|
|
3216
|
-
to = current.length - 1,
|
|
3217
|
-
by = 1
|
|
3218
|
-
} = part;
|
|
3219
|
-
for (let i = from; i <= to; i += by) {
|
|
3220
|
-
updatePath(current, [i].concat(path), traversed);
|
|
3221
|
-
}
|
|
3222
|
-
return;
|
|
3223
|
-
} else if (path.length > 1) {
|
|
3224
|
-
updatePath(current[part], path, [part].concat(traversed));
|
|
3225
|
-
return;
|
|
3226
|
-
}
|
|
3227
|
-
prev = current[part];
|
|
3228
|
-
traversed = [part].concat(traversed);
|
|
3229
|
-
}
|
|
3230
|
-
let value = path[0];
|
|
3231
|
-
if (typeof value === "function") {
|
|
3232
|
-
value = value(prev, traversed);
|
|
3233
|
-
if (value === prev) return;
|
|
3234
|
-
}
|
|
3235
|
-
if (part === void 0 && value == void 0) return;
|
|
3236
|
-
value = unwrap(value);
|
|
3237
|
-
if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
|
|
3238
|
-
mergeStoreNode(prev, value);
|
|
3239
|
-
} else setProperty(current, part, value);
|
|
3240
|
-
}
|
|
3241
|
-
function createStore(...[store, options]) {
|
|
3242
|
-
const unwrappedStore = unwrap(store || {});
|
|
3243
|
-
const isArray = Array.isArray(unwrappedStore);
|
|
3244
|
-
const wrappedStore = wrap$1(unwrappedStore);
|
|
3245
|
-
function setStore(...args) {
|
|
3246
|
-
batch(() => {
|
|
3247
|
-
isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
|
|
3248
|
-
});
|
|
3249
|
-
}
|
|
3250
|
-
return [wrappedStore, setStore];
|
|
3251
|
-
}
|
|
3252
|
-
const $ROOT = Symbol("store-root");
|
|
3253
|
-
function applyState(target, parent, property, merge, key) {
|
|
3254
|
-
const previous = parent[property];
|
|
3255
|
-
if (target === previous) return;
|
|
3256
|
-
const isArray = Array.isArray(target);
|
|
3257
|
-
if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
|
|
3258
|
-
setProperty(parent, property, target);
|
|
3259
|
-
return;
|
|
3260
|
-
}
|
|
3261
|
-
if (isArray) {
|
|
3262
|
-
if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
|
|
3263
|
-
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
3264
|
-
for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start] && target[start] && previous[start][key] && previous[start][key] === target[start][key]); start++) {
|
|
3265
|
-
applyState(target[start], previous, start, merge, key);
|
|
3266
|
-
}
|
|
3267
|
-
const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
|
|
3268
|
-
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[end] && target[newEnd] && previous[end][key] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
3269
|
-
temp[newEnd] = previous[end];
|
|
3270
|
-
}
|
|
3271
|
-
if (start > newEnd || start > end) {
|
|
3272
|
-
for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);
|
|
3273
|
-
for (; j < target.length; j++) {
|
|
3274
|
-
setProperty(previous, j, temp[j]);
|
|
3275
|
-
applyState(target[j], previous, j, merge, key);
|
|
3276
|
-
}
|
|
3277
|
-
if (previous.length > target.length) setProperty(previous, "length", target.length);
|
|
3278
|
-
return;
|
|
3279
|
-
}
|
|
3280
|
-
newIndicesNext = new Array(newEnd + 1);
|
|
3281
|
-
for (j = newEnd; j >= start; j--) {
|
|
3282
|
-
item = target[j];
|
|
3283
|
-
keyVal = key && item ? item[key] : item;
|
|
3284
|
-
i = newIndices.get(keyVal);
|
|
3285
|
-
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
3286
|
-
newIndices.set(keyVal, j);
|
|
3287
|
-
}
|
|
3288
|
-
for (i = start; i <= end; i++) {
|
|
3289
|
-
item = previous[i];
|
|
3290
|
-
keyVal = key && item ? item[key] : item;
|
|
3291
|
-
j = newIndices.get(keyVal);
|
|
3292
|
-
if (j !== void 0 && j !== -1) {
|
|
3293
|
-
temp[j] = previous[i];
|
|
3294
|
-
j = newIndicesNext[j];
|
|
3295
|
-
newIndices.set(keyVal, j);
|
|
3296
|
-
}
|
|
3297
|
-
}
|
|
3298
|
-
for (j = start; j < target.length; j++) {
|
|
3299
|
-
if (j in temp) {
|
|
3300
|
-
setProperty(previous, j, temp[j]);
|
|
3301
|
-
applyState(target[j], previous, j, merge, key);
|
|
3302
|
-
} else setProperty(previous, j, target[j]);
|
|
3303
|
-
}
|
|
3304
|
-
} else {
|
|
3305
|
-
for (let i = 0, len = target.length; i < len; i++) {
|
|
3306
|
-
applyState(target[i], previous, i, merge, key);
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
if (previous.length > target.length) setProperty(previous, "length", target.length);
|
|
3310
|
-
return;
|
|
3311
|
-
}
|
|
3312
|
-
const targetKeys = Object.keys(target);
|
|
3313
|
-
for (let i = 0, len = targetKeys.length; i < len; i++) {
|
|
3314
|
-
applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
|
|
3315
|
-
}
|
|
3316
|
-
const previousKeys = Object.keys(previous);
|
|
3317
|
-
for (let i = 0, len = previousKeys.length; i < len; i++) {
|
|
3318
|
-
if (target[previousKeys[i]] === void 0) setProperty(previous, previousKeys[i], void 0);
|
|
3319
|
-
}
|
|
3320
|
-
}
|
|
3321
|
-
function reconcile(value, options = {}) {
|
|
3322
|
-
const {
|
|
3323
|
-
merge,
|
|
3324
|
-
key = "id"
|
|
3325
|
-
} = options, v = unwrap(value);
|
|
3326
|
-
return (state) => {
|
|
3327
|
-
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
3328
|
-
const res = applyState(v, {
|
|
3329
|
-
[$ROOT]: state
|
|
3330
|
-
}, $ROOT, merge, key);
|
|
3331
|
-
return res === void 0 ? state : res;
|
|
3332
|
-
};
|
|
3333
|
-
}
|
|
3334
2789
|
function createEditorNodeId(kind) {
|
|
3335
2790
|
return `${kind}:${crypto.randomUUID()}`;
|
|
3336
2791
|
}
|
|
@@ -4707,217 +4162,1145 @@ function resolveEffectiveTableCellFormatting(options) {
|
|
|
4707
4162
|
...named.textStyle ?? {},
|
|
4708
4163
|
...conditional.textStyle ?? {}
|
|
4709
4164
|
},
|
|
4710
|
-
conditionalKeys: keys
|
|
4165
|
+
conditionalKeys: keys
|
|
4166
|
+
};
|
|
4167
|
+
}
|
|
4168
|
+
function withDefaultTableStyles(styles) {
|
|
4169
|
+
const defaults = Object.fromEntries(
|
|
4170
|
+
Object.entries(DEFAULT_TABLE_STYLES).filter(([id]) => !(id in styles))
|
|
4171
|
+
);
|
|
4172
|
+
return { ...styles, ...defaults };
|
|
4173
|
+
}
|
|
4174
|
+
function createEditorDocument(blocks, pageSettings, sections, styles, metadata, assets) {
|
|
4175
|
+
const normalizedPageSettings = normalizePageSettings(
|
|
4176
|
+
pageSettings ? {
|
|
4177
|
+
width: pageSettings.width,
|
|
4178
|
+
height: pageSettings.height,
|
|
4179
|
+
orientation: pageSettings.orientation,
|
|
4180
|
+
margins: { ...pageSettings.margins },
|
|
4181
|
+
...pageSettings.columns ? { columns: pageSettings.columns } : {}
|
|
4182
|
+
} : {
|
|
4183
|
+
width: DEFAULT_EDITOR_PAGE_SETTINGS.width,
|
|
4184
|
+
height: DEFAULT_EDITOR_PAGE_SETTINGS.height,
|
|
4185
|
+
orientation: DEFAULT_EDITOR_PAGE_SETTINGS.orientation,
|
|
4186
|
+
margins: { ...DEFAULT_EDITOR_PAGE_SETTINGS.margins }
|
|
4187
|
+
}
|
|
4188
|
+
);
|
|
4189
|
+
const document2 = {
|
|
4190
|
+
schemaVersion: 1,
|
|
4191
|
+
id: createEditorNodeId("document"),
|
|
4192
|
+
pageSettings: normalizedPageSettings,
|
|
4193
|
+
sections: sections ?? [
|
|
4194
|
+
{
|
|
4195
|
+
id: "section:default",
|
|
4196
|
+
blocks,
|
|
4197
|
+
pageSettings: normalizedPageSettings
|
|
4198
|
+
}
|
|
4199
|
+
],
|
|
4200
|
+
styles: styles ? withDefaultTableStyles(styles) : { ...DEFAULT_EDITOR_STYLES },
|
|
4201
|
+
metadata: metadata ?? { title: "Untitled document" },
|
|
4202
|
+
// The asset registry holds out-of-band image payloads (data URLs).
|
|
4203
|
+
// It must be carried through any document-rebuild path or `asset:<id>`
|
|
4204
|
+
// refs in image runs will dangle and the renderer will try to GET
|
|
4205
|
+
// "asset:img-1" as a URL.
|
|
4206
|
+
assets: assets ?? void 0
|
|
4207
|
+
};
|
|
4208
|
+
return document2;
|
|
4209
|
+
}
|
|
4210
|
+
function getDocumentCharacterCount(document2) {
|
|
4211
|
+
return getDocumentParagraphsCanonical(document2).reduce(
|
|
4212
|
+
(sum, p) => sum + getParagraphLength(p),
|
|
4213
|
+
0
|
|
4214
|
+
);
|
|
4215
|
+
}
|
|
4216
|
+
function getDocumentWordCount(document2) {
|
|
4217
|
+
const paragraphs = getDocumentParagraphsCanonical(document2);
|
|
4218
|
+
let totalWords = 0;
|
|
4219
|
+
for (const paragraph of paragraphs) {
|
|
4220
|
+
const text = paragraph.runs.reduce(
|
|
4221
|
+
(sum, run) => sum + run.text,
|
|
4222
|
+
""
|
|
4223
|
+
);
|
|
4224
|
+
if (!text.trim()) continue;
|
|
4225
|
+
const words = text.split(/[\s\p{P}]+/u).filter((word) => word.length > 0);
|
|
4226
|
+
totalWords += words.length;
|
|
4227
|
+
}
|
|
4228
|
+
return totalWords;
|
|
4229
|
+
}
|
|
4230
|
+
function findParagraphIndex(paragraphs, paragraphId) {
|
|
4231
|
+
const index = paragraphs.findIndex(
|
|
4232
|
+
(paragraph) => paragraph.id === paragraphId
|
|
4233
|
+
);
|
|
4234
|
+
return index === -1 ? 0 : index;
|
|
4235
|
+
}
|
|
4236
|
+
function findParagraphById(paragraphs, paragraphId) {
|
|
4237
|
+
return paragraphs[findParagraphIndex(paragraphs, paragraphId)];
|
|
4238
|
+
}
|
|
4239
|
+
function clampOffset(offset, paragraph) {
|
|
4240
|
+
return Math.max(0, Math.min(offset, getParagraphLength(paragraph)));
|
|
4241
|
+
}
|
|
4242
|
+
function clampPosition(state, position2) {
|
|
4243
|
+
const paragraphs = getParagraphs(state);
|
|
4244
|
+
const paragraph = findParagraphById(paragraphs, position2.paragraphId);
|
|
4245
|
+
return clampPositionInParagraph(position2, paragraph);
|
|
4246
|
+
}
|
|
4247
|
+
function clampPositionInParagraph(position2, paragraph) {
|
|
4248
|
+
const paragraphOffset = positionToParagraphOffset(paragraph, position2);
|
|
4249
|
+
return paragraphOffsetToPosition(
|
|
4250
|
+
paragraph,
|
|
4251
|
+
clampOffset(paragraphOffset, paragraph)
|
|
4252
|
+
);
|
|
4253
|
+
}
|
|
4254
|
+
function createCollapsedSelection(position2) {
|
|
4255
|
+
return {
|
|
4256
|
+
anchor: position2,
|
|
4257
|
+
focus: position2
|
|
4258
|
+
};
|
|
4259
|
+
}
|
|
4260
|
+
function isSelectionCollapsed(selection) {
|
|
4261
|
+
return selection.anchor.paragraphId === selection.focus.paragraphId && selection.anchor.runId === selection.focus.runId && selection.anchor.offset === selection.focus.offset;
|
|
4262
|
+
}
|
|
4263
|
+
function normalizeSelection(state, providedParagraphs) {
|
|
4264
|
+
const paragraphs = providedParagraphs ?? getParagraphs(state);
|
|
4265
|
+
const indexById = new Map(
|
|
4266
|
+
paragraphs.map(
|
|
4267
|
+
(paragraph, index) => [paragraph.id, index]
|
|
4268
|
+
)
|
|
4269
|
+
);
|
|
4270
|
+
const rawAnchorIndex = indexById.get(state.selection.anchor.paragraphId) ?? 0;
|
|
4271
|
+
const rawFocusIndex = indexById.get(state.selection.focus.paragraphId) ?? 0;
|
|
4272
|
+
const anchorParagraph = paragraphs[rawAnchorIndex] ?? paragraphs[0];
|
|
4273
|
+
const focusParagraph = paragraphs[rawFocusIndex] ?? paragraphs[0];
|
|
4274
|
+
const anchor = clampPositionInParagraph(
|
|
4275
|
+
state.selection.anchor,
|
|
4276
|
+
anchorParagraph
|
|
4277
|
+
);
|
|
4278
|
+
const focus = clampPositionInParagraph(state.selection.focus, focusParagraph);
|
|
4279
|
+
const anchorIndex = indexById.get(anchor.paragraphId) ?? rawAnchorIndex;
|
|
4280
|
+
const focusIndex = indexById.get(focus.paragraphId) ?? rawFocusIndex;
|
|
4281
|
+
const comparison = anchorIndex !== focusIndex ? anchorIndex - focusIndex : positionToParagraphOffset(paragraphs[anchorIndex], anchor) - positionToParagraphOffset(paragraphs[focusIndex], focus);
|
|
4282
|
+
const start = comparison <= 0 ? anchor : focus;
|
|
4283
|
+
const end = comparison <= 0 ? focus : anchor;
|
|
4284
|
+
const startParagraph = paragraphs[comparison <= 0 ? anchorIndex : focusIndex];
|
|
4285
|
+
const endParagraph = paragraphs[comparison <= 0 ? focusIndex : anchorIndex];
|
|
4286
|
+
return {
|
|
4287
|
+
start,
|
|
4288
|
+
end,
|
|
4289
|
+
startIndex: comparison <= 0 ? anchorIndex : focusIndex,
|
|
4290
|
+
endIndex: comparison <= 0 ? focusIndex : anchorIndex,
|
|
4291
|
+
startParagraphOffset: positionToParagraphOffset(startParagraph, start),
|
|
4292
|
+
endParagraphOffset: positionToParagraphOffset(endParagraph, end),
|
|
4293
|
+
isCollapsed: comparison === 0
|
|
4294
|
+
};
|
|
4295
|
+
}
|
|
4296
|
+
function createEditorStateFromDocument(document2, selection) {
|
|
4297
|
+
var _a2, _b2, _c;
|
|
4298
|
+
let normalizedDocument = {
|
|
4299
|
+
...document2,
|
|
4300
|
+
sections: document2.sections && document2.sections.length > 0 ? document2.sections : [
|
|
4301
|
+
{
|
|
4302
|
+
id: "section:default",
|
|
4303
|
+
blocks: [createEditorParagraph("")],
|
|
4304
|
+
pageSettings: ((_a2 = getDocumentSectionsCanonical(document2)[0]) == null ? void 0 : _a2.pageSettings) ?? DEFAULT_EDITOR_PAGE_SETTINGS
|
|
4305
|
+
}
|
|
4306
|
+
]
|
|
4307
|
+
};
|
|
4308
|
+
let allParagraphs = getDocumentParagraphsCanonical(normalizedDocument);
|
|
4309
|
+
if (allParagraphs.length === 0) {
|
|
4310
|
+
const fallbackParagraph = createEditorParagraph("");
|
|
4311
|
+
const sections = getDocumentSectionsCanonical(normalizedDocument);
|
|
4312
|
+
const firstSection = sections[0];
|
|
4313
|
+
if (firstSection) {
|
|
4314
|
+
const nextSections = [...sections];
|
|
4315
|
+
nextSections[0] = {
|
|
4316
|
+
...firstSection,
|
|
4317
|
+
blocks: [fallbackParagraph, ...firstSection.blocks]
|
|
4318
|
+
};
|
|
4319
|
+
normalizedDocument = {
|
|
4320
|
+
...normalizedDocument,
|
|
4321
|
+
sections: nextSections
|
|
4322
|
+
};
|
|
4323
|
+
}
|
|
4324
|
+
allParagraphs = getDocumentParagraphsCanonical(normalizedDocument);
|
|
4325
|
+
}
|
|
4326
|
+
let targetParagraph = allParagraphs[0];
|
|
4327
|
+
let activeSectionIndex = 0;
|
|
4328
|
+
let activeZone = "main";
|
|
4329
|
+
{
|
|
4330
|
+
const sections = getDocumentSectionsCanonical(normalizedDocument);
|
|
4331
|
+
const firstSection = sections[0];
|
|
4332
|
+
const mainParagraphs = (firstSection == null ? void 0 : firstSection.blocks.flatMap(getBlockParagraphs)) ?? [];
|
|
4333
|
+
if (mainParagraphs.length > 0) {
|
|
4334
|
+
targetParagraph = mainParagraphs[0];
|
|
4335
|
+
activeZone = "main";
|
|
4336
|
+
activeSectionIndex = 0;
|
|
4337
|
+
} else {
|
|
4338
|
+
const headerParagraphs = ((_b2 = firstSection == null ? void 0 : firstSection.header) == null ? void 0 : _b2.flatMap(getBlockParagraphs)) ?? [];
|
|
4339
|
+
const footerParagraphs = ((_c = firstSection == null ? void 0 : firstSection.footer) == null ? void 0 : _c.flatMap(getBlockParagraphs)) ?? [];
|
|
4340
|
+
if (headerParagraphs.length > 0) {
|
|
4341
|
+
targetParagraph = headerParagraphs[0];
|
|
4342
|
+
activeZone = "header";
|
|
4343
|
+
} else if (footerParagraphs.length > 0) {
|
|
4344
|
+
targetParagraph = footerParagraphs[0];
|
|
4345
|
+
activeZone = "footer";
|
|
4346
|
+
}
|
|
4347
|
+
activeSectionIndex = 0;
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
const position2 = paragraphOffsetToPosition(
|
|
4351
|
+
targetParagraph,
|
|
4352
|
+
Math.max(
|
|
4353
|
+
0,
|
|
4354
|
+
Math.min(0, getParagraphLength(targetParagraph))
|
|
4355
|
+
)
|
|
4356
|
+
);
|
|
4357
|
+
const result = {
|
|
4358
|
+
document: normalizedDocument,
|
|
4359
|
+
selection: createCollapsedSelection(position2),
|
|
4360
|
+
activeSectionIndex,
|
|
4361
|
+
activeZone
|
|
4362
|
+
};
|
|
4363
|
+
return result;
|
|
4364
|
+
}
|
|
4365
|
+
function createInitialEditorState() {
|
|
4366
|
+
const paragraph = createEditorParagraph("");
|
|
4367
|
+
const run = paragraph.runs[0];
|
|
4368
|
+
return {
|
|
4369
|
+
document: createEditorDocument([paragraph]),
|
|
4370
|
+
selection: createCollapsedSelection({
|
|
4371
|
+
paragraphId: paragraph.id,
|
|
4372
|
+
runId: run.id,
|
|
4373
|
+
offset: 0
|
|
4374
|
+
}),
|
|
4375
|
+
activeSectionIndex: 0,
|
|
4376
|
+
activeZone: "main"
|
|
4377
|
+
};
|
|
4378
|
+
}
|
|
4379
|
+
const EDITOR_SCHEMA_VERSION = 1;
|
|
4380
|
+
function cloneDocument(document2) {
|
|
4381
|
+
return structuredClone(document2);
|
|
4382
|
+
}
|
|
4383
|
+
function normalizeDocument(document2) {
|
|
4384
|
+
var _a2;
|
|
4385
|
+
const next = cloneDocument(document2);
|
|
4386
|
+
next.schemaVersion = next.schemaVersion ?? EDITOR_SCHEMA_VERSION;
|
|
4387
|
+
if (!((_a2 = next.sections) == null ? void 0 : _a2.length)) {
|
|
4388
|
+
next.sections = getDocumentSectionsCanonical(next);
|
|
4389
|
+
}
|
|
4390
|
+
return next;
|
|
4391
|
+
}
|
|
4392
|
+
function validateDocument(document2) {
|
|
4393
|
+
var _a2, _b2;
|
|
4394
|
+
const errors2 = [];
|
|
4395
|
+
if (!document2 || !document2.id || !((_a2 = document2.sections) == null ? void 0 : _a2.length)) errors2.push("Document must have an id and section");
|
|
4396
|
+
const ids = /* @__PURE__ */ new Set();
|
|
4397
|
+
for (const paragraph of getDocumentParagraphsCanonical(document2)) {
|
|
4398
|
+
if (ids.has(paragraph.id)) errors2.push(`Duplicate node id: ${paragraph.id}`);
|
|
4399
|
+
ids.add(paragraph.id);
|
|
4400
|
+
if (!((_b2 = paragraph.runs) == null ? void 0 : _b2.length)) errors2.push(`Paragraph has no runs: ${paragraph.id}`);
|
|
4401
|
+
for (const run of paragraph.runs) {
|
|
4402
|
+
if (ids.has(run.id)) errors2.push(`Duplicate node id: ${run.id}`);
|
|
4403
|
+
ids.add(run.id);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
return errors2.length ? { ok: false, error: { code: "VALIDATION_FAILED", message: errors2.join("; "), details: errors2 } } : { ok: true, value: true, version: 0, warnings: [] };
|
|
4407
|
+
}
|
|
4408
|
+
function createDocument(options = {}) {
|
|
4409
|
+
return createEditorDocument(options.blocks ?? [createEditorParagraph("")], void 0, void 0, void 0, {
|
|
4410
|
+
title: options.title ?? "Untitled document"
|
|
4411
|
+
});
|
|
4412
|
+
}
|
|
4413
|
+
const createParagraph = createEditorParagraph;
|
|
4414
|
+
function createHeading(text, options = {}) {
|
|
4415
|
+
const paragraph = createEditorParagraph(text);
|
|
4416
|
+
paragraph.style = { styleId: `heading${options.level ?? 1}` };
|
|
4417
|
+
return paragraph;
|
|
4418
|
+
}
|
|
4419
|
+
function createTable(rows) {
|
|
4420
|
+
return createEditorTable(rows.map((row) => createEditorTableRow(row.map((text) => createEditorTableCell([createEditorParagraph(text)])))));
|
|
4421
|
+
}
|
|
4422
|
+
function allNodes(document2) {
|
|
4423
|
+
const result = [{ id: document2.id, type: "document", node: document2 }];
|
|
4424
|
+
const visitBlocks = (blocks) => blocks.forEach((block) => {
|
|
4425
|
+
result.push({ id: block.id, type: block.type, text: block.type === "paragraph" ? getParagraphText(block) : void 0, node: block });
|
|
4426
|
+
if (block.type === "paragraph") block.runs.forEach((run) => result.push({ id: run.id, type: "run", text: run.text, node: run }));
|
|
4427
|
+
else block.rows.forEach((row) => {
|
|
4428
|
+
result.push({ id: row.id, type: "table-row", node: row });
|
|
4429
|
+
row.cells.forEach((cell) => {
|
|
4430
|
+
result.push({ id: cell.id, type: "table-cell", node: cell });
|
|
4431
|
+
visitBlocks(cell.blocks);
|
|
4432
|
+
});
|
|
4433
|
+
});
|
|
4434
|
+
});
|
|
4435
|
+
getDocumentSectionsCanonical(document2).forEach(
|
|
4436
|
+
(section) => visitBlocks(section.blocks)
|
|
4437
|
+
);
|
|
4438
|
+
return result;
|
|
4439
|
+
}
|
|
4440
|
+
function resolveParagraph(document2, selector) {
|
|
4441
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4442
|
+
const paragraphs = getDocumentParagraphsCanonical(document2);
|
|
4443
|
+
if ("nodeId" in selector) return paragraphs.find((p) => p.id === selector.nodeId) ?? null;
|
|
4444
|
+
if ("text" in selector) {
|
|
4445
|
+
const found = paragraphs.filter((p) => getParagraphText(p).includes(selector.text));
|
|
4446
|
+
const index = selector.occurrence ?? 0;
|
|
4447
|
+
if (found.length !== 1 && selector.occurrence === void 0) throw new Error(found.length > 1 ? "AMBIGUOUS_SELECTOR" : "NODE_NOT_FOUND");
|
|
4448
|
+
return found[index] ?? null;
|
|
4449
|
+
}
|
|
4450
|
+
if ("headingPath" in selector) {
|
|
4451
|
+
const index = selector.headingPath.length ? selector.headingPath.length - 1 : 0;
|
|
4452
|
+
return paragraphs.filter((p) => {
|
|
4453
|
+
var _a3, _b3;
|
|
4454
|
+
return (_b3 = (_a3 = p.style) == null ? void 0 : _a3.styleId) == null ? void 0 : _b3.startsWith("heading");
|
|
4455
|
+
})[index] ?? null;
|
|
4456
|
+
}
|
|
4457
|
+
if ("bookmark" in selector) {
|
|
4458
|
+
const bookmark = ((_a2 = document2.bookmarks) == null ? void 0 : _a2.items[selector.bookmark]) ?? Object.values(((_b2 = document2.bookmarks) == null ? void 0 : _b2.items) ?? {}).find((item) => item.name === selector.bookmark);
|
|
4459
|
+
const paragraphId = (_c = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _c.paragraphId;
|
|
4460
|
+
return paragraphId ? paragraphs.find((p) => p.id === paragraphId) ?? null : null;
|
|
4461
|
+
}
|
|
4462
|
+
if ("contentControlTag" in selector) {
|
|
4463
|
+
const tagged = paragraphs.find((p) => {
|
|
4464
|
+
var _a3;
|
|
4465
|
+
return (_a3 = p.sdtWrappers) == null ? void 0 : _a3.some((wrapper) => wrapper.sdtPr.tag === selector.contentControlTag || wrapper.sdtPr.alias === selector.contentControlTag);
|
|
4466
|
+
});
|
|
4467
|
+
if (tagged) return tagged;
|
|
4468
|
+
const taggedTable = allNodes(document2).find((node) => {
|
|
4469
|
+
var _a3;
|
|
4470
|
+
return node.type === "table" && ((_a3 = node.node.sdtWrappers) == null ? void 0 : _a3.some((wrapper) => {
|
|
4471
|
+
var _a4, _b3;
|
|
4472
|
+
return ((_a4 = wrapper.sdtPr) == null ? void 0 : _a4.tag) === selector.contentControlTag || ((_b3 = wrapper.sdtPr) == null ? void 0 : _b3.alias) === selector.contentControlTag;
|
|
4473
|
+
}));
|
|
4474
|
+
});
|
|
4475
|
+
const firstCellParagraph = (_i = (_h = (_g = (_f = (_e = (_d = taggedTable == null ? void 0 : taggedTable.node) == null ? void 0 : _d.rows) == null ? void 0 : _e[0]) == null ? void 0 : _f.cells) == null ? void 0 : _g[0]) == null ? void 0 : _h.blocks) == null ? void 0 : _i.find((block) => block.type === "paragraph");
|
|
4476
|
+
return firstCellParagraph ?? null;
|
|
4477
|
+
}
|
|
4478
|
+
if ("tableId" in selector) {
|
|
4479
|
+
const table = (_j = allNodes(document2).find((n2) => n2.id === selector.tableId && n2.type === "table")) == null ? void 0 : _j.node;
|
|
4480
|
+
return ((_l = (_k = table == null ? void 0 : table.rows[selector.row]) == null ? void 0 : _k.cells[selector.column]) == null ? void 0 : _l.blocks.find((b) => b.type === "paragraph")) ?? null;
|
|
4481
|
+
}
|
|
4482
|
+
return null;
|
|
4483
|
+
}
|
|
4484
|
+
function replaceParagraph(document2, id, update) {
|
|
4485
|
+
const visit = (blocks) => {
|
|
4486
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
4487
|
+
const block = blocks[i];
|
|
4488
|
+
if (block.type === "paragraph" && block.id === id) {
|
|
4489
|
+
blocks[i] = update(block);
|
|
4490
|
+
return true;
|
|
4491
|
+
}
|
|
4492
|
+
if (block.type === "table" && block.rows.some((r) => r.cells.some((c) => visit(c.blocks)))) return true;
|
|
4493
|
+
}
|
|
4494
|
+
return false;
|
|
4495
|
+
};
|
|
4496
|
+
getDocumentSectionsCanonical(document2).some((section) => visit(section.blocks));
|
|
4497
|
+
}
|
|
4498
|
+
function queryDocument(document2) {
|
|
4499
|
+
const outline = () => getDocumentParagraphsCanonical(document2).flatMap((p) => {
|
|
4500
|
+
var _a2, _b2;
|
|
4501
|
+
const match = (_b2 = (_a2 = p.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.match(/^heading(\d+)$/);
|
|
4502
|
+
return match ? [{ id: p.id, level: Number(match[1]), text: getParagraphText(p), path: [getParagraphText(p)] }] : [];
|
|
4503
|
+
});
|
|
4504
|
+
return {
|
|
4505
|
+
snapshot: () => ({ schemaVersion: document2.schemaVersion ?? EDITOR_SCHEMA_VERSION, documentId: document2.id, text: getDocumentParagraphsCanonical(document2).map(getParagraphText).join("\n"), outline: outline(), nodes: allNodes(document2) }),
|
|
4506
|
+
getText: (target) => {
|
|
4507
|
+
var _a2;
|
|
4508
|
+
if (!target) return getDocumentParagraphsCanonical(document2).map(getParagraphText).join("\n");
|
|
4509
|
+
if ("start" in target) return ((_a2 = getDocumentParagraphsCanonical(document2).find((p) => p.id === target.start.paragraphId)) == null ? void 0 : _a2.runs.map((r) => r.text).join("")) ?? "";
|
|
4510
|
+
return getParagraphText(resolveParagraph(document2, target) ?? createEditorParagraph(""));
|
|
4511
|
+
},
|
|
4512
|
+
getNode: (selector) => {
|
|
4513
|
+
const paragraph = resolveParagraph(document2, selector);
|
|
4514
|
+
return paragraph ? { id: paragraph.id, type: "paragraph", text: getParagraphText(paragraph), node: paragraph } : allNodes(document2).find((n2) => "nodeId" in selector && n2.id === selector.nodeId) ?? null;
|
|
4515
|
+
},
|
|
4516
|
+
find: (text) => getDocumentParagraphsCanonical(document2).flatMap((p) => {
|
|
4517
|
+
const value = getParagraphText(p);
|
|
4518
|
+
const matches = [];
|
|
4519
|
+
let start = value.indexOf(text);
|
|
4520
|
+
while (start >= 0) {
|
|
4521
|
+
matches.push({ selector: { nodeId: p.id }, paragraphId: p.id, text, start, end: start + text.length });
|
|
4522
|
+
start = value.indexOf(text, start + Math.max(1, text.length));
|
|
4523
|
+
}
|
|
4524
|
+
return matches;
|
|
4525
|
+
}),
|
|
4526
|
+
outline
|
|
4527
|
+
};
|
|
4528
|
+
}
|
|
4529
|
+
function applyDocumentOperations(document2, operations) {
|
|
4530
|
+
var _a2, _b2, _c, _d;
|
|
4531
|
+
const next = normalizeDocument(document2);
|
|
4532
|
+
const changedNodeIds = [];
|
|
4533
|
+
const createdNodeIds = [];
|
|
4534
|
+
const sections = next.sections;
|
|
4535
|
+
for (const operation of operations) {
|
|
4536
|
+
if (operation.op === "insertText" || operation.op === "replaceText") {
|
|
4537
|
+
const paragraph = resolveParagraph(next, operation.target);
|
|
4538
|
+
if (!paragraph) throw new Error("NODE_NOT_FOUND");
|
|
4539
|
+
const old = getParagraphText(paragraph);
|
|
4540
|
+
const offset = operation.op === "replaceText" ? 0 : Math.min(operation.offset ?? old.length, old.length);
|
|
4541
|
+
const text = operation.op === "replaceText" ? operation.text : old.slice(0, offset) + operation.text + old.slice(offset);
|
|
4542
|
+
replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text }] }));
|
|
4543
|
+
changedNodeIds.push(paragraph.id);
|
|
4544
|
+
} else if (operation.op === "deleteRange") {
|
|
4545
|
+
if (operation.range.start.paragraphId !== operation.range.end.paragraphId) throw new Error("INVALID_RANGE");
|
|
4546
|
+
const paragraph = getDocumentParagraphsCanonical(next).find((p) => p.id === operation.range.start.paragraphId);
|
|
4547
|
+
if (!paragraph) throw new Error("NODE_NOT_FOUND");
|
|
4548
|
+
const text = getParagraphText(paragraph);
|
|
4549
|
+
const start = Math.max(0, Math.min(operation.range.start.offset, text.length));
|
|
4550
|
+
const end = Math.max(start, Math.min(operation.range.end.offset, text.length));
|
|
4551
|
+
replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text: text.slice(0, start) + text.slice(end) }] }));
|
|
4552
|
+
changedNodeIds.push(paragraph.id);
|
|
4553
|
+
} else if (operation.op === "setParagraphStyle") {
|
|
4554
|
+
const paragraph = resolveParagraph(next, operation.target);
|
|
4555
|
+
if (!paragraph) throw new Error("NODE_NOT_FOUND");
|
|
4556
|
+
replaceParagraph(next, paragraph.id, (p) => ({ ...p, style: operation.style }));
|
|
4557
|
+
changedNodeIds.push(paragraph.id);
|
|
4558
|
+
} else if (operation.op === "setTextStyle") {
|
|
4559
|
+
const paragraph = resolveParagraph(next, operation.target);
|
|
4560
|
+
if (!paragraph) throw new Error("NODE_NOT_FOUND");
|
|
4561
|
+
replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: p.runs.map((r) => ({ ...r, styles: { ...r.styles, ...operation.style } })) }));
|
|
4562
|
+
changedNodeIds.push(paragraph.id);
|
|
4563
|
+
} else if (operation.op === "insertParagraph" || operation.op === "insertBlocks" || operation.op === "insertTable") {
|
|
4564
|
+
const blocks = operation.op === "insertParagraph" ? [createEditorParagraph(operation.text ?? "")] : operation.op === "insertTable" ? [createTable(operation.rows)] : operation.blocks;
|
|
4565
|
+
sections[0].blocks.push(...blocks);
|
|
4566
|
+
blocks.forEach((b) => {
|
|
4567
|
+
createdNodeIds.push(b.id);
|
|
4568
|
+
changedNodeIds.push(b.id);
|
|
4569
|
+
});
|
|
4570
|
+
} else if (operation.op === "updateTableCell") {
|
|
4571
|
+
const table = (_a2 = allNodes(next).find((n2) => n2.id === operation.target.tableId && n2.type === "table")) == null ? void 0 : _a2.node;
|
|
4572
|
+
const paragraph = (_c = (_b2 = table == null ? void 0 : table.rows[operation.target.row]) == null ? void 0 : _b2.cells[operation.target.column]) == null ? void 0 : _c.blocks.find((b) => b.type === "paragraph");
|
|
4573
|
+
if (!paragraph) throw new Error("NODE_NOT_FOUND");
|
|
4574
|
+
replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text: operation.text }] }));
|
|
4575
|
+
changedNodeIds.push(paragraph.id, operation.target.tableId);
|
|
4576
|
+
} else if (operation.op === "deleteNode") {
|
|
4577
|
+
const target = "nodeId" in operation.target ? operation.target.nodeId : (_d = resolveParagraph(next, operation.target)) == null ? void 0 : _d.id;
|
|
4578
|
+
if (!target) throw new Error("NODE_NOT_FOUND");
|
|
4579
|
+
const remove = (blocks) => {
|
|
4580
|
+
const index = blocks.findIndex((b) => b.id === target);
|
|
4581
|
+
if (index >= 0) {
|
|
4582
|
+
blocks.splice(index, 1);
|
|
4583
|
+
return true;
|
|
4584
|
+
}
|
|
4585
|
+
return blocks.some((b) => b.type === "table" && b.rows.some((r) => r.cells.some((c) => remove(c.blocks))));
|
|
4586
|
+
};
|
|
4587
|
+
if (!sections.some((section) => remove(section.blocks))) throw new Error("NODE_NOT_FOUND");
|
|
4588
|
+
changedNodeIds.push(target);
|
|
4589
|
+
} else throw new Error("UNSUPPORTED_OPERATION");
|
|
4590
|
+
}
|
|
4591
|
+
const validation = validateDocument(next);
|
|
4592
|
+
if (!validation.ok) throw new Error("VALIDATION_FAILED");
|
|
4593
|
+
return { document: next, value: { changedNodeIds: [...new Set(changedNodeIds)], createdNodeIds } };
|
|
4594
|
+
}
|
|
4595
|
+
function disabledCommandState() {
|
|
4596
|
+
return { isEnabled: false, isActive: false, value: void 0 };
|
|
4597
|
+
}
|
|
4598
|
+
function createOasisEditorClient() {
|
|
4599
|
+
let host = null;
|
|
4600
|
+
let resolveReady;
|
|
4601
|
+
let rejectReady;
|
|
4602
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
4603
|
+
let disposed = false;
|
|
4604
|
+
let disposeHost;
|
|
4605
|
+
let dirty = false;
|
|
4606
|
+
let version2 = 0;
|
|
4607
|
+
const idempotent = /* @__PURE__ */ new Map();
|
|
4608
|
+
const ready = new Promise((resolve, reject) => {
|
|
4609
|
+
resolveReady = resolve;
|
|
4610
|
+
rejectReady = reject;
|
|
4611
|
+
});
|
|
4612
|
+
const emit = (event, payload) => {
|
|
4613
|
+
if (event === "change") {
|
|
4614
|
+
dirty = true;
|
|
4615
|
+
}
|
|
4616
|
+
const handlers = listeners.get(event);
|
|
4617
|
+
if (!handlers) return;
|
|
4618
|
+
for (const handler of [...handlers]) {
|
|
4619
|
+
handler(payload);
|
|
4620
|
+
}
|
|
4621
|
+
};
|
|
4622
|
+
const addListener = (event, callback) => {
|
|
4623
|
+
const handlers = listeners.get(event) ?? /* @__PURE__ */ new Set();
|
|
4624
|
+
handlers.add(
|
|
4625
|
+
callback
|
|
4626
|
+
);
|
|
4627
|
+
listeners.set(event, handlers);
|
|
4628
|
+
return () => {
|
|
4629
|
+
handlers.delete(
|
|
4630
|
+
callback
|
|
4631
|
+
);
|
|
4632
|
+
if (handlers.size === 0) listeners.delete(event);
|
|
4633
|
+
};
|
|
4634
|
+
};
|
|
4635
|
+
const getRuntimeEditor = () => (host == null ? void 0 : host.getRuntimeEditor()) ?? null;
|
|
4636
|
+
const requireHost = () => {
|
|
4637
|
+
if (!host) throw new Error("Oasis editor client is not mounted.");
|
|
4638
|
+
return host;
|
|
4639
|
+
};
|
|
4640
|
+
const normalizePayload = (command, payloadOverride) => {
|
|
4641
|
+
const resolved = resolveCommandRef(command, payloadOverride);
|
|
4642
|
+
if (resolved.name === "insertTable" && resolved.payload && typeof resolved.payload === "object") {
|
|
4643
|
+
const payload = resolved.payload;
|
|
4644
|
+
return {
|
|
4645
|
+
...resolved,
|
|
4646
|
+
payload: {
|
|
4647
|
+
rows: payload.rows,
|
|
4648
|
+
cols: payload.cols ?? payload.columns
|
|
4649
|
+
}
|
|
4650
|
+
};
|
|
4651
|
+
}
|
|
4652
|
+
if (resolved.name === "setFontSize" && resolved.payload && typeof resolved.payload === "object") {
|
|
4653
|
+
const payload = resolved.payload;
|
|
4654
|
+
return { ...resolved, payload: payload.size };
|
|
4655
|
+
}
|
|
4656
|
+
return resolved;
|
|
4657
|
+
};
|
|
4658
|
+
const commands = {
|
|
4659
|
+
execute(command, payloadOverride) {
|
|
4660
|
+
const editor = getRuntimeEditor();
|
|
4661
|
+
if (!editor) {
|
|
4662
|
+
throw new Error("Oasis editor runtime is not ready.");
|
|
4663
|
+
}
|
|
4664
|
+
const resolved = normalizePayload(command, payloadOverride);
|
|
4665
|
+
return editor.commands.execute(resolved.name, resolved.payload);
|
|
4666
|
+
},
|
|
4667
|
+
canExecute(command, payloadOverride) {
|
|
4668
|
+
const editor = getRuntimeEditor();
|
|
4669
|
+
if (!editor) return false;
|
|
4670
|
+
const resolved = normalizePayload(command, payloadOverride);
|
|
4671
|
+
return editor.commands.canExecute(resolved.name, resolved.payload);
|
|
4672
|
+
},
|
|
4673
|
+
state(command) {
|
|
4674
|
+
var _a2;
|
|
4675
|
+
const editor = getRuntimeEditor();
|
|
4676
|
+
if (!editor) return disabledCommandState();
|
|
4677
|
+
const resolved = resolveCommandRef(command);
|
|
4678
|
+
const registered = editor.commands.get(resolved.name);
|
|
4679
|
+
const state = (_a2 = registered == null ? void 0 : registered.refresh) == null ? void 0 : _a2.call(registered, resolved.payload);
|
|
4680
|
+
return {
|
|
4681
|
+
isEnabled: (state == null ? void 0 : state.isEnabled) ?? editor.commands.has(resolved.name) ?? false,
|
|
4682
|
+
isActive: Boolean(state == null ? void 0 : state.isActive),
|
|
4683
|
+
value: state == null ? void 0 : state.value
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4686
|
+
};
|
|
4687
|
+
return {
|
|
4688
|
+
ready,
|
|
4689
|
+
commands,
|
|
4690
|
+
connectHost(nextHost) {
|
|
4691
|
+
host = nextHost;
|
|
4692
|
+
},
|
|
4693
|
+
setDispose(dispose2) {
|
|
4694
|
+
disposeHost = dispose2;
|
|
4695
|
+
},
|
|
4696
|
+
resolveReady(editor) {
|
|
4697
|
+
dirty = false;
|
|
4698
|
+
resolveReady(editor);
|
|
4699
|
+
emit("ready", editor);
|
|
4700
|
+
},
|
|
4701
|
+
rejectReady(error) {
|
|
4702
|
+
rejectReady(error);
|
|
4703
|
+
emit("error", error);
|
|
4704
|
+
},
|
|
4705
|
+
emit,
|
|
4706
|
+
dispose() {
|
|
4707
|
+
if (disposed) return;
|
|
4708
|
+
disposed = true;
|
|
4709
|
+
return disposeHost == null ? void 0 : disposeHost();
|
|
4710
|
+
},
|
|
4711
|
+
getState() {
|
|
4712
|
+
return requireHost().getState();
|
|
4713
|
+
},
|
|
4714
|
+
getDocument() {
|
|
4715
|
+
return requireHost().getDocument();
|
|
4716
|
+
},
|
|
4717
|
+
setDocument(document2) {
|
|
4718
|
+
requireHost().setDocument(document2);
|
|
4719
|
+
version2 += 1;
|
|
4720
|
+
},
|
|
4721
|
+
loadDocument(document2) {
|
|
4722
|
+
requireHost().setDocument(document2);
|
|
4723
|
+
version2 += 1;
|
|
4724
|
+
dirty = false;
|
|
4725
|
+
},
|
|
4726
|
+
updateDocument(updater) {
|
|
4727
|
+
const currentHost = requireHost();
|
|
4728
|
+
if (currentHost.applyTransactionalState) currentHost.applyTransactionalState((state) => ({ ...state, document: updater(state.document) }));
|
|
4729
|
+
else currentHost.setDocument(updater(currentHost.getDocument()));
|
|
4730
|
+
version2 += 1;
|
|
4731
|
+
},
|
|
4732
|
+
resetDocument() {
|
|
4733
|
+
requireHost().resetDocument();
|
|
4734
|
+
version2 += 1;
|
|
4735
|
+
dirty = false;
|
|
4736
|
+
},
|
|
4737
|
+
async save() {
|
|
4738
|
+
await requireHost().saveDocument();
|
|
4739
|
+
dirty = false;
|
|
4740
|
+
},
|
|
4741
|
+
isDirty() {
|
|
4742
|
+
return dirty;
|
|
4743
|
+
},
|
|
4744
|
+
markClean() {
|
|
4745
|
+
dirty = false;
|
|
4746
|
+
},
|
|
4747
|
+
getSelection() {
|
|
4748
|
+
return requireHost().getSelection();
|
|
4749
|
+
},
|
|
4750
|
+
setSelection(selection) {
|
|
4751
|
+
requireHost().setSelection(selection);
|
|
4752
|
+
},
|
|
4753
|
+
focusEditor() {
|
|
4754
|
+
requireHost().focus();
|
|
4755
|
+
},
|
|
4756
|
+
blurEditor() {
|
|
4757
|
+
requireHost().blur();
|
|
4758
|
+
},
|
|
4759
|
+
document: {
|
|
4760
|
+
get: () => requireHost().getDocument(),
|
|
4761
|
+
set: (document2) => {
|
|
4762
|
+
requireHost().setDocument(document2);
|
|
4763
|
+
version2 += 1;
|
|
4764
|
+
},
|
|
4765
|
+
load: (document2) => {
|
|
4766
|
+
requireHost().setDocument(document2);
|
|
4767
|
+
version2 += 1;
|
|
4768
|
+
dirty = false;
|
|
4769
|
+
},
|
|
4770
|
+
update: (updater) => {
|
|
4771
|
+
const currentHost = requireHost();
|
|
4772
|
+
if (currentHost.applyTransactionalState) currentHost.applyTransactionalState((state) => ({ ...state, document: updater(state.document) }));
|
|
4773
|
+
else currentHost.setDocument(updater(currentHost.getDocument()));
|
|
4774
|
+
version2 += 1;
|
|
4775
|
+
},
|
|
4776
|
+
reset: () => {
|
|
4777
|
+
requireHost().resetDocument();
|
|
4778
|
+
version2 += 1;
|
|
4779
|
+
dirty = false;
|
|
4780
|
+
},
|
|
4781
|
+
save: async () => {
|
|
4782
|
+
await requireHost().saveDocument();
|
|
4783
|
+
dirty = false;
|
|
4784
|
+
},
|
|
4785
|
+
isDirty: () => dirty,
|
|
4786
|
+
markClean: () => {
|
|
4787
|
+
dirty = false;
|
|
4788
|
+
},
|
|
4789
|
+
version: () => version2
|
|
4790
|
+
},
|
|
4791
|
+
selection: {
|
|
4792
|
+
get: () => requireHost().getSelection(),
|
|
4793
|
+
set: (selection) => requireHost().setSelection(selection)
|
|
4794
|
+
},
|
|
4795
|
+
focus: {
|
|
4796
|
+
focus: () => requireHost().focus(),
|
|
4797
|
+
blur: () => requireHost().blur()
|
|
4798
|
+
},
|
|
4799
|
+
history: {
|
|
4800
|
+
undo: () => commands.execute("undo"),
|
|
4801
|
+
redo: () => commands.execute("redo"),
|
|
4802
|
+
canUndo: () => commands.canExecute("undo"),
|
|
4803
|
+
canRedo: () => commands.canExecute("redo"),
|
|
4804
|
+
clear: () => requireHost().clearHistory()
|
|
4805
|
+
},
|
|
4806
|
+
import: {
|
|
4807
|
+
docx: (file) => requireHost().importDocx(file)
|
|
4808
|
+
},
|
|
4809
|
+
export: {
|
|
4810
|
+
docx: () => requireHost().exportDocx(),
|
|
4811
|
+
pdf: () => requireHost().exportPdf()
|
|
4812
|
+
},
|
|
4813
|
+
query: {
|
|
4814
|
+
snapshot: () => queryDocument(requireHost().getDocument()).snapshot(),
|
|
4815
|
+
getText: (target) => queryDocument(requireHost().getDocument()).getText(target),
|
|
4816
|
+
getNode: (selector) => queryDocument(requireHost().getDocument()).getNode(selector),
|
|
4817
|
+
find: (text) => queryDocument(requireHost().getDocument()).find(text),
|
|
4818
|
+
outline: () => queryDocument(requireHost().getDocument()).outline()
|
|
4819
|
+
},
|
|
4820
|
+
edit: {
|
|
4821
|
+
async apply(request) {
|
|
4822
|
+
if (request.expectedVersion !== void 0 && request.expectedVersion !== version2) {
|
|
4823
|
+
return { ok: false, error: { code: "DOCUMENT_VERSION_CONFLICT", message: "Document version does not match expectedVersion", expectedVersion: request.expectedVersion, actualVersion: version2 } };
|
|
4824
|
+
}
|
|
4825
|
+
if (request.idempotencyKey && idempotent.has(request.idempotencyKey)) return idempotent.get(request.idempotencyKey);
|
|
4826
|
+
const host2 = requireHost();
|
|
4827
|
+
try {
|
|
4828
|
+
const applied = applyDocumentOperations(host2.getDocument(), request.operations);
|
|
4829
|
+
if (host2.applyTransactionalState) host2.applyTransactionalState((state) => ({ ...state, document: applied.document }));
|
|
4830
|
+
else host2.setDocument(applied.document);
|
|
4831
|
+
version2 += 1;
|
|
4832
|
+
const result = { ok: true, value: applied.value, version: version2, warnings: [] };
|
|
4833
|
+
if (request.idempotencyKey) idempotent.set(request.idempotencyKey, result);
|
|
4834
|
+
return result;
|
|
4835
|
+
} catch (error) {
|
|
4836
|
+
const message = error instanceof Error ? error.message : "Edit failed";
|
|
4837
|
+
const code2 = message === "AMBIGUOUS_SELECTOR" ? "AMBIGUOUS_SELECTOR" : message === "INVALID_RANGE" ? "INVALID_RANGE" : message === "VALIDATION_FAILED" ? "VALIDATION_FAILED" : message === "UNSUPPORTED_OPERATION" ? "UNSUPPORTED_OPERATION" : "NODE_NOT_FOUND";
|
|
4838
|
+
return { ok: false, error: { code: code2, message } };
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
},
|
|
4842
|
+
io: {
|
|
4843
|
+
async import(request) {
|
|
4844
|
+
var _a2, _b2;
|
|
4845
|
+
if ((_a2 = request.signal) == null ? void 0 : _a2.aborted) return { ok: false, error: { code: "ABORTED", message: "Import aborted" } };
|
|
4846
|
+
try {
|
|
4847
|
+
const data = request.data instanceof Blob ? request.data : new Blob([
|
|
4848
|
+
request.data instanceof Uint8Array ? Uint8Array.from(request.data).buffer : request.data
|
|
4849
|
+
]);
|
|
4850
|
+
const file = new File([data], request.filename ?? "document.docx", { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
4851
|
+
await requireHost().importDocx(file);
|
|
4852
|
+
version2 += 1;
|
|
4853
|
+
(_b2 = request.onProgress) == null ? void 0 : _b2.call(request, { phase: "done", progress: 100 });
|
|
4854
|
+
return { ok: true, value: { format: "docx" }, version: version2, warnings: [] };
|
|
4855
|
+
} catch (error) {
|
|
4856
|
+
return { ok: false, error: { code: "IMPORT_FAILED", message: error instanceof Error ? error.message : "Import failed" } };
|
|
4857
|
+
}
|
|
4858
|
+
},
|
|
4859
|
+
async export(request) {
|
|
4860
|
+
try {
|
|
4861
|
+
const value = request.format === "docx" ? await requireHost().exportDocxBlob() : await requireHost().exportPdfBlob();
|
|
4862
|
+
return { ok: true, value: { format: request.format, blob: value, arrayBuffer: () => value.arrayBuffer() }, version: version2, warnings: [] };
|
|
4863
|
+
} catch (error) {
|
|
4864
|
+
return { ok: false, error: { code: "EXPORT_FAILED", message: error instanceof Error ? error.message : "Export failed" } };
|
|
4865
|
+
}
|
|
4866
|
+
}
|
|
4867
|
+
},
|
|
4868
|
+
ui: {
|
|
4869
|
+
state: () => {
|
|
4870
|
+
var _a2, _b2;
|
|
4871
|
+
return ((_b2 = (_a2 = requireHost()).getUiState) == null ? void 0 : _b2.call(_a2)) ?? {};
|
|
4872
|
+
},
|
|
4873
|
+
update: (patch) => {
|
|
4874
|
+
var _a2, _b2;
|
|
4875
|
+
const next = ((_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, patch)) ?? {};
|
|
4876
|
+
emit("uiChange", next);
|
|
4877
|
+
return next;
|
|
4878
|
+
},
|
|
4879
|
+
setReadOnly: (value) => {
|
|
4880
|
+
var _a2, _b2;
|
|
4881
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { readOnly: value });
|
|
4882
|
+
},
|
|
4883
|
+
zoom: { get: () => {
|
|
4884
|
+
var _a2, _b2;
|
|
4885
|
+
return ((_b2 = (_a2 = requireHost()).getZoom) == null ? void 0 : _b2.call(_a2)) ?? 100;
|
|
4886
|
+
}, set: (value) => {
|
|
4887
|
+
var _a2, _b2;
|
|
4888
|
+
return (_b2 = (_a2 = requireHost()).setZoom) == null ? void 0 : _b2.call(_a2, value);
|
|
4889
|
+
}, adjust: (delta) => {
|
|
4890
|
+
var _a2, _b2;
|
|
4891
|
+
return (_b2 = (_a2 = requireHost()).adjustZoom) == null ? void 0 : _b2.call(_a2, delta);
|
|
4892
|
+
} },
|
|
4893
|
+
chrome: { setVisible: (value) => {
|
|
4894
|
+
var _a2, _b2;
|
|
4895
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showChrome: value });
|
|
4896
|
+
} },
|
|
4897
|
+
titleBar: { setVisible: (value) => {
|
|
4898
|
+
var _a2, _b2;
|
|
4899
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showTitleBar: value });
|
|
4900
|
+
} },
|
|
4901
|
+
menubar: { setVisible: (value) => {
|
|
4902
|
+
var _a2, _b2;
|
|
4903
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showMenubar: value });
|
|
4904
|
+
}, items: { register: (...args) => {
|
|
4905
|
+
var _a2;
|
|
4906
|
+
return (_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.register(...args);
|
|
4907
|
+
}, unregister: (id) => {
|
|
4908
|
+
var _a2;
|
|
4909
|
+
return (_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.unregister(id);
|
|
4910
|
+
}, getItems: () => {
|
|
4911
|
+
var _a2;
|
|
4912
|
+
return ((_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.getItems()) ?? [];
|
|
4913
|
+
} } },
|
|
4914
|
+
toolbar: { setVisible: (value) => {
|
|
4915
|
+
var _a2, _b2;
|
|
4916
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showToolbar: value });
|
|
4917
|
+
}, items: { register: (...args) => {
|
|
4918
|
+
var _a2;
|
|
4919
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.register(...args);
|
|
4920
|
+
}, insertBefore: (...args) => {
|
|
4921
|
+
var _a2;
|
|
4922
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.insertBefore(...args);
|
|
4923
|
+
}, insertAfter: (...args) => {
|
|
4924
|
+
var _a2;
|
|
4925
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.insertAfter(...args);
|
|
4926
|
+
}, replace: (...args) => {
|
|
4927
|
+
var _a2;
|
|
4928
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.replace(...args);
|
|
4929
|
+
}, remove: (id) => {
|
|
4930
|
+
var _a2;
|
|
4931
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.remove(id);
|
|
4932
|
+
}, move: (...args) => {
|
|
4933
|
+
var _a2;
|
|
4934
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.move(...args);
|
|
4935
|
+
}, get: (id) => {
|
|
4936
|
+
var _a2;
|
|
4937
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.get(id);
|
|
4938
|
+
}, getOrdered: () => {
|
|
4939
|
+
var _a2;
|
|
4940
|
+
return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.getOrdered()) ?? [];
|
|
4941
|
+
}, getItems: () => {
|
|
4942
|
+
var _a2;
|
|
4943
|
+
return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.getItems()) ?? [];
|
|
4944
|
+
}, clear: () => {
|
|
4945
|
+
var _a2;
|
|
4946
|
+
return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.clear();
|
|
4947
|
+
}, onChange: (cb) => {
|
|
4948
|
+
var _a2;
|
|
4949
|
+
return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.onChange(cb)) ?? (() => void 0);
|
|
4950
|
+
} } },
|
|
4951
|
+
outline: { setVisible: (value) => {
|
|
4952
|
+
var _a2, _b2;
|
|
4953
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showOutline: value });
|
|
4954
|
+
} },
|
|
4955
|
+
shell: { set: (shell) => {
|
|
4956
|
+
var _a2, _b2;
|
|
4957
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { shell });
|
|
4958
|
+
} },
|
|
4959
|
+
locale: { set: (locale) => {
|
|
4960
|
+
var _a2, _b2;
|
|
4961
|
+
(_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { locale });
|
|
4962
|
+
} }
|
|
4963
|
+
},
|
|
4964
|
+
on: addListener,
|
|
4965
|
+
once(event, callback) {
|
|
4966
|
+
const unsubscribe = addListener(event, (payload) => {
|
|
4967
|
+
unsubscribe();
|
|
4968
|
+
callback(payload);
|
|
4969
|
+
});
|
|
4970
|
+
return unsubscribe;
|
|
4971
|
+
},
|
|
4972
|
+
off(event, callback) {
|
|
4973
|
+
const handlers = listeners.get(event);
|
|
4974
|
+
if (!handlers) return;
|
|
4975
|
+
handlers.delete(
|
|
4976
|
+
callback
|
|
4977
|
+
);
|
|
4978
|
+
if (handlers.size === 0) listeners.delete(event);
|
|
4979
|
+
}
|
|
4711
4980
|
};
|
|
4712
4981
|
}
|
|
4713
|
-
function
|
|
4714
|
-
const
|
|
4715
|
-
|
|
4982
|
+
function createOasisEditor(container, props = {}) {
|
|
4983
|
+
const client = createOasisEditorClient();
|
|
4984
|
+
const dispose2 = render(
|
|
4985
|
+
() => OasisEditorAppLazy({ ...props, runtime: { ...props.runtime, client } }),
|
|
4986
|
+
container
|
|
4716
4987
|
);
|
|
4717
|
-
|
|
4988
|
+
client.setDispose(() => {
|
|
4989
|
+
dispose2();
|
|
4990
|
+
container.innerHTML = "";
|
|
4991
|
+
});
|
|
4992
|
+
return client;
|
|
4718
4993
|
}
|
|
4719
|
-
function
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
...pageSettings.columns ? { columns: pageSettings.columns } : {}
|
|
4727
|
-
} : {
|
|
4728
|
-
width: DEFAULT_EDITOR_PAGE_SETTINGS.width,
|
|
4729
|
-
height: DEFAULT_EDITOR_PAGE_SETTINGS.height,
|
|
4730
|
-
orientation: DEFAULT_EDITOR_PAGE_SETTINGS.orientation,
|
|
4731
|
-
margins: { ...DEFAULT_EDITOR_PAGE_SETTINGS.margins }
|
|
4994
|
+
function OasisEditorContainer(props) {
|
|
4995
|
+
return createComponent(OasisEditorAppLazy, mergeProps(props, {
|
|
4996
|
+
get ui() {
|
|
4997
|
+
return {
|
|
4998
|
+
...props.ui,
|
|
4999
|
+
showChrome: false
|
|
5000
|
+
};
|
|
4732
5001
|
}
|
|
5002
|
+
}));
|
|
5003
|
+
}
|
|
5004
|
+
function createOasisEditorContainer(container, props = {}) {
|
|
5005
|
+
const client = createOasisEditorClient();
|
|
5006
|
+
const dispose2 = render(
|
|
5007
|
+
() => OasisEditorContainer({
|
|
5008
|
+
...props,
|
|
5009
|
+
runtime: { ...props.runtime, client }
|
|
5010
|
+
}),
|
|
5011
|
+
container
|
|
4733
5012
|
);
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
5013
|
+
client.setDispose(() => {
|
|
5014
|
+
dispose2();
|
|
5015
|
+
container.innerHTML = "";
|
|
5016
|
+
});
|
|
5017
|
+
return client;
|
|
5018
|
+
}
|
|
5019
|
+
const $RAW = Symbol("store-raw"), $NODE = Symbol("store-node"), $HAS = Symbol("store-has"), $SELF = Symbol("store-self");
|
|
5020
|
+
function wrap$1(value) {
|
|
5021
|
+
let p = value[$PROXY];
|
|
5022
|
+
if (!p) {
|
|
5023
|
+
Object.defineProperty(value, $PROXY, {
|
|
5024
|
+
value: p = new Proxy(value, proxyTraps$1)
|
|
5025
|
+
});
|
|
5026
|
+
if (!Array.isArray(value)) {
|
|
5027
|
+
const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
|
|
5028
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
5029
|
+
const prop = keys[i];
|
|
5030
|
+
if (desc[prop].get) {
|
|
5031
|
+
Object.defineProperty(value, prop, {
|
|
5032
|
+
enumerable: desc[prop].enumerable,
|
|
5033
|
+
get: desc[prop].get.bind(p)
|
|
5034
|
+
});
|
|
5035
|
+
}
|
|
4742
5036
|
}
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
// The asset registry holds out-of-band image payloads (data URLs).
|
|
4747
|
-
// It must be carried through any document-rebuild path or `asset:<id>`
|
|
4748
|
-
// refs in image runs will dangle and the renderer will try to GET
|
|
4749
|
-
// "asset:img-1" as a URL.
|
|
4750
|
-
assets: assets ?? void 0
|
|
4751
|
-
};
|
|
4752
|
-
return document2;
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
return p;
|
|
4753
5040
|
}
|
|
4754
|
-
function
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
0
|
|
4758
|
-
);
|
|
5041
|
+
function isWrappable(obj) {
|
|
5042
|
+
let proto;
|
|
5043
|
+
return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
|
|
4759
5044
|
}
|
|
4760
|
-
function
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
)
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
5045
|
+
function unwrap(item, set = /* @__PURE__ */ new Set()) {
|
|
5046
|
+
let result, unwrapped, v, prop;
|
|
5047
|
+
if (result = item != null && item[$RAW]) return result;
|
|
5048
|
+
if (!isWrappable(item) || set.has(item)) return item;
|
|
5049
|
+
if (Array.isArray(item)) {
|
|
5050
|
+
if (Object.isFrozen(item)) item = item.slice(0);
|
|
5051
|
+
else set.add(item);
|
|
5052
|
+
for (let i = 0, l = item.length; i < l; i++) {
|
|
5053
|
+
v = item[i];
|
|
5054
|
+
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
|
|
5055
|
+
}
|
|
5056
|
+
} else {
|
|
5057
|
+
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
5058
|
+
else set.add(item);
|
|
5059
|
+
const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
|
|
5060
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
5061
|
+
prop = keys[i];
|
|
5062
|
+
if (desc[prop].get) continue;
|
|
5063
|
+
v = item[prop];
|
|
5064
|
+
if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
|
|
5065
|
+
}
|
|
4771
5066
|
}
|
|
4772
|
-
return
|
|
5067
|
+
return item;
|
|
4773
5068
|
}
|
|
4774
|
-
function
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
5069
|
+
function getNodes(target, symbol) {
|
|
5070
|
+
let nodes = target[symbol];
|
|
5071
|
+
if (!nodes) Object.defineProperty(target, symbol, {
|
|
5072
|
+
value: nodes = /* @__PURE__ */ Object.create(null)
|
|
5073
|
+
});
|
|
5074
|
+
return nodes;
|
|
4779
5075
|
}
|
|
4780
|
-
function
|
|
4781
|
-
return
|
|
5076
|
+
function getNode(nodes, property, value) {
|
|
5077
|
+
if (nodes[property]) return nodes[property];
|
|
5078
|
+
const [s, set] = createSignal(value, {
|
|
5079
|
+
equals: false,
|
|
5080
|
+
internal: true
|
|
5081
|
+
});
|
|
5082
|
+
s.$ = set;
|
|
5083
|
+
return nodes[property] = s;
|
|
4782
5084
|
}
|
|
4783
|
-
function
|
|
4784
|
-
|
|
5085
|
+
function proxyDescriptor$1(target, property) {
|
|
5086
|
+
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
5087
|
+
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE) return desc;
|
|
5088
|
+
delete desc.value;
|
|
5089
|
+
delete desc.writable;
|
|
5090
|
+
desc.get = () => target[$PROXY][property];
|
|
5091
|
+
return desc;
|
|
4785
5092
|
}
|
|
4786
|
-
function
|
|
4787
|
-
|
|
4788
|
-
const paragraph = findParagraphById(paragraphs, position2.paragraphId);
|
|
4789
|
-
return clampPositionInParagraph(position2, paragraph);
|
|
5093
|
+
function trackSelf(target) {
|
|
5094
|
+
getListener() && getNode(getNodes(target, $NODE), $SELF)();
|
|
4790
5095
|
}
|
|
4791
|
-
function
|
|
4792
|
-
|
|
4793
|
-
return
|
|
4794
|
-
paragraph,
|
|
4795
|
-
clampOffset(paragraphOffset, paragraph)
|
|
4796
|
-
);
|
|
5096
|
+
function ownKeys(target) {
|
|
5097
|
+
trackSelf(target);
|
|
5098
|
+
return Reflect.ownKeys(target);
|
|
4797
5099
|
}
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
5100
|
+
const proxyTraps$1 = {
|
|
5101
|
+
get(target, property, receiver) {
|
|
5102
|
+
if (property === $RAW) return target;
|
|
5103
|
+
if (property === $PROXY) return receiver;
|
|
5104
|
+
if (property === $TRACK) {
|
|
5105
|
+
trackSelf(target);
|
|
5106
|
+
return receiver;
|
|
5107
|
+
}
|
|
5108
|
+
const nodes = getNodes(target, $NODE);
|
|
5109
|
+
const tracked = nodes[property];
|
|
5110
|
+
let value = tracked ? tracked() : target[property];
|
|
5111
|
+
if (property === $NODE || property === $HAS || property === "__proto__") return value;
|
|
5112
|
+
if (!tracked) {
|
|
5113
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
5114
|
+
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
|
|
5115
|
+
}
|
|
5116
|
+
return isWrappable(value) ? wrap$1(value) : value;
|
|
5117
|
+
},
|
|
5118
|
+
has(target, property) {
|
|
5119
|
+
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
|
|
5120
|
+
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
5121
|
+
return property in target;
|
|
5122
|
+
},
|
|
5123
|
+
set() {
|
|
5124
|
+
return true;
|
|
5125
|
+
},
|
|
5126
|
+
deleteProperty() {
|
|
5127
|
+
return true;
|
|
5128
|
+
},
|
|
5129
|
+
ownKeys,
|
|
5130
|
+
getOwnPropertyDescriptor: proxyDescriptor$1
|
|
5131
|
+
};
|
|
5132
|
+
function setProperty(state, property, value, deleting = false) {
|
|
5133
|
+
if (!deleting && state[property] === value) return;
|
|
5134
|
+
const prev = state[property], len = state.length;
|
|
5135
|
+
if (value === void 0) {
|
|
5136
|
+
delete state[property];
|
|
5137
|
+
if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
|
|
5138
|
+
} else {
|
|
5139
|
+
state[property] = value;
|
|
5140
|
+
if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
|
|
5141
|
+
}
|
|
5142
|
+
let nodes = getNodes(state, $NODE), node;
|
|
5143
|
+
if (node = getNode(nodes, property, prev)) node.$(() => value);
|
|
5144
|
+
if (Array.isArray(state) && state.length !== len) {
|
|
5145
|
+
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
|
|
5146
|
+
(node = getNode(nodes, "length", len)) && node.$(state.length);
|
|
5147
|
+
}
|
|
5148
|
+
(node = nodes[$SELF]) && node.$();
|
|
4803
5149
|
}
|
|
4804
|
-
function
|
|
4805
|
-
|
|
5150
|
+
function mergeStoreNode(state, value) {
|
|
5151
|
+
const keys = Object.keys(value);
|
|
5152
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
5153
|
+
const key = keys[i];
|
|
5154
|
+
setProperty(state, key, value[key]);
|
|
5155
|
+
}
|
|
4806
5156
|
}
|
|
4807
|
-
function
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
state.selection.anchor,
|
|
4820
|
-
anchorParagraph
|
|
4821
|
-
);
|
|
4822
|
-
const focus = clampPositionInParagraph(state.selection.focus, focusParagraph);
|
|
4823
|
-
const anchorIndex = indexById.get(anchor.paragraphId) ?? rawAnchorIndex;
|
|
4824
|
-
const focusIndex = indexById.get(focus.paragraphId) ?? rawFocusIndex;
|
|
4825
|
-
const comparison = anchorIndex !== focusIndex ? anchorIndex - focusIndex : positionToParagraphOffset(paragraphs[anchorIndex], anchor) - positionToParagraphOffset(paragraphs[focusIndex], focus);
|
|
4826
|
-
const start = comparison <= 0 ? anchor : focus;
|
|
4827
|
-
const end = comparison <= 0 ? focus : anchor;
|
|
4828
|
-
const startParagraph = paragraphs[comparison <= 0 ? anchorIndex : focusIndex];
|
|
4829
|
-
const endParagraph = paragraphs[comparison <= 0 ? focusIndex : anchorIndex];
|
|
4830
|
-
return {
|
|
4831
|
-
start,
|
|
4832
|
-
end,
|
|
4833
|
-
startIndex: comparison <= 0 ? anchorIndex : focusIndex,
|
|
4834
|
-
endIndex: comparison <= 0 ? focusIndex : anchorIndex,
|
|
4835
|
-
startParagraphOffset: positionToParagraphOffset(startParagraph, start),
|
|
4836
|
-
endParagraphOffset: positionToParagraphOffset(endParagraph, end),
|
|
4837
|
-
isCollapsed: comparison === 0
|
|
4838
|
-
};
|
|
5157
|
+
function updateArray(current, next) {
|
|
5158
|
+
if (typeof next === "function") next = next(current);
|
|
5159
|
+
next = unwrap(next);
|
|
5160
|
+
if (Array.isArray(next)) {
|
|
5161
|
+
if (current === next) return;
|
|
5162
|
+
let i = 0, len = next.length;
|
|
5163
|
+
for (; i < len; i++) {
|
|
5164
|
+
const value = next[i];
|
|
5165
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
5166
|
+
}
|
|
5167
|
+
setProperty(current, "length", len);
|
|
5168
|
+
} else mergeStoreNode(current, next);
|
|
4839
5169
|
}
|
|
4840
|
-
function
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
pageSettings: ((_a2 = getDocumentSectionsCanonical(document2)[0]) == null ? void 0 : _a2.pageSettings) ?? DEFAULT_EDITOR_PAGE_SETTINGS
|
|
5170
|
+
function updatePath(current, path, traversed = []) {
|
|
5171
|
+
let part, prev = current;
|
|
5172
|
+
if (path.length > 1) {
|
|
5173
|
+
part = path.shift();
|
|
5174
|
+
const partType = typeof part, isArray = Array.isArray(current);
|
|
5175
|
+
if (Array.isArray(part)) {
|
|
5176
|
+
for (let i = 0; i < part.length; i++) {
|
|
5177
|
+
updatePath(current, [part[i]].concat(path), traversed);
|
|
4849
5178
|
}
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
5179
|
+
return;
|
|
5180
|
+
} else if (isArray && partType === "function") {
|
|
5181
|
+
for (let i = 0; i < current.length; i++) {
|
|
5182
|
+
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
|
|
5183
|
+
}
|
|
5184
|
+
return;
|
|
5185
|
+
} else if (isArray && partType === "object") {
|
|
5186
|
+
const {
|
|
5187
|
+
from = 0,
|
|
5188
|
+
to = current.length - 1,
|
|
5189
|
+
by = 1
|
|
5190
|
+
} = part;
|
|
5191
|
+
for (let i = from; i <= to; i += by) {
|
|
5192
|
+
updatePath(current, [i].concat(path), traversed);
|
|
5193
|
+
}
|
|
5194
|
+
return;
|
|
5195
|
+
} else if (path.length > 1) {
|
|
5196
|
+
updatePath(current[part], path, [part].concat(traversed));
|
|
5197
|
+
return;
|
|
4867
5198
|
}
|
|
4868
|
-
|
|
5199
|
+
prev = current[part];
|
|
5200
|
+
traversed = [part].concat(traversed);
|
|
4869
5201
|
}
|
|
4870
|
-
let
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
5202
|
+
let value = path[0];
|
|
5203
|
+
if (typeof value === "function") {
|
|
5204
|
+
value = value(prev, traversed);
|
|
5205
|
+
if (value === prev) return;
|
|
5206
|
+
}
|
|
5207
|
+
if (part === void 0 && value == void 0) return;
|
|
5208
|
+
value = unwrap(value);
|
|
5209
|
+
if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
|
|
5210
|
+
mergeStoreNode(prev, value);
|
|
5211
|
+
} else setProperty(current, part, value);
|
|
5212
|
+
}
|
|
5213
|
+
function createStore(...[store, options]) {
|
|
5214
|
+
const unwrappedStore = unwrap(store || {});
|
|
5215
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
5216
|
+
const wrappedStore = wrap$1(unwrappedStore);
|
|
5217
|
+
function setStore(...args) {
|
|
5218
|
+
batch(() => {
|
|
5219
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
|
|
5220
|
+
});
|
|
5221
|
+
}
|
|
5222
|
+
return [wrappedStore, setStore];
|
|
5223
|
+
}
|
|
5224
|
+
const $ROOT = Symbol("store-root");
|
|
5225
|
+
function applyState(target, parent, property, merge, key) {
|
|
5226
|
+
const previous = parent[property];
|
|
5227
|
+
if (target === previous) return;
|
|
5228
|
+
const isArray = Array.isArray(target);
|
|
5229
|
+
if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
|
|
5230
|
+
setProperty(parent, property, target);
|
|
5231
|
+
return;
|
|
5232
|
+
}
|
|
5233
|
+
if (isArray) {
|
|
5234
|
+
if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
|
|
5235
|
+
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
5236
|
+
for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start] && target[start] && previous[start][key] && previous[start][key] === target[start][key]); start++) {
|
|
5237
|
+
applyState(target[start], previous, start, merge, key);
|
|
5238
|
+
}
|
|
5239
|
+
const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
|
|
5240
|
+
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[end] && target[newEnd] && previous[end][key] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
5241
|
+
temp[newEnd] = previous[end];
|
|
5242
|
+
}
|
|
5243
|
+
if (start > newEnd || start > end) {
|
|
5244
|
+
for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);
|
|
5245
|
+
for (; j < target.length; j++) {
|
|
5246
|
+
setProperty(previous, j, temp[j]);
|
|
5247
|
+
applyState(target[j], previous, j, merge, key);
|
|
5248
|
+
}
|
|
5249
|
+
if (previous.length > target.length) setProperty(previous, "length", target.length);
|
|
5250
|
+
return;
|
|
5251
|
+
}
|
|
5252
|
+
newIndicesNext = new Array(newEnd + 1);
|
|
5253
|
+
for (j = newEnd; j >= start; j--) {
|
|
5254
|
+
item = target[j];
|
|
5255
|
+
keyVal = key && item ? item[key] : item;
|
|
5256
|
+
i = newIndices.get(keyVal);
|
|
5257
|
+
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
5258
|
+
newIndices.set(keyVal, j);
|
|
5259
|
+
}
|
|
5260
|
+
for (i = start; i <= end; i++) {
|
|
5261
|
+
item = previous[i];
|
|
5262
|
+
keyVal = key && item ? item[key] : item;
|
|
5263
|
+
j = newIndices.get(keyVal);
|
|
5264
|
+
if (j !== void 0 && j !== -1) {
|
|
5265
|
+
temp[j] = previous[i];
|
|
5266
|
+
j = newIndicesNext[j];
|
|
5267
|
+
newIndices.set(keyVal, j);
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
for (j = start; j < target.length; j++) {
|
|
5271
|
+
if (j in temp) {
|
|
5272
|
+
setProperty(previous, j, temp[j]);
|
|
5273
|
+
applyState(target[j], previous, j, merge, key);
|
|
5274
|
+
} else setProperty(previous, j, target[j]);
|
|
5275
|
+
}
|
|
4881
5276
|
} else {
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
if (headerParagraphs.length > 0) {
|
|
4885
|
-
targetParagraph = headerParagraphs[0];
|
|
4886
|
-
activeZone = "header";
|
|
4887
|
-
} else if (footerParagraphs.length > 0) {
|
|
4888
|
-
targetParagraph = footerParagraphs[0];
|
|
4889
|
-
activeZone = "footer";
|
|
5277
|
+
for (let i = 0, len = target.length; i < len; i++) {
|
|
5278
|
+
applyState(target[i], previous, i, merge, key);
|
|
4890
5279
|
}
|
|
4891
|
-
activeSectionIndex = 0;
|
|
4892
5280
|
}
|
|
5281
|
+
if (previous.length > target.length) setProperty(previous, "length", target.length);
|
|
5282
|
+
return;
|
|
5283
|
+
}
|
|
5284
|
+
const targetKeys = Object.keys(target);
|
|
5285
|
+
for (let i = 0, len = targetKeys.length; i < len; i++) {
|
|
5286
|
+
applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
|
|
5287
|
+
}
|
|
5288
|
+
const previousKeys = Object.keys(previous);
|
|
5289
|
+
for (let i = 0, len = previousKeys.length; i < len; i++) {
|
|
5290
|
+
if (target[previousKeys[i]] === void 0) setProperty(previous, previousKeys[i], void 0);
|
|
4893
5291
|
}
|
|
4894
|
-
const position2 = paragraphOffsetToPosition(
|
|
4895
|
-
targetParagraph,
|
|
4896
|
-
Math.max(
|
|
4897
|
-
0,
|
|
4898
|
-
Math.min(0, getParagraphLength(targetParagraph))
|
|
4899
|
-
)
|
|
4900
|
-
);
|
|
4901
|
-
const result = {
|
|
4902
|
-
document: normalizedDocument,
|
|
4903
|
-
selection: createCollapsedSelection(position2),
|
|
4904
|
-
activeSectionIndex,
|
|
4905
|
-
activeZone
|
|
4906
|
-
};
|
|
4907
|
-
return result;
|
|
4908
5292
|
}
|
|
4909
|
-
function
|
|
4910
|
-
const
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
})
|
|
4919
|
-
|
|
4920
|
-
activeZone: "main"
|
|
5293
|
+
function reconcile(value, options = {}) {
|
|
5294
|
+
const {
|
|
5295
|
+
merge,
|
|
5296
|
+
key = "id"
|
|
5297
|
+
} = options, v = unwrap(value);
|
|
5298
|
+
return (state) => {
|
|
5299
|
+
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
5300
|
+
const res = applyState(v, {
|
|
5301
|
+
[$ROOT]: state
|
|
5302
|
+
}, $ROOT, merge, key);
|
|
5303
|
+
return res === void 0 ? state : res;
|
|
4921
5304
|
};
|
|
4922
5305
|
}
|
|
4923
5306
|
class PluginCollection {
|
|
@@ -5223,6 +5606,9 @@ function sortByOrder(items) {
|
|
|
5223
5606
|
}).map((entry) => entry.item);
|
|
5224
5607
|
}
|
|
5225
5608
|
class Editor {
|
|
5609
|
+
/**
|
|
5610
|
+
* @param options - Options for synchronous construction (no plugins).
|
|
5611
|
+
*/
|
|
5226
5612
|
constructor(options = {}) {
|
|
5227
5613
|
__publicField(this, "stateStore");
|
|
5228
5614
|
__publicField(this, "setState");
|
|
@@ -5233,6 +5619,11 @@ class Editor {
|
|
|
5233
5619
|
this.initializeState(options);
|
|
5234
5620
|
this.pluginCollection = new PluginCollection(this, []);
|
|
5235
5621
|
}
|
|
5622
|
+
/**
|
|
5623
|
+
* Creates an editor instance asynchronously, initializing all provided plugins.
|
|
5624
|
+
* @param options - Options including plugins to load.
|
|
5625
|
+
* @returns A promise that resolves to the initialized editor.
|
|
5626
|
+
*/
|
|
5236
5627
|
static async create(options = {}) {
|
|
5237
5628
|
const { plugins = [], ...syncOptions } = options;
|
|
5238
5629
|
const editor = new Editor(syncOptions);
|
|
@@ -5247,26 +5638,44 @@ class Editor {
|
|
|
5247
5638
|
this.setState = setState;
|
|
5248
5639
|
this.commands.setContextProvider(() => this.createCommandContext());
|
|
5249
5640
|
}
|
|
5641
|
+
/** @returns The current editor state. */
|
|
5250
5642
|
get state() {
|
|
5251
5643
|
return this.stateStore;
|
|
5252
5644
|
}
|
|
5645
|
+
/**
|
|
5646
|
+
* Applies a state updater function and emits a "change:data" event.
|
|
5647
|
+
* @param updater - Function that receives the current state and returns the new state.
|
|
5648
|
+
*/
|
|
5253
5649
|
dispatch(updater) {
|
|
5254
5650
|
const next = updater(this.stateStore);
|
|
5255
5651
|
this.setState(next);
|
|
5256
5652
|
this.emit("change:data", this.stateStore);
|
|
5257
5653
|
}
|
|
5654
|
+
/** Destroys the editor, cleaning up plugins, commands, UI, and listeners. */
|
|
5258
5655
|
async destroy() {
|
|
5259
5656
|
await this.pluginCollection.destroy();
|
|
5260
5657
|
this.commands.clear();
|
|
5261
5658
|
this.ui.clear();
|
|
5262
5659
|
this.listeners.clear();
|
|
5263
5660
|
}
|
|
5661
|
+
/**
|
|
5662
|
+
* Subscribes to an event.
|
|
5663
|
+
* @param event - The event name.
|
|
5664
|
+
* @param callback - The handler to invoke when the event fires.
|
|
5665
|
+
* @returns An unsubscribe function.
|
|
5666
|
+
*/
|
|
5264
5667
|
on(event, callback) {
|
|
5265
5668
|
const handlers = this.listeners.get(event) ?? /* @__PURE__ */ new Set();
|
|
5266
5669
|
handlers.add(callback);
|
|
5267
5670
|
this.listeners.set(event, handlers);
|
|
5268
5671
|
return () => this.off(event, callback);
|
|
5269
5672
|
}
|
|
5673
|
+
/**
|
|
5674
|
+
* Subscribes to a single emission of an event.
|
|
5675
|
+
* @param event - The event name.
|
|
5676
|
+
* @param callback - The handler to invoke once.
|
|
5677
|
+
* @returns An unsubscribe function.
|
|
5678
|
+
*/
|
|
5270
5679
|
once(event, callback) {
|
|
5271
5680
|
const wrapper = (...args) => {
|
|
5272
5681
|
this.off(event, wrapper);
|
|
@@ -5274,6 +5683,11 @@ class Editor {
|
|
|
5274
5683
|
};
|
|
5275
5684
|
return this.on(event, wrapper);
|
|
5276
5685
|
}
|
|
5686
|
+
/**
|
|
5687
|
+
* Removes a previously subscribed event handler.
|
|
5688
|
+
* @param event - The event name.
|
|
5689
|
+
* @param callback - The handler to remove.
|
|
5690
|
+
*/
|
|
5277
5691
|
off(event, callback) {
|
|
5278
5692
|
const handlers = this.listeners.get(event);
|
|
5279
5693
|
if (!handlers) {
|
|
@@ -39785,7 +40199,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
39785
40199
|
const worker = new Worker(
|
|
39786
40200
|
new URL(
|
|
39787
40201
|
/* @vite-ignore */
|
|
39788
|
-
"" + new URL("assets/importDocxWorker-
|
|
40202
|
+
"" + new URL("assets/importDocxWorker-B1vHeo5L.js", import.meta.url).href,
|
|
39789
40203
|
import.meta.url
|
|
39790
40204
|
),
|
|
39791
40205
|
{
|
|
@@ -43717,6 +44131,10 @@ class MenuRegistry {
|
|
|
43717
44131
|
constructor() {
|
|
43718
44132
|
__publicField(this, "items", []);
|
|
43719
44133
|
}
|
|
44134
|
+
/**
|
|
44135
|
+
* Registers or updates a menu item by id.
|
|
44136
|
+
* @param item - The menu item to register.
|
|
44137
|
+
*/
|
|
43720
44138
|
register(item) {
|
|
43721
44139
|
const existingIndex = this.items.findIndex(
|
|
43722
44140
|
(entry) => entry.id === item.id
|
|
@@ -43730,9 +44148,14 @@ class MenuRegistry {
|
|
|
43730
44148
|
(a, b) => (a.order ?? Number.MAX_SAFE_INTEGER) - (b.order ?? Number.MAX_SAFE_INTEGER)
|
|
43731
44149
|
);
|
|
43732
44150
|
}
|
|
44151
|
+
/**
|
|
44152
|
+
* Removes a menu item by id.
|
|
44153
|
+
* @param id - The id of the item to remove.
|
|
44154
|
+
*/
|
|
43733
44155
|
unregister(id) {
|
|
43734
44156
|
this.items = this.items.filter((i) => i.id !== id);
|
|
43735
44157
|
}
|
|
44158
|
+
/** @returns A copy of all registered menu items. */
|
|
43736
44159
|
getItems() {
|
|
43737
44160
|
return [...this.items];
|
|
43738
44161
|
}
|
|
@@ -47141,37 +47564,45 @@ export {
|
|
|
47141
47564
|
ActionRow as d7,
|
|
47142
47565
|
ColorPicker as d8,
|
|
47143
47566
|
CommandRegistry as d9,
|
|
47144
|
-
|
|
47145
|
-
|
|
47146
|
-
|
|
47147
|
-
|
|
47148
|
-
|
|
47149
|
-
|
|
47567
|
+
Button$1 as dA,
|
|
47568
|
+
buildRibbonTabDefinitions as dB,
|
|
47569
|
+
cloneDocument as dC,
|
|
47570
|
+
createDocument as dD,
|
|
47571
|
+
createEditorCommandBus as dE,
|
|
47572
|
+
createHeading as dF,
|
|
47573
|
+
createOasisEditor as dG,
|
|
47574
|
+
createOasisEditorContainer as dH,
|
|
47575
|
+
createParagraph as dI,
|
|
47576
|
+
createTable as dJ,
|
|
47577
|
+
mount as dK,
|
|
47578
|
+
normalizeDocument as dL,
|
|
47579
|
+
registerToolbarRenderer as dM,
|
|
47580
|
+
validateDocument as dN,
|
|
47150
47581
|
DEFAULT_PALETTE as da,
|
|
47151
47582
|
DialogFooter as db,
|
|
47152
|
-
|
|
47153
|
-
|
|
47154
|
-
|
|
47155
|
-
|
|
47156
|
-
|
|
47157
|
-
|
|
47158
|
-
|
|
47159
|
-
|
|
47160
|
-
|
|
47161
|
-
|
|
47162
|
-
|
|
47163
|
-
|
|
47164
|
-
|
|
47165
|
-
|
|
47166
|
-
|
|
47167
|
-
|
|
47168
|
-
|
|
47169
|
-
|
|
47170
|
-
|
|
47171
|
-
|
|
47172
|
-
|
|
47173
|
-
|
|
47174
|
-
|
|
47583
|
+
EDITOR_SCHEMA_VERSION as dc,
|
|
47584
|
+
FieldRow as dd,
|
|
47585
|
+
FloatingActionButton as de,
|
|
47586
|
+
GridPicker as df,
|
|
47587
|
+
Heading as dg,
|
|
47588
|
+
IconButton as dh,
|
|
47589
|
+
Menu as di,
|
|
47590
|
+
OASIS_BUILTIN_COMMANDS as dj,
|
|
47591
|
+
OASIS_MENU_ITEMS as dk,
|
|
47592
|
+
OASIS_TOOLBAR_ITEMS as dl,
|
|
47593
|
+
OasisEditorAppLazy as dm,
|
|
47594
|
+
OasisEditorContainer as dn,
|
|
47595
|
+
PluginCollection as dp,
|
|
47596
|
+
Popover as dq,
|
|
47597
|
+
RIBBON_TABS as dr,
|
|
47598
|
+
Select as ds,
|
|
47599
|
+
Separator as dt,
|
|
47600
|
+
SidePanel as du,
|
|
47601
|
+
SidePanelBody as dv,
|
|
47602
|
+
SidePanelFooter as dw,
|
|
47603
|
+
SidePanelHeader as dx,
|
|
47604
|
+
SplitButton as dy,
|
|
47605
|
+
StyleGallery as dz,
|
|
47175
47606
|
estimateTableBlockHeight as e,
|
|
47176
47607
|
getParagraphText as f,
|
|
47177
47608
|
getProjectedParagraphBlockHeight as g,
|