oasis-editor 0.0.138 → 0.0.139

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.
Files changed (45) hide show
  1. package/dist/{OasisEditorApp-DMI2ZfOd.js → OasisEditorApp-B1x9P0Ua.js} +50 -8
  2. package/dist/adapters/mountController.d.ts +11 -0
  3. package/dist/adapters/react.d.ts +8 -0
  4. package/dist/adapters/ui.d.ts +1 -1
  5. package/dist/adapters/vue.d.ts +10 -0
  6. package/dist/app/bootstrap/createOasisEditorApp.d.ts +9 -0
  7. package/dist/app/bootstrap/createOasisEditorContainer.d.ts +9 -0
  8. package/dist/app/client/OasisEditorClient.d.ts +254 -1
  9. package/dist/app/client/publicDocumentApi.d.ts +223 -0
  10. package/dist/app/controllers/documentIO/DocumentExporter.d.ts +10 -2
  11. package/dist/app/controllers/documentIO/DocumentImporter.d.ts +6 -0
  12. package/dist/app/controllers/useEditorDocumentIO.d.ts +4 -2
  13. package/dist/app/controllers/useEditorFindReplace.d.ts +7 -0
  14. package/dist/app/controllers/useEditorPersistence.d.ts +10 -0
  15. package/dist/app/services/FindReplaceService.d.ts +9 -0
  16. package/dist/app/services/indexedDbPersistence.d.ts +10 -1
  17. package/dist/app/services/tablePropertiesService.d.ts +12 -3
  18. package/dist/app/services/userPreferences.d.ts +4 -0
  19. package/dist/assets/{importDocxWorker-DBjcGf-C.js → importDocxWorker-B1vHeo5L.js} +1 -1
  20. package/dist/core/Editor.d.ts +33 -1
  21. package/dist/core/commands/CommandBus.d.ts +26 -0
  22. package/dist/core/commands/publicCommandTypes.d.ts +53 -0
  23. package/dist/core/model/types/document.d.ts +2 -0
  24. package/dist/core/plugin.d.ts +60 -0
  25. package/dist/import/DocumentFormatImporter.d.ts +20 -4
  26. package/dist/import/documentImporterRegistry.d.ts +6 -2
  27. package/dist/{index-M7h7REmM.js → index-BVWzLonI.js} +1182 -760
  28. package/dist/index.d.ts +3 -1
  29. package/dist/mountController.d.ts +11 -0
  30. package/dist/oasis-editor.js +44 -36
  31. package/dist/oasis-editor.umd.cjs +4 -4
  32. package/dist/react.d.ts +8 -0
  33. package/dist/ui/OasisEditorAppProps.d.ts +8 -4
  34. package/dist/ui/app/connectEditorClientHost.d.ts +12 -2
  35. package/dist/ui/app/createEditorCommandRuntime.d.ts +8 -1
  36. package/dist/ui/app/createEditorDocumentRuntime.d.ts +4 -2
  37. package/dist/ui/canvas/CanvasDebug.d.ts +15 -1
  38. package/dist/ui/components/Menubar/menuRegistry.d.ts +11 -0
  39. package/dist/ui/components/Toolbar/registry/ToolbarRegistry.d.ts +43 -7
  40. package/dist/ui/components/Toolbar/schema/items.d.ts +39 -7
  41. package/dist/ui/components/Toolbar/state/createToolbarApi.d.ts +8 -4
  42. package/dist/ui.d.ts +1 -1
  43. package/dist/ui.js +29 -30
  44. package/dist/vue.d.ts +10 -0
  45. package/package.json +1 -1
