superdoc 2.0.0-next.47 → 2.0.0-next.48

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.
@@ -4814,7 +4814,11 @@ function createSuperDocUI(options) {
4814
4814
  if (mirroredEditCommandState) {
4815
4815
  const shippedStatus = mirroredEditCommandState.shippedStatus;
4816
4816
  const supported = shippedStatus !== "not-shipped" && shippedStatus !== "disabled";
4817
- const reason = mirroredEditCommandState.reason === void 0 ? void 0 : coerceSuperDocUIReason(mirroredEditCommandState.reason, SUPERDOC_UI_REASONS.commandUnsupported);
4817
+ const mirroredEnabled = typeof mirroredEditCommandState.enabled === "boolean" ? mirroredEditCommandState.enabled : true;
4818
+ const isHistoryCommand = id === "undo" || id === "redo";
4819
+ const historyUnread = isHistoryCommand && mirroredEditCommandState.historyResolved === false;
4820
+ const isEmptyHistoryStack = isHistoryCommand && supported && mirroredEnabled === false && mirroredEditCommandState.reason === null && !historyUnread;
4821
+ const reason = mirroredEditCommandState.reason === void 0 ? void 0 : isEmptyHistoryStack ? SUPERDOC_UI_REASONS.historyEmpty : historyUnread ? SUPERDOC_UI_REASONS.notReady : coerceSuperDocUIReason(mirroredEditCommandState.reason, SUPERDOC_UI_REASONS.commandUnsupported);
4818
4822
  if (descriptor.mutates && readonly) return normalizeCommandState({
4819
4823
  enabled: false,
4820
4824
  active: false,
@@ -4822,7 +4826,7 @@ function createSuperDocUI(options) {
4822
4826
  reason: SUPERDOC_UI_REASONS.documentReadonly
4823
4827
  }, "builtin");
4824
4828
  return normalizeCommandState({
4825
- enabled: supported && (typeof mirroredEditCommandState.enabled === "boolean" ? mirroredEditCommandState.enabled : true),
4829
+ enabled: supported && mirroredEnabled,
4826
4830
  active: false,
4827
4831
  supported,
4828
4832
  reason
@@ -5747,6 +5751,37 @@ function createSuperDocUI(options) {
5747
5751
  };
5748
5752
  let currentHostSelectionSource = null;
5749
5753
  let detachHostSelection = null;
5754
+ let currentEditCommandsSource = null;
5755
+ let detachEditCommands = null;
5756
+ let editCommandsRecomputeQueued = false;
5757
+ const requestEditCommandsRecompute = () => {
5758
+ if (disposed || editCommandsRecomputeQueued) return;
5759
+ editCommandsRecomputeQueued = true;
5760
+ const run = () => {
5761
+ if (!editCommandsRecomputeQueued) return;
5762
+ editCommandsRecomputeQueued = false;
5763
+ if (disposed) return;
5764
+ recompute();
5765
+ };
5766
+ if (typeof queueMicrotask === "function") queueMicrotask(run);
5767
+ else Promise.resolve().then(run);
5768
+ };
5769
+ const syncEditCommandsSubscription = () => {
5770
+ const next = getEditCommands();
5771
+ if (next === currentEditCommandsSource) return;
5772
+ if (detachEditCommands) {
5773
+ detachEditCommands();
5774
+ detachEditCommands = null;
5775
+ }
5776
+ currentEditCommandsSource = next;
5777
+ if (!next || typeof next.subscribe !== "function") return;
5778
+ try {
5779
+ const unsubscribe = next.subscribe(() => requestEditCommandsRecompute());
5780
+ if (typeof unsubscribe === "function") detachEditCommands = unsubscribe;
5781
+ } catch {
5782
+ currentEditCommandsSource = null;
5783
+ }
5784
+ };
5750
5785
  let currentHostReviewSource = null;
5751
5786
  let detachHostReview = null;
5752
5787
  let currentHostEventsSource = null;
@@ -5941,8 +5976,10 @@ function createSuperDocUI(options) {
5941
5976
  };
5942
5977
  const recompute = () => {
5943
5978
  if (disposed) return;
5979
+ editCommandsRecomputeQueued = false;
5944
5980
  syncCoordinatorEditor();
5945
5981
  syncHostSelectionSubscription();
5982
+ syncEditCommandsSubscription();
5946
5983
  syncHostReviewSubscription();
5947
5984
  syncDocumentSelectionFallbackSubscription();
5948
5985
  syncHostEventsSubscription();
@@ -5977,6 +6014,7 @@ function createSuperDocUI(options) {
5977
6014
  };
5978
6015
  attach(superdoc, HOST_EVENTS);
5979
6016
  syncHostSelectionSubscription();
6017
+ syncEditCommandsSubscription();
5980
6018
  syncHostReviewSubscription();
5981
6019
  syncDocumentSelectionFallbackSubscription();
5982
6020
  syncHostEventsSubscription();
@@ -9049,6 +9087,9 @@ function createSuperDocUI(options) {
9049
9087
  if (detachHostSelection) detachHostSelection();
9050
9088
  detachHostSelection = null;
9051
9089
  currentHostSelectionSource = null;
9090
+ if (detachEditCommands) detachEditCommands();
9091
+ detachEditCommands = null;
9092
+ currentEditCommandsSource = null;
9052
9093
  if (detachHostReview) detachHostReview();
9053
9094
  detachHostReview = null;
9054
9095
  currentHostReviewSource = null;
@@ -4592,7 +4592,11 @@ function createSuperDocUI(options) {
4592
4592
  if (mirroredEditCommandState) {
4593
4593
  const shippedStatus = mirroredEditCommandState.shippedStatus;
4594
4594
  const supported = shippedStatus !== "not-shipped" && shippedStatus !== "disabled";
4595
- const reason = mirroredEditCommandState.reason === void 0 ? void 0 : coerceSuperDocUIReason(mirroredEditCommandState.reason, SUPERDOC_UI_REASONS.commandUnsupported);
4595
+ const mirroredEnabled = typeof mirroredEditCommandState.enabled === "boolean" ? mirroredEditCommandState.enabled : true;
4596
+ const isHistoryCommand = id === "undo" || id === "redo";
4597
+ const historyUnread = isHistoryCommand && mirroredEditCommandState.historyResolved === false;
4598
+ const isEmptyHistoryStack = isHistoryCommand && supported && mirroredEnabled === false && mirroredEditCommandState.reason === null && !historyUnread;
4599
+ const reason = mirroredEditCommandState.reason === void 0 ? void 0 : isEmptyHistoryStack ? SUPERDOC_UI_REASONS.historyEmpty : historyUnread ? SUPERDOC_UI_REASONS.notReady : coerceSuperDocUIReason(mirroredEditCommandState.reason, SUPERDOC_UI_REASONS.commandUnsupported);
4596
4600
  if (descriptor.mutates && readonly) return normalizeCommandState({
4597
4601
  enabled: false,
4598
4602
  active: false,
@@ -4600,7 +4604,7 @@ function createSuperDocUI(options) {
4600
4604
  reason: SUPERDOC_UI_REASONS.documentReadonly
4601
4605
  }, "builtin");
4602
4606
  return normalizeCommandState({
4603
- enabled: supported && (typeof mirroredEditCommandState.enabled === "boolean" ? mirroredEditCommandState.enabled : true),
4607
+ enabled: supported && mirroredEnabled,
4604
4608
  active: false,
4605
4609
  supported,
4606
4610
  reason
@@ -5525,6 +5529,37 @@ function createSuperDocUI(options) {
5525
5529
  };
5526
5530
  let currentHostSelectionSource = null;
5527
5531
  let detachHostSelection = null;
5532
+ let currentEditCommandsSource = null;
5533
+ let detachEditCommands = null;
5534
+ let editCommandsRecomputeQueued = false;
5535
+ const requestEditCommandsRecompute = () => {
5536
+ if (disposed || editCommandsRecomputeQueued) return;
5537
+ editCommandsRecomputeQueued = true;
5538
+ const run = () => {
5539
+ if (!editCommandsRecomputeQueued) return;
5540
+ editCommandsRecomputeQueued = false;
5541
+ if (disposed) return;
5542
+ recompute();
5543
+ };
5544
+ if (typeof queueMicrotask === "function") queueMicrotask(run);
5545
+ else Promise.resolve().then(run);
5546
+ };
5547
+ const syncEditCommandsSubscription = () => {
5548
+ const next = getEditCommands();
5549
+ if (next === currentEditCommandsSource) return;
5550
+ if (detachEditCommands) {
5551
+ detachEditCommands();
5552
+ detachEditCommands = null;
5553
+ }
5554
+ currentEditCommandsSource = next;
5555
+ if (!next || typeof next.subscribe !== "function") return;
5556
+ try {
5557
+ const unsubscribe = next.subscribe(() => requestEditCommandsRecompute());
5558
+ if (typeof unsubscribe === "function") detachEditCommands = unsubscribe;
5559
+ } catch {
5560
+ currentEditCommandsSource = null;
5561
+ }
5562
+ };
5528
5563
  let currentHostReviewSource = null;
5529
5564
  let detachHostReview = null;
5530
5565
  let currentHostEventsSource = null;
@@ -5719,8 +5754,10 @@ function createSuperDocUI(options) {
5719
5754
  };
5720
5755
  const recompute = () => {
5721
5756
  if (disposed) return;
5757
+ editCommandsRecomputeQueued = false;
5722
5758
  syncCoordinatorEditor();
5723
5759
  syncHostSelectionSubscription();
5760
+ syncEditCommandsSubscription();
5724
5761
  syncHostReviewSubscription();
5725
5762
  syncDocumentSelectionFallbackSubscription();
5726
5763
  syncHostEventsSubscription();
@@ -5755,6 +5792,7 @@ function createSuperDocUI(options) {
5755
5792
  };
5756
5793
  attach(superdoc, HOST_EVENTS);
5757
5794
  syncHostSelectionSubscription();
5795
+ syncEditCommandsSubscription();
5758
5796
  syncHostReviewSubscription();
5759
5797
  syncDocumentSelectionFallbackSubscription();
5760
5798
  syncHostEventsSubscription();
@@ -8827,6 +8865,9 @@ function createSuperDocUI(options) {
8827
8865
  if (detachHostSelection) detachHostSelection();
8828
8866
  detachHostSelection = null;
8829
8867
  currentHostSelectionSource = null;
8868
+ if (detachEditCommands) detachEditCommands();
8869
+ detachEditCommands = null;
8870
+ currentEditCommandsSource = null;
8830
8871
  if (detachHostReview) detachHostReview();
8831
8872
  detachHostReview = null;
8832
8873
  currentHostReviewSource = null;
@@ -7,7 +7,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
7
7
  var PRIVATE_ENGINE_INFO = (0, __superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
8
8
  var ENGINE_INFO = Object.freeze({
9
9
  ...PRIVATE_ENGINE_INFO,
10
- superdocVersion: "2.0.0-next.47",
10
+ superdocVersion: "2.0.0-next.48",
11
11
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
12
12
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
13
13
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -6,7 +6,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
6
6
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
7
7
  var ENGINE_INFO = Object.freeze({
8
8
  ...PRIVATE_ENGINE_INFO,
9
- superdocVersion: "2.0.0-next.47",
9
+ superdocVersion: "2.0.0-next.48",
10
10
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
11
11
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
12
12
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../chunks/rolldown-runtime-_dR15c8t.cjs");
3
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-Dk6T01KE.cjs");
3
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-BNo2DvD1.cjs");
4
4
  let react = require("react");
5
5
  var SuperDocUIContext = (0, react.createContext)(null);
6
6
  function disposeOwnedUi(ref) {
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-CKyCKKdl.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-BmtUtDDR.es.js";
2
2
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
3
3
  var SuperDocUIContext = createContext(null);
4
4
  function disposeOwnedUi(ref) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-Dk6T01KE.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-BNo2DvD1.cjs");
3
3
  exports.BUILT_IN_COMMAND_IDS = require_create_super_doc_ui.BUILT_IN_COMMAND_IDS;
4
4
  exports.createSuperDocUI = require_create_super_doc_ui.createSuperDocUI;
5
5
  exports.shallowEqual = require_create_super_doc_ui.shallowEqual;
@@ -1,2 +1,2 @@
1
- import { n as shallowEqual, r as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-CKyCKKdl.es.js";
1
+ import { n as shallowEqual, r as BUILT_IN_COMMAND_IDS, t as createSuperDocUI } from "../chunks/create-super-doc-ui-BmtUtDDR.es.js";
2
2
  export { BUILT_IN_COMMAND_IDS, createSuperDocUI, shallowEqual };
package/dist/superdoc.cjs CHANGED
@@ -6,7 +6,7 @@ const require_uuid = require("./chunks/uuid-CFp0WGVU.cjs");
6
6
  const require_jszip = require("./chunks/jszip-BdUBlUeG.cjs");
7
7
  const require__plugin_vue_export_helper = require("./chunks/_plugin-vue_export-helper-BTwbGDKw.cjs");
8
8
  const require_constants = require("./chunks/constants-sbCZ2O_A.cjs");
9
- const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-Dk6T01KE.cjs");
9
+ const require_create_super_doc_ui = require("./chunks/create-super-doc-ui-BNo2DvD1.cjs");
10
10
  let vue = require("vue");
11
11
  vue = require_rolldown_runtime.__toESM(vue);
12
12
  require("y-websocket");
@@ -34710,7 +34710,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
34710
34710
  this.config.colors = shuffleArray(this.config.colors);
34711
34711
  this.userColorMap = /* @__PURE__ */ new Map();
34712
34712
  this.colorIndex = 0;
34713
- this.version = "2.0.0-next.47";
34713
+ this.version = "2.0.0-next.48";
34714
34714
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
34715
34715
  this.superdocId = config.superdocId || require_uuid.v4_default();
34716
34716
  this.colors = this.config.colors ?? [];
@@ -5,7 +5,7 @@ import { t as v4_default } from "./chunks/uuid-B2Sqk-3p.es.js";
5
5
  import { a as init_dist, i as global, n as init_dist$1, r as process$1, t as require_jszip_min } from "./chunks/jszip-DzmwAHr3.es.js";
6
6
  import { t as __plugin_vue_export_helper_default } from "./chunks/_plugin-vue_export-helper-CInC0bKI.es.js";
7
7
  import { n as PDF_TO_CSS_UNITS } from "./chunks/constants-CY3R3_kF.es.js";
8
- import { a as createV2ReviewMutationReconciler, i as isV2EditableTextMutationEvent, o as getV2TrackedChangeMutationImpact, s as composeAuthorColorResolver, t as createSuperDocUI } from "./chunks/create-super-doc-ui-CKyCKKdl.es.js";
8
+ import { a as createV2ReviewMutationReconciler, i as isV2EditableTextMutationEvent, o as getV2TrackedChangeMutationImpact, s as composeAuthorColorResolver, t as createSuperDocUI } from "./chunks/create-super-doc-ui-BmtUtDDR.es.js";
9
9
  import * as Vue from "vue";
10
10
  import { Fragment, Teleport, Transition, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, getCurrentInstance, h, inject, markRaw, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeUnmount, onDeactivated, onMounted, openBlock, reactive, ref, renderList, renderSlot, resolveDirective, resolveDynamicComponent, shallowRef, toDisplayString, toRaw, toRef, unref, useAttrs, vModelText, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
11
11
  import "y-websocket";
@@ -34647,7 +34647,7 @@ var SuperDoc = class extends import_eventemitter3.default {
34647
34647
  this.config.colors = shuffleArray(this.config.colors);
34648
34648
  this.userColorMap = /* @__PURE__ */ new Map();
34649
34649
  this.colorIndex = 0;
34650
- this.version = "2.0.0-next.47";
34650
+ this.version = "2.0.0-next.48";
34651
34651
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
34652
34652
  this.superdocId = config.superdocId || v4_default();
34653
34653
  this.colors = this.config.colors ?? [];