@@ -2731,7 +2731,7 @@ function OasisEditorAppLazy(props = {}) {
2731
2731
  onCleanup(() => {
2732
2732
  cancelled = true;
2733
2733
  });
2734
- import("./OasisEditorApp-DMI2ZfOd.js").then((m) => {
2734
+ import("./OasisEditorApp-B1x9P0Ua.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,1136 @@ 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
+ const next = cloneDocument(document2);
4385
+ next.schemaVersion = next.schemaVersion ?? EDITOR_SCHEMA_VERSION;
4386
+ return next;
4387
+ }
4388
+ function validateDocument(document2) {
4389
+ var _a2, _b2;
4390
+ const errors2 = [];
4391
+ if (!document2 || !document2.id || !((_a2 = document2.sections) == null ? void 0 : _a2.length)) errors2.push("Document must have an id and section");
4392
+ const ids = /* @__PURE__ */ new Set();
4393
+ for (const paragraph of getDocumentParagraphsCanonical(document2)) {
4394
+ if (ids.has(paragraph.id)) errors2.push(`Duplicate node id: ${paragraph.id}`);
4395
+ ids.add(paragraph.id);
4396
+ if (!((_b2 = paragraph.runs) == null ? void 0 : _b2.length)) errors2.push(`Paragraph has no runs: ${paragraph.id}`);
4397
+ for (const run of paragraph.runs) {
4398
+ if (ids.has(run.id)) errors2.push(`Duplicate node id: ${run.id}`);
4399
+ ids.add(run.id);
4400
+ }
4401
+ }
4402
+ return errors2.length ? { ok: false, error: { code: "VALIDATION_FAILED", message: errors2.join("; "), details: errors2 } } : { ok: true, value: true, version: 0, warnings: [] };
4403
+ }
4404
+ function createDocument(options = {}) {
4405
+ return createEditorDocument(options.blocks ?? [createEditorParagraph("")], void 0, void 0, void 0, {
4406
+ title: options.title ?? "Untitled document"
4407
+ });
4408
+ }
4409
+ const createParagraph = createEditorParagraph;
4410
+ function createHeading(text, options = {}) {
4411
+ const paragraph = createEditorParagraph(text);
4412
+ paragraph.style = { styleId: `heading${options.level ?? 1}` };
4413
+ return paragraph;
4414
+ }
4415
+ function createTable(rows) {
4416
+ return createEditorTable(rows.map((row) => createEditorTableRow(row.map((text) => createEditorTableCell([createEditorParagraph(text)])))));
4417
+ }
4418
+ function allNodes(document2) {
4419
+ const result = [{ id: document2.id, type: "document", node: document2 }];
4420
+ const visitBlocks = (blocks) => blocks.forEach((block) => {
4421
+ result.push({ id: block.id, type: block.type, text: block.type === "paragraph" ? getParagraphText(block) : void 0, node: block });
4422
+ if (block.type === "paragraph") block.runs.forEach((run) => result.push({ id: run.id, type: "run", text: run.text, node: run }));
4423
+ else block.rows.forEach((row) => {
4424
+ result.push({ id: row.id, type: "table-row", node: row });
4425
+ row.cells.forEach((cell) => {
4426
+ result.push({ id: cell.id, type: "table-cell", node: cell });
4427
+ visitBlocks(cell.blocks);
4428
+ });
4429
+ });
4430
+ });
4431
+ document2.sections.forEach((section) => visitBlocks(section.blocks));
4432
+ return result;
4433
+ }
4434
+ function resolveParagraph(document2, selector) {
4435
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
4436
+ const paragraphs = getDocumentParagraphsCanonical(document2);
4437
+ if ("nodeId" in selector) return paragraphs.find((p) => p.id === selector.nodeId) ?? null;
4438
+ if ("text" in selector) {
4439
+ const found = paragraphs.filter((p) => getParagraphText(p).includes(selector.text));
4440
+ const index = selector.occurrence ?? 0;
4441
+ if (found.length !== 1 && selector.occurrence === void 0) throw new Error(found.length > 1 ? "AMBIGUOUS_SELECTOR" : "NODE_NOT_FOUND");
4442
+ return found[index] ?? null;
4443
+ }
4444
+ if ("headingPath" in selector) {
4445
+ const index = selector.headingPath.length ? selector.headingPath.length - 1 : 0;
4446
+ return paragraphs.filter((p) => {
4447
+ var _a3, _b3;
4448
+ return (_b3 = (_a3 = p.style) == null ? void 0 : _a3.styleId) == null ? void 0 : _b3.startsWith("heading");
4449
+ })[index] ?? null;
4450
+ }
4451
+ if ("bookmark" in selector) {
4452
+ 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);
4453
+ const paragraphId = (_c = bookmark == null ? void 0 : bookmark.start) == null ? void 0 : _c.paragraphId;
4454
+ return paragraphId ? paragraphs.find((p) => p.id === paragraphId) ?? null : null;
4455
+ }
4456
+ if ("contentControlTag" in selector) {
4457
+ const tagged = paragraphs.find((p) => {
4458
+ var _a3;
4459
+ return (_a3 = p.sdtWrappers) == null ? void 0 : _a3.some((wrapper) => wrapper.sdtPr.tag === selector.contentControlTag || wrapper.sdtPr.alias === selector.contentControlTag);
4460
+ });
4461
+ if (tagged) return tagged;
4462
+ const taggedTable = allNodes(document2).find((node) => {
4463
+ var _a3;
4464
+ return node.type === "table" && ((_a3 = node.node.sdtWrappers) == null ? void 0 : _a3.some((wrapper) => {
4465
+ var _a4, _b3;
4466
+ return ((_a4 = wrapper.sdtPr) == null ? void 0 : _a4.tag) === selector.contentControlTag || ((_b3 = wrapper.sdtPr) == null ? void 0 : _b3.alias) === selector.contentControlTag;
4467
+ }));
4468
+ });
4469
+ 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");
4470
+ return firstCellParagraph ?? null;
4471
+ }
4472
+ if ("tableId" in selector) {
4473
+ const table = (_j = allNodes(document2).find((n2) => n2.id === selector.tableId && n2.type === "table")) == null ? void 0 : _j.node;
4474
+ 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;
4475
+ }
4476
+ return null;
4477
+ }
4478
+ function replaceParagraph(document2, id, update) {
4479
+ const visit = (blocks) => {
4480
+ for (let i = 0; i < blocks.length; i++) {
4481
+ const block = blocks[i];
4482
+ if (block.type === "paragraph" && block.id === id) {
4483
+ blocks[i] = update(block);
4484
+ return true;
4485
+ }
4486
+ if (block.type === "table" && block.rows.some((r) => r.cells.some((c) => visit(c.blocks)))) return true;
4487
+ }
4488
+ return false;
4489
+ };
4490
+ document2.sections.some((section) => visit(section.blocks));
4491
+ }
4492
+ function queryDocument(document2) {
4493
+ const outline = () => getDocumentParagraphsCanonical(document2).flatMap((p) => {
4494
+ var _a2, _b2;
4495
+ const match = (_b2 = (_a2 = p.style) == null ? void 0 : _a2.styleId) == null ? void 0 : _b2.match(/^heading(\d+)$/);
4496
+ return match ? [{ id: p.id, level: Number(match[1]), text: getParagraphText(p), path: [getParagraphText(p)] }] : [];
4497
+ });
4498
+ return {
4499
+ snapshot: () => ({ schemaVersion: document2.schemaVersion ?? EDITOR_SCHEMA_VERSION, documentId: document2.id, text: getDocumentParagraphsCanonical(document2).map(getParagraphText).join("\n"), outline: outline(), nodes: allNodes(document2) }),
4500
+ getText: (target) => {
4501
+ var _a2;
4502
+ if (!target) return getDocumentParagraphsCanonical(document2).map(getParagraphText).join("\n");
4503
+ 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("")) ?? "";
4504
+ return getParagraphText(resolveParagraph(document2, target) ?? createEditorParagraph(""));
4505
+ },
4506
+ getNode: (selector) => {
4507
+ const paragraph = resolveParagraph(document2, selector);
4508
+ return paragraph ? { id: paragraph.id, type: "paragraph", text: getParagraphText(paragraph), node: paragraph } : allNodes(document2).find((n2) => "nodeId" in selector && n2.id === selector.nodeId) ?? null;
4509
+ },
4510
+ find: (text) => getDocumentParagraphsCanonical(document2).flatMap((p) => {
4511
+ const value = getParagraphText(p);
4512
+ const matches = [];
4513
+ let start = value.indexOf(text);
4514
+ while (start >= 0) {
4515
+ matches.push({ selector: { nodeId: p.id }, paragraphId: p.id, text, start, end: start + text.length });
4516
+ start = value.indexOf(text, start + Math.max(1, text.length));
4517
+ }
4518
+ return matches;
4519
+ }),
4520
+ outline
4521
+ };
4522
+ }
4523
+ function applyDocumentOperations(document2, operations) {
4524
+ var _a2, _b2, _c, _d;
4525
+ const next = normalizeDocument(document2);
4526
+ const changedNodeIds = [];
4527
+ const createdNodeIds = [];
4528
+ for (const operation of operations) {
4529
+ if (operation.op === "insertText" || operation.op === "replaceText") {
4530
+ const paragraph = resolveParagraph(next, operation.target);
4531
+ if (!paragraph) throw new Error("NODE_NOT_FOUND");
4532
+ const old = getParagraphText(paragraph);
4533
+ const offset = operation.op === "replaceText" ? 0 : Math.min(operation.offset ?? old.length, old.length);
4534
+ const text = operation.op === "replaceText" ? operation.text : old.slice(0, offset) + operation.text + old.slice(offset);
4535
+ replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text }] }));
4536
+ changedNodeIds.push(paragraph.id);
4537
+ } else if (operation.op === "deleteRange") {
4538
+ if (operation.range.start.paragraphId !== operation.range.end.paragraphId) throw new Error("INVALID_RANGE");
4539
+ const paragraph = getDocumentParagraphsCanonical(next).find((p) => p.id === operation.range.start.paragraphId);
4540
+ if (!paragraph) throw new Error("NODE_NOT_FOUND");
4541
+ const text = getParagraphText(paragraph);
4542
+ const start = Math.max(0, Math.min(operation.range.start.offset, text.length));
4543
+ const end = Math.max(start, Math.min(operation.range.end.offset, text.length));
4544
+ replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text: text.slice(0, start) + text.slice(end) }] }));
4545
+ changedNodeIds.push(paragraph.id);
4546
+ } else if (operation.op === "setParagraphStyle") {
4547
+ const paragraph = resolveParagraph(next, operation.target);
4548
+ if (!paragraph) throw new Error("NODE_NOT_FOUND");
4549
+ replaceParagraph(next, paragraph.id, (p) => ({ ...p, style: operation.style }));
4550
+ changedNodeIds.push(paragraph.id);
4551
+ } else if (operation.op === "setTextStyle") {
4552
+ const paragraph = resolveParagraph(next, operation.target);
4553
+ if (!paragraph) throw new Error("NODE_NOT_FOUND");
4554
+ replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: p.runs.map((r) => ({ ...r, styles: { ...r.styles, ...operation.style } })) }));
4555
+ changedNodeIds.push(paragraph.id);
4556
+ } else if (operation.op === "insertParagraph" || operation.op === "insertBlocks" || operation.op === "insertTable") {
4557
+ const blocks = operation.op === "insertParagraph" ? [createEditorParagraph(operation.text ?? "")] : operation.op === "insertTable" ? [createTable(operation.rows)] : operation.blocks;
4558
+ next.sections[0].blocks.push(...blocks);
4559
+ blocks.forEach((b) => {
4560
+ createdNodeIds.push(b.id);
4561
+ changedNodeIds.push(b.id);
4562
+ });
4563
+ } else if (operation.op === "updateTableCell") {
4564
+ const table = (_a2 = allNodes(next).find((n2) => n2.id === operation.target.tableId && n2.type === "table")) == null ? void 0 : _a2.node;
4565
+ 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");
4566
+ if (!paragraph) throw new Error("NODE_NOT_FOUND");
4567
+ replaceParagraph(next, paragraph.id, (p) => ({ ...p, runs: [{ ...p.runs[0], text: operation.text }] }));
4568
+ changedNodeIds.push(paragraph.id, operation.target.tableId);
4569
+ } else if (operation.op === "deleteNode") {
4570
+ const target = "nodeId" in operation.target ? operation.target.nodeId : (_d = resolveParagraph(next, operation.target)) == null ? void 0 : _d.id;
4571
+ if (!target) throw new Error("NODE_NOT_FOUND");
4572
+ const remove = (blocks) => {
4573
+ const index = blocks.findIndex((b) => b.id === target);
4574
+ if (index >= 0) {
4575
+ blocks.splice(index, 1);
4576
+ return true;
4577
+ }
4578
+ return blocks.some((b) => b.type === "table" && b.rows.some((r) => r.cells.some((c) => remove(c.blocks))));
4579
+ };
4580
+ if (!next.sections.some((section) => remove(section.blocks))) throw new Error("NODE_NOT_FOUND");
4581
+ changedNodeIds.push(target);
4582
+ } else throw new Error("UNSUPPORTED_OPERATION");
4583
+ }
4584
+ const validation = validateDocument(next);
4585
+ if (!validation.ok) throw new Error("VALIDATION_FAILED");
4586
+ return { document: next, value: { changedNodeIds: [...new Set(changedNodeIds)], createdNodeIds } };
4587
+ }
4588
+ function disabledCommandState() {
4589
+ return { isEnabled: false, isActive: false, value: void 0 };
4590
+ }
4591
+ function createOasisEditorClient() {
4592
+ let host = null;
4593
+ let resolveReady;
4594
+ let rejectReady;
4595
+ const listeners = /* @__PURE__ */ new Map();
4596
+ let disposed = false;
4597
+ let disposeHost;
4598
+ let dirty = false;
4599
+ let version2 = 0;
4600
+ const idempotent = /* @__PURE__ */ new Map();
4601
+ const ready = new Promise((resolve, reject) => {
4602
+ resolveReady = resolve;
4603
+ rejectReady = reject;
4604
+ });
4605
+ const emit = (event, payload) => {
4606
+ if (event === "change") {
4607
+ dirty = true;
4608
+ }
4609
+ const handlers = listeners.get(event);
4610
+ if (!handlers) return;
4611
+ for (const handler of [...handlers]) {
4612
+ handler(payload);
4613
+ }
4614
+ };
4615
+ const addListener = (event, callback) => {
4616
+ const handlers = listeners.get(event) ?? /* @__PURE__ */ new Set();
4617
+ handlers.add(
4618
+ callback
4619
+ );
4620
+ listeners.set(event, handlers);
4621
+ return () => {
4622
+ handlers.delete(
4623
+ callback
4624
+ );
4625
+ if (handlers.size === 0) listeners.delete(event);
4626
+ };
4627
+ };
4628
+ const getRuntimeEditor = () => (host == null ? void 0 : host.getRuntimeEditor()) ?? null;
4629
+ const requireHost = () => {
4630
+ if (!host) throw new Error("Oasis editor client is not mounted.");
4631
+ return host;
4632
+ };
4633
+ const normalizePayload = (command, payloadOverride) => {
4634
+ const resolved = resolveCommandRef(command, payloadOverride);
4635
+ if (resolved.name === "insertTable" && resolved.payload && typeof resolved.payload === "object") {
4636
+ const payload = resolved.payload;
4637
+ return {
4638
+ ...resolved,
4639
+ payload: {
4640
+ rows: payload.rows,
4641
+ cols: payload.cols ?? payload.columns
4642
+ }
4643
+ };
4644
+ }
4645
+ if (resolved.name === "setFontSize" && resolved.payload && typeof resolved.payload === "object") {
4646
+ const payload = resolved.payload;
4647
+ return { ...resolved, payload: payload.size };
4648
+ }
4649
+ return resolved;
4650
+ };
4651
+ const commands = {
4652
+ execute(command, payloadOverride) {
4653
+ const editor = getRuntimeEditor();
4654
+ if (!editor) {
4655
+ throw new Error("Oasis editor runtime is not ready.");
4656
+ }
4657
+ const resolved = normalizePayload(command, payloadOverride);
4658
+ return editor.commands.execute(resolved.name, resolved.payload);
4659
+ },
4660
+ canExecute(command, payloadOverride) {
4661
+ const editor = getRuntimeEditor();
4662
+ if (!editor) return false;
4663
+ const resolved = normalizePayload(command, payloadOverride);
4664
+ return editor.commands.canExecute(resolved.name, resolved.payload);
4665
+ },
4666
+ state(command) {
4667
+ var _a2;
4668
+ const editor = getRuntimeEditor();
4669
+ if (!editor) return disabledCommandState();
4670
+ const resolved = resolveCommandRef(command);
4671
+ const registered = editor.commands.get(resolved.name);
4672
+ const state = (_a2 = registered == null ? void 0 : registered.refresh) == null ? void 0 : _a2.call(registered, resolved.payload);
4673
+ return {
4674
+ isEnabled: (state == null ? void 0 : state.isEnabled) ?? editor.commands.has(resolved.name) ?? false,
4675
+ isActive: Boolean(state == null ? void 0 : state.isActive),
4676
+ value: state == null ? void 0 : state.value
4677
+ };
4678
+ }
4679
+ };
4680
+ return {
4681
+ ready,
4682
+ commands,
4683
+ connectHost(nextHost) {
4684
+ host = nextHost;
4685
+ },
4686
+ setDispose(dispose2) {
4687
+ disposeHost = dispose2;
4688
+ },
4689
+ resolveReady(editor) {
4690
+ dirty = false;
4691
+ resolveReady(editor);
4692
+ emit("ready", editor);
4693
+ },
4694
+ rejectReady(error) {
4695
+ rejectReady(error);
4696
+ emit("error", error);
4697
+ },
4698
+ emit,
4699
+ dispose() {
4700
+ if (disposed) return;
4701
+ disposed = true;
4702
+ return disposeHost == null ? void 0 : disposeHost();
4703
+ },
4704
+ getState() {
4705
+ return requireHost().getState();
4706
+ },
4707
+ getDocument() {
4708
+ return requireHost().getDocument();
4709
+ },
4710
+ setDocument(document2) {
4711
+ requireHost().setDocument(document2);
4712
+ version2 += 1;
4713
+ },
4714
+ loadDocument(document2) {
4715
+ requireHost().setDocument(document2);
4716
+ version2 += 1;
4717
+ dirty = false;
4718
+ },
4719
+ updateDocument(updater) {
4720
+ const currentHost = requireHost();
4721
+ if (currentHost.applyTransactionalState) currentHost.applyTransactionalState((state) => ({ ...state, document: updater(state.document) }));
4722
+ else currentHost.setDocument(updater(currentHost.getDocument()));
4723
+ version2 += 1;
4724
+ },
4725
+ resetDocument() {
4726
+ requireHost().resetDocument();
4727
+ version2 += 1;
4728
+ dirty = false;
4729
+ },
4730
+ async save() {
4731
+ await requireHost().saveDocument();
4732
+ dirty = false;
4733
+ },
4734
+ isDirty() {
4735
+ return dirty;
4736
+ },
4737
+ markClean() {
4738
+ dirty = false;
4739
+ },
4740
+ getSelection() {
4741
+ return requireHost().getSelection();
4742
+ },
4743
+ setSelection(selection) {
4744
+ requireHost().setSelection(selection);
4745
+ },
4746
+ focusEditor() {
4747
+ requireHost().focus();
4748
+ },
4749
+ blurEditor() {
4750
+ requireHost().blur();
4751
+ },
4752
+ document: {
4753
+ get: () => requireHost().getDocument(),
4754
+ set: (document2) => {
4755
+ requireHost().setDocument(document2);
4756
+ version2 += 1;
4757
+ },
4758
+ load: (document2) => {
4759
+ requireHost().setDocument(document2);
4760
+ version2 += 1;
4761
+ dirty = false;
4762
+ },
4763
+ update: (updater) => {
4764
+ const currentHost = requireHost();
4765
+ if (currentHost.applyTransactionalState) currentHost.applyTransactionalState((state) => ({ ...state, document: updater(state.document) }));
4766
+ else currentHost.setDocument(updater(currentHost.getDocument()));
4767
+ version2 += 1;
4768
+ },
4769
+ reset: () => {
4770
+ requireHost().resetDocument();
4771
+ version2 += 1;
4772
+ dirty = false;
4773
+ },
4774
+ save: async () => {
4775
+ await requireHost().saveDocument();
4776
+ dirty = false;
4777
+ },
4778
+ isDirty: () => dirty,
4779
+ markClean: () => {
4780
+ dirty = false;
4781
+ },
4782
+ version: () => version2
4783
+ },
4784
+ selection: {
4785
+ get: () => requireHost().getSelection(),
4786
+ set: (selection) => requireHost().setSelection(selection)
4787
+ },
4788
+ focus: {
4789
+ focus: () => requireHost().focus(),
4790
+ blur: () => requireHost().blur()
4791
+ },
4792
+ history: {
4793
+ undo: () => commands.execute("undo"),
4794
+ redo: () => commands.execute("redo"),
4795
+ canUndo: () => commands.canExecute("undo"),
4796
+ canRedo: () => commands.canExecute("redo"),
4797
+ clear: () => requireHost().clearHistory()
4798
+ },
4799
+ import: {
4800
+ docx: (file) => requireHost().importDocx(file)
4801
+ },
4802
+ export: {
4803
+ docx: () => requireHost().exportDocx(),
4804
+ pdf: () => requireHost().exportPdf()
4805
+ },
4806
+ query: {
4807
+ snapshot: () => queryDocument(requireHost().getDocument()).snapshot(),
4808
+ getText: (target) => queryDocument(requireHost().getDocument()).getText(target),
4809
+ getNode: (selector) => queryDocument(requireHost().getDocument()).getNode(selector),
4810
+ find: (text) => queryDocument(requireHost().getDocument()).find(text),
4811
+ outline: () => queryDocument(requireHost().getDocument()).outline()
4812
+ },
4813
+ edit: {
4814
+ async apply(request) {
4815
+ if (request.expectedVersion !== void 0 && request.expectedVersion !== version2) {
4816
+ return { ok: false, error: { code: "DOCUMENT_VERSION_CONFLICT", message: "Document version does not match expectedVersion", expectedVersion: request.expectedVersion, actualVersion: version2 } };
4817
+ }
4818
+ if (request.idempotencyKey && idempotent.has(request.idempotencyKey)) return idempotent.get(request.idempotencyKey);
4819
+ const host2 = requireHost();
4820
+ try {
4821
+ const applied = applyDocumentOperations(host2.getDocument(), request.operations);
4822
+ if (host2.applyTransactionalState) host2.applyTransactionalState((state) => ({ ...state, document: applied.document }));
4823
+ else host2.setDocument(applied.document);
4824
+ version2 += 1;
4825
+ const result = { ok: true, value: applied.value, version: version2, warnings: [] };
4826
+ if (request.idempotencyKey) idempotent.set(request.idempotencyKey, result);
4827
+ return result;
4828
+ } catch (error) {
4829
+ const message = error instanceof Error ? error.message : "Edit failed";
4830
+ 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";
4831
+ return { ok: false, error: { code: code2, message } };
4832
+ }
4833
+ }
4834
+ },
4835
+ io: {
4836
+ async import(request) {
4837
+ var _a2, _b2;
4838
+ if ((_a2 = request.signal) == null ? void 0 : _a2.aborted) return { ok: false, error: { code: "ABORTED", message: "Import aborted" } };
4839
+ try {
4840
+ const data = request.data instanceof Blob ? request.data : new Blob([request.data]);
4841
+ const file = new File([data], request.filename ?? "document.docx", { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
4842
+ await requireHost().importDocx(file);
4843
+ version2 += 1;
4844
+ (_b2 = request.onProgress) == null ? void 0 : _b2.call(request, { phase: "done", progress: 100 });
4845
+ return { ok: true, value: { format: "docx" }, version: version2, warnings: [] };
4846
+ } catch (error) {
4847
+ return { ok: false, error: { code: "IMPORT_FAILED", message: error instanceof Error ? error.message : "Import failed" } };
4848
+ }
4849
+ },
4850
+ async export(request) {
4851
+ try {
4852
+ const value = request.format === "docx" ? await requireHost().exportDocxBlob() : await requireHost().exportPdfBlob();
4853
+ return { ok: true, value: { format: request.format, blob: value, arrayBuffer: () => value.arrayBuffer() }, version: version2, warnings: [] };
4854
+ } catch (error) {
4855
+ return { ok: false, error: { code: "EXPORT_FAILED", message: error instanceof Error ? error.message : "Export failed" } };
4856
+ }
4857
+ }
4858
+ },
4859
+ ui: {
4860
+ state: () => {
4861
+ var _a2, _b2;
4862
+ return ((_b2 = (_a2 = requireHost()).getUiState) == null ? void 0 : _b2.call(_a2)) ?? {};
4863
+ },
4864
+ update: (patch) => {
4865
+ var _a2, _b2;
4866
+ const next = ((_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, patch)) ?? {};
4867
+ emit("uiChange", next);
4868
+ return next;
4869
+ },
4870
+ setReadOnly: (value) => {
4871
+ var _a2, _b2;
4872
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { readOnly: value });
4873
+ },
4874
+ zoom: { get: () => {
4875
+ var _a2, _b2;
4876
+ return ((_b2 = (_a2 = requireHost()).getZoom) == null ? void 0 : _b2.call(_a2)) ?? 100;
4877
+ }, set: (value) => {
4878
+ var _a2, _b2;
4879
+ return (_b2 = (_a2 = requireHost()).setZoom) == null ? void 0 : _b2.call(_a2, value);
4880
+ }, adjust: (delta) => {
4881
+ var _a2, _b2;
4882
+ return (_b2 = (_a2 = requireHost()).adjustZoom) == null ? void 0 : _b2.call(_a2, delta);
4883
+ } },
4884
+ chrome: { setVisible: (value) => {
4885
+ var _a2, _b2;
4886
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showChrome: value });
4887
+ } },
4888
+ titleBar: { setVisible: (value) => {
4889
+ var _a2, _b2;
4890
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showTitleBar: value });
4891
+ } },
4892
+ menubar: { setVisible: (value) => {
4893
+ var _a2, _b2;
4894
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showMenubar: value });
4895
+ }, items: { register: (...args) => {
4896
+ var _a2;
4897
+ return (_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.register(...args);
4898
+ }, unregister: (id) => {
4899
+ var _a2;
4900
+ return (_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.unregister(id);
4901
+ }, getItems: () => {
4902
+ var _a2;
4903
+ return ((_a2 = requireHost().menuRegistry) == null ? void 0 : _a2.getItems()) ?? [];
4904
+ } } },
4905
+ toolbar: { setVisible: (value) => {
4906
+ var _a2, _b2;
4907
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showToolbar: value });
4908
+ }, items: { register: (...args) => {
4909
+ var _a2;
4910
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.register(...args);
4911
+ }, insertBefore: (...args) => {
4912
+ var _a2;
4913
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.insertBefore(...args);
4914
+ }, insertAfter: (...args) => {
4915
+ var _a2;
4916
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.insertAfter(...args);
4917
+ }, replace: (...args) => {
4918
+ var _a2;
4919
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.replace(...args);
4920
+ }, remove: (id) => {
4921
+ var _a2;
4922
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.remove(id);
4923
+ }, move: (...args) => {
4924
+ var _a2;
4925
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.move(...args);
4926
+ }, get: (id) => {
4927
+ var _a2;
4928
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.get(id);
4929
+ }, getOrdered: () => {
4930
+ var _a2;
4931
+ return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.getOrdered()) ?? [];
4932
+ }, getItems: () => {
4933
+ var _a2;
4934
+ return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.getItems()) ?? [];
4935
+ }, clear: () => {
4936
+ var _a2;
4937
+ return (_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.clear();
4938
+ }, onChange: (cb) => {
4939
+ var _a2;
4940
+ return ((_a2 = requireHost().toolbarRegistry) == null ? void 0 : _a2.onChange(cb)) ?? (() => void 0);
4941
+ } } },
4942
+ outline: { setVisible: (value) => {
4943
+ var _a2, _b2;
4944
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { showOutline: value });
4945
+ } },
4946
+ shell: { set: (shell) => {
4947
+ var _a2, _b2;
4948
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { shell });
4949
+ } },
4950
+ locale: { set: (locale) => {
4951
+ var _a2, _b2;
4952
+ (_b2 = (_a2 = requireHost()).updateUiState) == null ? void 0 : _b2.call(_a2, { locale });
4953
+ } }
4954
+ },
4955
+ on: addListener,
4956
+ once(event, callback) {
4957
+ const unsubscribe = addListener(event, (payload) => {
4958
+ unsubscribe();
4959
+ callback(payload);
4960
+ });
4961
+ return unsubscribe;
4962
+ },
4963
+ off(event, callback) {
4964
+ const handlers = listeners.get(event);
4965
+ if (!handlers) return;
4966
+ handlers.delete(
4967
+ callback
4968
+ );
4969
+ if (handlers.size === 0) listeners.delete(event);
4970
+ }
4711
4971
  };
4712
4972
  }
4713
- function withDefaultTableStyles(styles) {
4714
- const defaults = Object.fromEntries(
4715
- Object.entries(DEFAULT_TABLE_STYLES).filter(([id]) => !(id in styles))
4973
+ function createOasisEditor(container, props = {}) {
4974
+ const client = createOasisEditorClient();
4975
+ const dispose2 = render(
4976
+ () => OasisEditorAppLazy({ ...props, runtime: { ...props.runtime, client } }),
4977
+ container
4716
4978
  );
4717
- return { ...styles, ...defaults };
4979
+ client.setDispose(() => {
4980
+ dispose2();
4981
+ container.innerHTML = "";
4982
+ });
4983
+ return client;
4718
4984
  }
4719
- function createEditorDocument(blocks, pageSettings, sections, styles, metadata, assets) {
4720
- const normalizedPageSettings = normalizePageSettings(
4721
- pageSettings ? {
4722
- width: pageSettings.width,
4723
- height: pageSettings.height,
4724
- orientation: pageSettings.orientation,
4725
- margins: { ...pageSettings.margins },
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 }
4985
+ function OasisEditorContainer(props) {
4986
+ return createComponent(OasisEditorAppLazy, mergeProps(props, {
4987
+ get ui() {
4988
+ return {
4989
+ ...props.ui,
4990
+ showChrome: false
4991
+ };
4732
4992
  }
4993
+ }));
4994
+ }
4995
+ function createOasisEditorContainer(container, props = {}) {
4996
+ const client = createOasisEditorClient();
4997
+ const dispose2 = render(
4998
+ () => OasisEditorContainer({
4999
+ ...props,
5000
+ runtime: { ...props.runtime, client }
5001
+ }),
5002
+ container
4733
5003
  );
4734
- const document2 = {
4735
- id: createEditorNodeId("document"),
4736
- pageSettings: normalizedPageSettings,
4737
- sections: sections ?? [
4738
- {
4739
- id: "section:default",
4740
- blocks,
4741
- pageSettings: normalizedPageSettings
5004
+ client.setDispose(() => {
5005
+ dispose2();
5006
+ container.innerHTML = "";
5007
+ });
5008
+ return client;
5009
+ }
5010
+ const $RAW = Symbol("store-raw"), $NODE = Symbol("store-node"), $HAS = Symbol("store-has"), $SELF = Symbol("store-self");
5011
+ function wrap$1(value) {
5012
+ let p = value[$PROXY];
5013
+ if (!p) {
5014
+ Object.defineProperty(value, $PROXY, {
5015
+ value: p = new Proxy(value, proxyTraps$1)
5016
+ });
5017
+ if (!Array.isArray(value)) {
5018
+ const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
5019
+ for (let i = 0, l = keys.length; i < l; i++) {
5020
+ const prop = keys[i];
5021
+ if (desc[prop].get) {
5022
+ Object.defineProperty(value, prop, {
5023
+ enumerable: desc[prop].enumerable,
5024
+ get: desc[prop].get.bind(p)
5025
+ });
5026
+ }
4742
5027
  }
4743
- ],
4744
- styles: styles ? withDefaultTableStyles(styles) : { ...DEFAULT_EDITOR_STYLES },
4745
- metadata: metadata ?? { title: "Untitled document" },
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;
5028
+ }
5029
+ }
5030
+ return p;
4753
5031
  }
4754
- function getDocumentCharacterCount(document2) {
4755
- return getDocumentParagraphsCanonical(document2).reduce(
4756
- (sum, p) => sum + getParagraphLength(p),
4757
- 0
4758
- );
5032
+ function isWrappable(obj) {
5033
+ let proto;
5034
+ return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
4759
5035
  }
4760
- function getDocumentWordCount(document2) {
4761
- const paragraphs = getDocumentParagraphsCanonical(document2);
4762
- let totalWords = 0;
4763
- for (const paragraph of paragraphs) {
4764
- const text = paragraph.runs.reduce(
4765
- (sum, run) => sum + run.text,
4766
- ""
4767
- );
4768
- if (!text.trim()) continue;
4769
- const words = text.split(/[\s\p{P}]+/u).filter((word) => word.length > 0);
4770
- totalWords += words.length;
5036
+ function unwrap(item, set = /* @__PURE__ */ new Set()) {
5037
+ let result, unwrapped, v, prop;
5038
+ if (result = item != null && item[$RAW]) return result;
5039
+ if (!isWrappable(item) || set.has(item)) return item;
5040
+ if (Array.isArray(item)) {
5041
+ if (Object.isFrozen(item)) item = item.slice(0);
5042
+ else set.add(item);
5043
+ for (let i = 0, l = item.length; i < l; i++) {
5044
+ v = item[i];
5045
+ if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
5046
+ }
5047
+ } else {
5048
+ if (Object.isFrozen(item)) item = Object.assign({}, item);
5049
+ else set.add(item);
5050
+ const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
5051
+ for (let i = 0, l = keys.length; i < l; i++) {
5052
+ prop = keys[i];
5053
+ if (desc[prop].get) continue;
5054
+ v = item[prop];
5055
+ if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
5056
+ }
4771
5057
  }
4772
- return totalWords;
5058
+ return item;
4773
5059
  }
4774
- function findParagraphIndex(paragraphs, paragraphId) {
4775
- const index = paragraphs.findIndex(
4776
- (paragraph) => paragraph.id === paragraphId
4777
- );
4778
- return index === -1 ? 0 : index;
5060
+ function getNodes(target, symbol) {
5061
+ let nodes = target[symbol];
5062
+ if (!nodes) Object.defineProperty(target, symbol, {
5063
+ value: nodes = /* @__PURE__ */ Object.create(null)
5064
+ });
5065
+ return nodes;
4779
5066
  }
4780
- function findParagraphById(paragraphs, paragraphId) {
4781
- return paragraphs[findParagraphIndex(paragraphs, paragraphId)];
5067
+ function getNode(nodes, property, value) {
5068
+ if (nodes[property]) return nodes[property];
5069
+ const [s, set] = createSignal(value, {
5070
+ equals: false,
5071
+ internal: true
5072
+ });
5073
+ s.$ = set;
5074
+ return nodes[property] = s;
4782
5075
  }
4783
- function clampOffset(offset, paragraph) {
4784
- return Math.max(0, Math.min(offset, getParagraphLength(paragraph)));
5076
+ function proxyDescriptor$1(target, property) {
5077
+ const desc = Reflect.getOwnPropertyDescriptor(target, property);
5078
+ if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE) return desc;
5079
+ delete desc.value;
5080
+ delete desc.writable;
5081
+ desc.get = () => target[$PROXY][property];
5082
+ return desc;
4785
5083
  }
4786
- function clampPosition(state, position2) {
4787
- const paragraphs = getParagraphs(state);
4788
- const paragraph = findParagraphById(paragraphs, position2.paragraphId);
4789
- return clampPositionInParagraph(position2, paragraph);
5084
+ function trackSelf(target) {
5085
+ getListener() && getNode(getNodes(target, $NODE), $SELF)();
4790
5086
  }
4791
- function clampPositionInParagraph(position2, paragraph) {
4792
- const paragraphOffset = positionToParagraphOffset(paragraph, position2);
4793
- return paragraphOffsetToPosition(
4794
- paragraph,
4795
- clampOffset(paragraphOffset, paragraph)
4796
- );
5087
+ function ownKeys(target) {
5088
+ trackSelf(target);
5089
+ return Reflect.ownKeys(target);
4797
5090
  }
4798
- function createCollapsedSelection(position2) {
4799
- return {
4800
- anchor: position2,
4801
- focus: position2
4802
- };
5091
+ const proxyTraps$1 = {
5092
+ get(target, property, receiver) {
5093
+ if (property === $RAW) return target;
5094
+ if (property === $PROXY) return receiver;
5095
+ if (property === $TRACK) {
5096
+ trackSelf(target);
5097
+ return receiver;
5098
+ }
5099
+ const nodes = getNodes(target, $NODE);
5100
+ const tracked = nodes[property];
5101
+ let value = tracked ? tracked() : target[property];
5102
+ if (property === $NODE || property === $HAS || property === "__proto__") return value;
5103
+ if (!tracked) {
5104
+ const desc = Object.getOwnPropertyDescriptor(target, property);
5105
+ if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
5106
+ }
5107
+ return isWrappable(value) ? wrap$1(value) : value;
5108
+ },
5109
+ has(target, property) {
5110
+ if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
5111
+ getListener() && getNode(getNodes(target, $HAS), property)();
5112
+ return property in target;
5113
+ },
5114
+ set() {
5115
+ return true;
5116
+ },
5117
+ deleteProperty() {
5118
+ return true;
5119
+ },
5120
+ ownKeys,
5121
+ getOwnPropertyDescriptor: proxyDescriptor$1
5122
+ };
5123
+ function setProperty(state, property, value, deleting = false) {
5124
+ if (!deleting && state[property] === value) return;
5125
+ const prev = state[property], len = state.length;
5126
+ if (value === void 0) {
5127
+ delete state[property];
5128
+ if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
5129
+ } else {
5130
+ state[property] = value;
5131
+ if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
5132
+ }
5133
+ let nodes = getNodes(state, $NODE), node;
5134
+ if (node = getNode(nodes, property, prev)) node.$(() => value);
5135
+ if (Array.isArray(state) && state.length !== len) {
5136
+ for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
5137
+ (node = getNode(nodes, "length", len)) && node.$(state.length);
5138
+ }
5139
+ (node = nodes[$SELF]) && node.$();
4803
5140
  }
4804
- function isSelectionCollapsed(selection) {
4805
- return selection.anchor.paragraphId === selection.focus.paragraphId && selection.anchor.runId === selection.focus.runId && selection.anchor.offset === selection.focus.offset;
5141
+ function mergeStoreNode(state, value) {
5142
+ const keys = Object.keys(value);
5143
+ for (let i = 0; i < keys.length; i += 1) {
5144
+ const key = keys[i];
5145
+ setProperty(state, key, value[key]);
5146
+ }
4806
5147
  }
4807
- function normalizeSelection(state, providedParagraphs) {
4808
- const paragraphs = providedParagraphs ?? getParagraphs(state);
4809
- const indexById = new Map(
4810
- paragraphs.map(
4811
- (paragraph, index) => [paragraph.id, index]
4812
- )
4813
- );
4814
- const rawAnchorIndex = indexById.get(state.selection.anchor.paragraphId) ?? 0;
4815
- const rawFocusIndex = indexById.get(state.selection.focus.paragraphId) ?? 0;
4816
- const anchorParagraph = paragraphs[rawAnchorIndex] ?? paragraphs[0];
4817
- const focusParagraph = paragraphs[rawFocusIndex] ?? paragraphs[0];
4818
- const anchor = clampPositionInParagraph(
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
- };
5148
+ function updateArray(current, next) {
5149
+ if (typeof next === "function") next = next(current);
5150
+ next = unwrap(next);
5151
+ if (Array.isArray(next)) {
5152
+ if (current === next) return;
5153
+ let i = 0, len = next.length;
5154
+ for (; i < len; i++) {
5155
+ const value = next[i];
5156
+ if (current[i] !== value) setProperty(current, i, value);
5157
+ }
5158
+ setProperty(current, "length", len);
5159
+ } else mergeStoreNode(current, next);
4839
5160
  }
4840
- function createEditorStateFromDocument(document2, selection) {
4841
- var _a2, _b2, _c;
4842
- let normalizedDocument = {
4843
- ...document2,
4844
- sections: document2.sections && document2.sections.length > 0 ? document2.sections : [
4845
- {
4846
- id: "section:default",
4847
- blocks: [createEditorParagraph("")],
4848
- pageSettings: ((_a2 = getDocumentSectionsCanonical(document2)[0]) == null ? void 0 : _a2.pageSettings) ?? DEFAULT_EDITOR_PAGE_SETTINGS
5161
+ function updatePath(current, path, traversed = []) {
5162
+ let part, prev = current;
5163
+ if (path.length > 1) {
5164
+ part = path.shift();
5165
+ const partType = typeof part, isArray = Array.isArray(current);
5166
+ if (Array.isArray(part)) {
5167
+ for (let i = 0; i < part.length; i++) {
5168
+ updatePath(current, [part[i]].concat(path), traversed);
4849
5169
  }
4850
- ]
4851
- };
4852
- let allParagraphs = getDocumentParagraphsCanonical(normalizedDocument);
4853
- if (allParagraphs.length === 0) {
4854
- const fallbackParagraph = createEditorParagraph("");
4855
- const sections = getDocumentSectionsCanonical(normalizedDocument);
4856
- const firstSection = sections[0];
4857
- if (firstSection) {
4858
- const nextSections = [...sections];
4859
- nextSections[0] = {
4860
- ...firstSection,
4861
- blocks: [fallbackParagraph, ...firstSection.blocks]
4862
- };
4863
- normalizedDocument = {
4864
- ...normalizedDocument,
4865
- sections: nextSections
4866
- };
5170
+ return;
5171
+ } else if (isArray && partType === "function") {
5172
+ for (let i = 0; i < current.length; i++) {
5173
+ if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
5174
+ }
5175
+ return;
5176
+ } else if (isArray && partType === "object") {
5177
+ const {
5178
+ from = 0,
5179
+ to = current.length - 1,
5180
+ by = 1
5181
+ } = part;
5182
+ for (let i = from; i <= to; i += by) {
5183
+ updatePath(current, [i].concat(path), traversed);
5184
+ }
5185
+ return;
5186
+ } else if (path.length > 1) {
5187
+ updatePath(current[part], path, [part].concat(traversed));
5188
+ return;
4867
5189
  }
4868
- allParagraphs = getDocumentParagraphsCanonical(normalizedDocument);
5190
+ prev = current[part];
5191
+ traversed = [part].concat(traversed);
4869
5192
  }
4870
- let targetParagraph = allParagraphs[0];
4871
- let activeSectionIndex = 0;
4872
- let activeZone = "main";
4873
- {
4874
- const sections = getDocumentSectionsCanonical(normalizedDocument);
4875
- const firstSection = sections[0];
4876
- const mainParagraphs = (firstSection == null ? void 0 : firstSection.blocks.flatMap(getBlockParagraphs)) ?? [];
4877
- if (mainParagraphs.length > 0) {
4878
- targetParagraph = mainParagraphs[0];
4879
- activeZone = "main";
4880
- activeSectionIndex = 0;
5193
+ let value = path[0];
5194
+ if (typeof value === "function") {
5195
+ value = value(prev, traversed);
5196
+ if (value === prev) return;
5197
+ }
5198
+ if (part === void 0 && value == void 0) return;
5199
+ value = unwrap(value);
5200
+ if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
5201
+ mergeStoreNode(prev, value);
5202
+ } else setProperty(current, part, value);
5203
+ }
5204
+ function createStore(...[store, options]) {
5205
+ const unwrappedStore = unwrap(store || {});
5206
+ const isArray = Array.isArray(unwrappedStore);
5207
+ const wrappedStore = wrap$1(unwrappedStore);
5208
+ function setStore(...args) {
5209
+ batch(() => {
5210
+ isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
5211
+ });
5212
+ }
5213
+ return [wrappedStore, setStore];
5214
+ }
5215
+ const $ROOT = Symbol("store-root");
5216
+ function applyState(target, parent, property, merge, key) {
5217
+ const previous = parent[property];
5218
+ if (target === previous) return;
5219
+ const isArray = Array.isArray(target);
5220
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
5221
+ setProperty(parent, property, target);
5222
+ return;
5223
+ }
5224
+ if (isArray) {
5225
+ if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
5226
+ let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
5227
+ 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++) {
5228
+ applyState(target[start], previous, start, merge, key);
5229
+ }
5230
+ const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
5231
+ 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--) {
5232
+ temp[newEnd] = previous[end];
5233
+ }
5234
+ if (start > newEnd || start > end) {
5235
+ for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);
5236
+ for (; j < target.length; j++) {
5237
+ setProperty(previous, j, temp[j]);
5238
+ applyState(target[j], previous, j, merge, key);
5239
+ }
5240
+ if (previous.length > target.length) setProperty(previous, "length", target.length);
5241
+ return;
5242
+ }
5243
+ newIndicesNext = new Array(newEnd + 1);
5244
+ for (j = newEnd; j >= start; j--) {
5245
+ item = target[j];
5246
+ keyVal = key && item ? item[key] : item;
5247
+ i = newIndices.get(keyVal);
5248
+ newIndicesNext[j] = i === void 0 ? -1 : i;
5249
+ newIndices.set(keyVal, j);
5250
+ }
5251
+ for (i = start; i <= end; i++) {
5252
+ item = previous[i];
5253
+ keyVal = key && item ? item[key] : item;
5254
+ j = newIndices.get(keyVal);
5255
+ if (j !== void 0 && j !== -1) {
5256
+ temp[j] = previous[i];
5257
+ j = newIndicesNext[j];
5258
+ newIndices.set(keyVal, j);
5259
+ }
5260
+ }
5261
+ for (j = start; j < target.length; j++) {
5262
+ if (j in temp) {
5263
+ setProperty(previous, j, temp[j]);
5264
+ applyState(target[j], previous, j, merge, key);
5265
+ } else setProperty(previous, j, target[j]);
5266
+ }
4881
5267
  } else {
4882
- const headerParagraphs = ((_b2 = firstSection == null ? void 0 : firstSection.header) == null ? void 0 : _b2.flatMap(getBlockParagraphs)) ?? [];
4883
- const footerParagraphs = ((_c = firstSection == null ? void 0 : firstSection.footer) == null ? void 0 : _c.flatMap(getBlockParagraphs)) ?? [];
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";
5268
+ for (let i = 0, len = target.length; i < len; i++) {
5269
+ applyState(target[i], previous, i, merge, key);
4890
5270
  }
4891
- activeSectionIndex = 0;
4892
5271
  }
5272
+ if (previous.length > target.length) setProperty(previous, "length", target.length);
5273
+ return;
5274
+ }
5275
+ const targetKeys = Object.keys(target);
5276
+ for (let i = 0, len = targetKeys.length; i < len; i++) {
5277
+ applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
5278
+ }
5279
+ const previousKeys = Object.keys(previous);
5280
+ for (let i = 0, len = previousKeys.length; i < len; i++) {
5281
+ if (target[previousKeys[i]] === void 0) setProperty(previous, previousKeys[i], void 0);
4893
5282
  }
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
5283
  }
4909
- function createInitialEditorState() {
4910
- const paragraph = createEditorParagraph("");
4911
- const run = paragraph.runs[0];
4912
- return {
4913
- document: createEditorDocument([paragraph]),
4914
- selection: createCollapsedSelection({
4915
- paragraphId: paragraph.id,
4916
- runId: run.id,
4917
- offset: 0
4918
- }),
4919
- activeSectionIndex: 0,
4920
- activeZone: "main"
5284
+ function reconcile(value, options = {}) {
5285
+ const {
5286
+ merge,
5287
+ key = "id"
5288
+ } = options, v = unwrap(value);
5289
+ return (state) => {
5290
+ if (!isWrappable(state) || !isWrappable(v)) return v;
5291
+ const res = applyState(v, {
5292
+ [$ROOT]: state
5293
+ }, $ROOT, merge, key);
5294
+ return res === void 0 ? state : res;
4921
5295
  };
4922
5296
  }
4923
5297
  class PluginCollection {
@@ -5223,6 +5597,9 @@ function sortByOrder(items) {
5223
5597
  }).map((entry) => entry.item);
5224
5598
  }
5225
5599
  class Editor {
5600
+ /**
5601
+ * @param options - Options for synchronous construction (no plugins).
5602
+ */
5226
5603
  constructor(options = {}) {
5227
5604
  __publicField(this, "stateStore");
5228
5605
  __publicField(this, "setState");
@@ -5233,6 +5610,11 @@ class Editor {
5233
5610
  this.initializeState(options);
5234
5611
  this.pluginCollection = new PluginCollection(this, []);
5235
5612
  }
5613
+ /**
5614
+ * Creates an editor instance asynchronously, initializing all provided plugins.
5615
+ * @param options - Options including plugins to load.
5616
+ * @returns A promise that resolves to the initialized editor.
5617
+ */
5236
5618
  static async create(options = {}) {
5237
5619
  const { plugins = [], ...syncOptions } = options;
5238
5620
  const editor = new Editor(syncOptions);
@@ -5247,26 +5629,44 @@ class Editor {
5247
5629
  this.setState = setState;
5248
5630
  this.commands.setContextProvider(() => this.createCommandContext());
5249
5631
  }
5632
+ /** @returns The current editor state. */
5250
5633
  get state() {
5251
5634
  return this.stateStore;
5252
5635
  }
5636
+ /**
5637
+ * Applies a state updater function and emits a "change:data" event.
5638
+ * @param updater - Function that receives the current state and returns the new state.
5639
+ */
5253
5640
  dispatch(updater) {
5254
5641
  const next = updater(this.stateStore);
5255
5642
  this.setState(next);
5256
5643
  this.emit("change:data", this.stateStore);
5257
5644
  }
5645
+ /** Destroys the editor, cleaning up plugins, commands, UI, and listeners. */
5258
5646
  async destroy() {
5259
5647
  await this.pluginCollection.destroy();
5260
5648
  this.commands.clear();
5261
5649
  this.ui.clear();
5262
5650
  this.listeners.clear();
5263
5651
  }
5652
+ /**
5653
+ * Subscribes to an event.
5654
+ * @param event - The event name.
5655
+ * @param callback - The handler to invoke when the event fires.
5656
+ * @returns An unsubscribe function.
5657
+ */
5264
5658
  on(event, callback) {
5265
5659
  const handlers = this.listeners.get(event) ?? /* @__PURE__ */ new Set();
5266
5660
  handlers.add(callback);
5267
5661
  this.listeners.set(event, handlers);
5268
5662
  return () => this.off(event, callback);
5269
5663
  }
5664
+ /**
5665
+ * Subscribes to a single emission of an event.
5666
+ * @param event - The event name.
5667
+ * @param callback - The handler to invoke once.
5668
+ * @returns An unsubscribe function.
5669
+ */
5270
5670
  once(event, callback) {
5271
5671
  const wrapper = (...args) => {
5272
5672
  this.off(event, wrapper);
@@ -5274,6 +5674,11 @@ class Editor {
5274
5674
  };
5275
5675
  return this.on(event, wrapper);
5276
5676
  }
5677
+ /**
5678
+ * Removes a previously subscribed event handler.
5679
+ * @param event - The event name.
5680
+ * @param callback - The handler to remove.
5681
+ */
5277
5682
  off(event, callback) {
5278
5683
  const handlers = this.listeners.get(event);
5279
5684
  if (!handlers) {
@@ -39785,7 +40190,7 @@ function importDocxInWorker(buffer, options = {}) {
39785
40190
  const worker = new Worker(
39786
40191
  new URL(
39787
40192
  /* @vite-ignore */
39788
- "" + new URL("assets/importDocxWorker-DBjcGf-C.js", import.meta.url).href,
40193
+ "" + new URL("assets/importDocxWorker-B1vHeo5L.js", import.meta.url).href,
39789
40194
  import.meta.url
39790
40195
  ),
39791
40196
  {
@@ -43717,6 +44122,10 @@ class MenuRegistry {
43717
44122
  constructor() {
43718
44123
  __publicField(this, "items", []);
43719
44124
  }
44125
+ /**
44126
+ * Registers or updates a menu item by id.
44127
+ * @param item - The menu item to register.
44128
+ */
43720
44129
  register(item) {
43721
44130
  const existingIndex = this.items.findIndex(
43722
44131
  (entry) => entry.id === item.id
@@ -43730,9 +44139,14 @@ class MenuRegistry {
43730
44139
  (a, b) => (a.order ?? Number.MAX_SAFE_INTEGER) - (b.order ?? Number.MAX_SAFE_INTEGER)
43731
44140
  );
43732
44141
  }
44142
+ /**
44143
+ * Removes a menu item by id.
44144
+ * @param id - The id of the item to remove.
44145
+ */
43733
44146
  unregister(id) {
43734
44147
  this.items = this.items.filter((i) => i.id !== id);
43735
44148
  }
44149
+ /** @returns A copy of all registered menu items. */
43736
44150
  getItems() {
43737
44151
  return [...this.items];
43738
44152
  }
@@ -47141,37 +47555,45 @@ export {
47141
47555
  ActionRow as d7,
47142
47556
  ColorPicker as d8,
47143
47557
  CommandRegistry as d9,
47144
- buildRibbonTabDefinitions as dA,
47145
- createEditorCommandBus as dB,
47146
- createOasisEditor as dC,
47147
- createOasisEditorContainer as dD,
47148
- mount as dE,
47149
- registerToolbarRenderer as dF,
47558
+ Button$1 as dA,
47559
+ buildRibbonTabDefinitions as dB,
47560
+ cloneDocument as dC,
47561
+ createDocument as dD,
47562
+ createEditorCommandBus as dE,
47563
+ createHeading as dF,
47564
+ createOasisEditor as dG,
47565
+ createOasisEditorContainer as dH,
47566
+ createParagraph as dI,
47567
+ createTable as dJ,
47568
+ mount as dK,
47569
+ normalizeDocument as dL,
47570
+ registerToolbarRenderer as dM,
47571
+ validateDocument as dN,
47150
47572
  DEFAULT_PALETTE as da,
47151
47573
  DialogFooter as db,
47152
- FieldRow as dc,
47153
- FloatingActionButton as dd,
47154
- GridPicker as de,
47155
- Heading as df,
47156
- IconButton as dg,
47157
- Menu as dh,
47158
- OASIS_BUILTIN_COMMANDS as di,
47159
- OASIS_MENU_ITEMS as dj,
47160
- OASIS_TOOLBAR_ITEMS as dk,
47161
- OasisEditorAppLazy as dl,
47162
- OasisEditorContainer as dm,
47163
- PluginCollection as dn,
47164
- Popover as dp,
47165
- RIBBON_TABS as dq,
47166
- Select as dr,
47167
- Separator as ds,
47168
- SidePanel as dt,
47169
- SidePanelBody as du,
47170
- SidePanelFooter as dv,
47171
- SidePanelHeader as dw,
47172
- SplitButton as dx,
47173
- StyleGallery as dy,
47174
- Button$1 as dz,
47574
+ EDITOR_SCHEMA_VERSION as dc,
47575
+ FieldRow as dd,
47576
+ FloatingActionButton as de,
47577
+ GridPicker as df,
47578
+ Heading as dg,
47579
+ IconButton as dh,
47580
+ Menu as di,
47581
+ OASIS_BUILTIN_COMMANDS as dj,
47582
+ OASIS_MENU_ITEMS as dk,
47583
+ OASIS_TOOLBAR_ITEMS as dl,
47584
+ OasisEditorAppLazy as dm,
47585
+ OasisEditorContainer as dn,
47586
+ PluginCollection as dp,
47587
+ Popover as dq,
47588
+ RIBBON_TABS as dr,
47589
+ Select as ds,
47590
+ Separator as dt,
47591
+ SidePanel as du,
47592
+ SidePanelBody as dv,
47593
+ SidePanelFooter as dw,
47594
+ SidePanelHeader as dx,
47595
+ SplitButton as dy,
47596
+ StyleGallery as dz,
47175
47597
  estimateTableBlockHeight as e,
47176
47598
  getParagraphText as f,
47177
47599
  getProjectedParagraphBlockHeight as g,