@arbidocs/blocks 0.4.154 → 0.4.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedNativeDocxComparison-OLWRQSRS.js → ConnectedNativeDocxComparison-2PLOOXSH.js} +7 -7
- package/dist/{ConnectedNativeDocxComparison-OLWRQSRS.js.map → ConnectedNativeDocxComparison-2PLOOXSH.js.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-YORMOPPN.cjs → ConnectedNativeDocxComparison-S25BPUH5.cjs} +8 -8
- package/dist/{ConnectedNativeDocxComparison-YORMOPPN.cjs.map → ConnectedNativeDocxComparison-S25BPUH5.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxEditor-34EBIIFS.js → ConnectedNativeDocxEditor-JJAGMHZC.js} +5 -5
- package/dist/{ConnectedNativeDocxEditor-34EBIIFS.js.map → ConnectedNativeDocxEditor-JJAGMHZC.js.map} +1 -1
- package/dist/{ConnectedNativeDocxEditor-EHTWGGX3.cjs → ConnectedNativeDocxEditor-YA4HWLY4.cjs} +7 -7
- package/dist/{ConnectedNativeDocxEditor-EHTWGGX3.cjs.map → ConnectedNativeDocxEditor-YA4HWLY4.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-5DK6QGYN.cjs → ConnectedStreamedWordArtifact-EXYZAU4Y.cjs} +8 -8
- package/dist/ConnectedStreamedWordArtifact-EXYZAU4Y.cjs.map +1 -0
- package/dist/{ConnectedStreamedWordArtifact-GLIDLSAS.js → ConnectedStreamedWordArtifact-YAAXY5KY.js} +7 -7
- package/dist/{ConnectedStreamedWordArtifact-GLIDLSAS.js.map → ConnectedStreamedWordArtifact-YAAXY5KY.js.map} +1 -1
- package/dist/{NativeDocxEditor-XT5ZLFGU.js → NativeDocxEditor-JBQMH3MP.js} +3 -3
- package/dist/{NativeDocxEditor-XT5ZLFGU.js.map → NativeDocxEditor-JBQMH3MP.js.map} +1 -1
- package/dist/{NativeDocxEditor-5VBNM5I7.cjs → NativeDocxEditor-M3I776GD.cjs} +7 -7
- package/dist/{NativeDocxEditor-5VBNM5I7.cjs.map → NativeDocxEditor-M3I776GD.cjs.map} +1 -1
- package/dist/agents/index.cjs +238 -238
- package/dist/agents/index.js +4 -4
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/{chunk-MF5KQ4PS.js → chunk-2CWM2CFZ.js} +4 -4
- package/dist/{chunk-MF5KQ4PS.js.map → chunk-2CWM2CFZ.js.map} +1 -1
- package/dist/{chunk-QKR5LWDO.js → chunk-6HG56GCT.js} +4 -4
- package/dist/{chunk-QKR5LWDO.js.map → chunk-6HG56GCT.js.map} +1 -1
- package/dist/chunk-6HMCF4AJ.js +1720 -0
- package/dist/chunk-6HMCF4AJ.js.map +1 -0
- package/dist/{chunk-KHXEIEXN.js → chunk-7IRSCMNK.js} +3 -3
- package/dist/{chunk-KHXEIEXN.js.map → chunk-7IRSCMNK.js.map} +1 -1
- package/dist/{chunk-TZOQKV64.js → chunk-EWCJXUBP.js} +3 -3
- package/dist/{chunk-TZOQKV64.js.map → chunk-EWCJXUBP.js.map} +1 -1
- package/dist/{chunk-CU6LDQ57.js → chunk-F3EZDBDJ.js} +4 -4
- package/dist/{chunk-CU6LDQ57.js.map → chunk-F3EZDBDJ.js.map} +1 -1
- package/dist/{chunk-YF3QUHKN.cjs → chunk-FEGXFABZ.cjs} +3 -3
- package/dist/{chunk-YF3QUHKN.cjs.map → chunk-FEGXFABZ.cjs.map} +1 -1
- package/dist/{chunk-GC2FSPSQ.cjs → chunk-HDJRSCRE.cjs} +6 -6
- package/dist/{chunk-GC2FSPSQ.cjs.map → chunk-HDJRSCRE.cjs.map} +1 -1
- package/dist/{chunk-CQCNU5KT.cjs → chunk-IJEISII2.cjs} +6 -6
- package/dist/{chunk-CQCNU5KT.cjs.map → chunk-IJEISII2.cjs.map} +1 -1
- package/dist/{chunk-NPR5BGFF.cjs → chunk-JSQEAPTC.cjs} +26 -14
- package/dist/chunk-JSQEAPTC.cjs.map +1 -0
- package/dist/{chunk-BDA3RHYD.cjs → chunk-MUDEL7UL.cjs} +25 -884
- package/dist/chunk-MUDEL7UL.cjs.map +1 -0
- package/dist/{chunk-6QAAIDQQ.cjs → chunk-O3FB62T5.cjs} +47 -47
- package/dist/{chunk-6QAAIDQQ.cjs.map → chunk-O3FB62T5.cjs.map} +1 -1
- package/dist/{chunk-265GOG4W.js → chunk-ONTUMV74.js} +26 -14
- package/dist/chunk-ONTUMV74.js.map +1 -0
- package/dist/chunk-OTU5KGQ6.cjs +18 -0
- package/dist/{chunk-HUATKA3M.cjs.map → chunk-OTU5KGQ6.cjs.map} +1 -1
- package/dist/{chunk-GO3BN76C.js → chunk-PGOSIJ2I.js} +3 -3
- package/dist/{chunk-GO3BN76C.js.map → chunk-PGOSIJ2I.js.map} +1 -1
- package/dist/chunk-S74QMZVZ.cjs +18 -0
- package/dist/{chunk-C3SMTA3C.cjs.map → chunk-S74QMZVZ.cjs.map} +1 -1
- package/dist/{chunk-KUT2Y7JF.cjs → chunk-TQIY2SVY.cjs} +5 -5
- package/dist/{chunk-KUT2Y7JF.cjs.map → chunk-TQIY2SVY.cjs.map} +1 -1
- package/dist/{chunk-MNG7N6M2.js → chunk-UKCCV63X.js} +4 -4
- package/dist/{chunk-MNG7N6M2.js.map → chunk-UKCCV63X.js.map} +1 -1
- package/dist/{chunk-B3FMUFAW.cjs → chunk-UKT3WH5Z.cjs} +3 -3
- package/dist/{chunk-B3FMUFAW.cjs.map → chunk-UKT3WH5Z.cjs.map} +1 -1
- package/dist/{chunk-P6RIBIVN.js → chunk-UPMADXDU.js} +3 -3
- package/dist/{chunk-P6RIBIVN.js.map → chunk-UPMADXDU.js.map} +1 -1
- package/dist/{chunk-757OYF6G.cjs → chunk-VY4UFXTM.cjs} +4 -4
- package/dist/{chunk-757OYF6G.cjs.map → chunk-VY4UFXTM.cjs.map} +1 -1
- package/dist/{chunk-RE7NULEY.js → chunk-W7CWGURO.js} +28 -873
- package/dist/chunk-W7CWGURO.js.map +1 -0
- package/dist/chunk-WV4TD2HZ.cjs +1785 -0
- package/dist/chunk-WV4TD2HZ.cjs.map +1 -0
- package/dist/{chunk-WU34CHU5.js → chunk-YMQDDUKW.js} +3 -3
- package/dist/{chunk-WU34CHU5.js.map → chunk-YMQDDUKW.js.map} +1 -1
- package/dist/connect/docx.cjs +11 -11
- package/dist/connect/docx.js +7 -7
- package/dist/connect/index.cjs +1313 -151
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +1 -0
- package/dist/connect/index.js +1175 -27
- package/dist/connect/index.js.map +1 -1
- package/dist/connect/viewer.cjs +48 -52
- package/dist/connect/viewer.cjs.map +1 -1
- package/dist/connect/viewer.js +10 -14
- package/dist/connect/viewer.js.map +1 -1
- package/dist/connection/files/DocumentSyncGlyph.d.ts +28 -0
- package/dist/connection/files/explorer/ConnectedFilesExplorer.d.ts +56 -0
- package/dist/connection/files/explorer/FileTiles.d.ts +87 -0
- package/dist/connection/files/index.d.ts +5 -0
- package/dist/connection/files/store.d.ts +27 -0
- package/dist/connection/files/support.d.ts +38 -0
- package/dist/document-tools/index.cjs +1 -1
- package/dist/document-tools/index.js +1 -1
- package/dist/docx/index.cjs +47 -47
- package/dist/docx/index.js +3 -3
- package/dist/facts/index.cjs +54 -54
- package/dist/facts/index.js +4 -4
- package/dist/files/DocStatusIcon.d.ts +5 -4
- package/dist/files/FailedStageIcon.d.ts +26 -0
- package/dist/files/folders/FolderProviderIcon.d.ts +29 -0
- package/dist/files/folders/folderPaths.d.ts +86 -0
- package/dist/files/folders/index.d.ts +2 -0
- package/dist/files/index.cjs +326 -238
- package/dist/files/index.d.ts +5 -0
- package/dist/files/index.js +2 -2
- package/dist/files/permissions.d.ts +28 -0
- package/dist/files/recently-deleted.d.ts +7 -0
- package/dist/files/visibility.d.ts +31 -0
- package/dist/index.cjs +371 -371
- package/dist/index.js +10 -10
- package/dist/studio/index.cjs +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/workflow-canvas/index.cjs +16 -16
- package/dist/workflow-canvas/index.js +4 -4
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.cjs +96 -29
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.d.cts +1 -1
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.d.ts +1 -1
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.js +98 -31
- package/node_modules/@arbidocs/coedit/dist/hocuspocus.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/index.cjs +96 -29
- package/node_modules/@arbidocs/coedit/dist/index.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/index.d.cts +1 -1
- package/node_modules/@arbidocs/coedit/dist/index.d.ts +1 -1
- package/node_modules/@arbidocs/coedit/dist/index.js +98 -31
- package/node_modules/@arbidocs/coedit/dist/index.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.cjs +98 -33
- package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.d.cts +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.d.ts +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.js +99 -34
- package/node_modules/@arbidocs/coedit/dist/server.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/{session-Cf9iu1Vt.d.cts → session-WGvWs6yO.d.cts} +22 -4
- package/node_modules/@arbidocs/coedit/dist/{session-Cf9iu1Vt.d.ts → session-WGvWs6yO.d.ts} +22 -4
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +6 -5
- package/dist/ConnectedStreamedWordArtifact-5DK6QGYN.cjs.map +0 -1
- package/dist/chunk-265GOG4W.js.map +0 -1
- package/dist/chunk-BDA3RHYD.cjs.map +0 -1
- package/dist/chunk-C3SMTA3C.cjs +0 -18
- package/dist/chunk-HUATKA3M.cjs +0 -18
- package/dist/chunk-JGOST4IL.js +0 -648
- package/dist/chunk-JGOST4IL.js.map +0 -1
- package/dist/chunk-NPR5BGFF.cjs.map +0 -1
- package/dist/chunk-RE7NULEY.js.map +0 -1
- package/dist/chunk-YAEXSCUW.cjs +0 -677
- package/dist/chunk-YAEXSCUW.cjs.map +0 -1
|
@@ -5,7 +5,7 @@ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
|
5
5
|
import { TreePackageStore, PackageTransactResult, HeadlessDocumentView, ImageDecodePort } from '@docx-editor.dev/core/store';
|
|
6
6
|
import { R as ReferencesPort } from './port-BbN5OZHx.cjs';
|
|
7
7
|
import { R as Revision } from './track-eYC94jTp.cjs';
|
|
8
|
-
import { D as DocxCollaborationSession } from './session-
|
|
8
|
+
import { D as DocxCollaborationSession } from './session-WGvWs6yO.cjs';
|
|
9
9
|
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-DXiFQMA6.cjs';
|
|
10
10
|
import 'y-protocols/awareness';
|
|
11
11
|
import '@docx-editor.dev/core/collaboration/replication';
|
|
@@ -5,7 +5,7 @@ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
|
5
5
|
import { TreePackageStore, PackageTransactResult, HeadlessDocumentView, ImageDecodePort } from '@docx-editor.dev/core/store';
|
|
6
6
|
import { R as ReferencesPort } from './port-BbN5OZHx.js';
|
|
7
7
|
import { R as Revision } from './track-eYC94jTp.js';
|
|
8
|
-
import { D as DocxCollaborationSession } from './session-
|
|
8
|
+
import { D as DocxCollaborationSession } from './session-WGvWs6yO.js';
|
|
9
9
|
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-DXiFQMA6.js';
|
|
10
10
|
import 'y-protocols/awareness';
|
|
11
11
|
import '@docx-editor.dev/core/collaboration/replication';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Awareness } from 'y-protocols/awareness';
|
|
2
2
|
import { createServerAutomationHost } from '@docx-editor.dev/core/automation';
|
|
3
|
-
import { createCollaborationDocumentPort, historyGroupOfJournal } from '@docx-editor.dev/core/collaboration/replication';
|
|
3
|
+
import { createCollaborationDocumentPort, historyGroupOfJournal, mapOffsetAcrossText } from '@docx-editor.dev/core/collaboration/replication';
|
|
4
4
|
import { TreePackageStore, validateRasterHeader, headlessViewOfStore, ORIGIN_IDS, readOoxmlPackage, writeOoxmlPackage, readOoxmlPart, validateExternalTarget, relsPartNameFor, contentTypesPartBytes, withContentTypeOverride, readXml } from '@docx-editor.dev/core/store';
|
|
5
5
|
import { resolveNumberingLevel, resolveStoryListItems, buildStyleCascadeTable, withNumberingStyleLinks, buildNumberingIndex } from '@docx-editor.dev/core/layout';
|
|
6
6
|
import { zipSync, strToU8, strFromU8, unzipSync } from 'fflate';
|
|
@@ -1895,7 +1895,6 @@ function applyJournal(doc, registry, journal, origin, context) {
|
|
|
1895
1895
|
|
|
1896
1896
|
// src/sync.ts
|
|
1897
1897
|
var LOCAL_ORIGIN = /* @__PURE__ */ Symbol("arbi-coedit/local");
|
|
1898
|
-
var DEFAULT_REMOTE_DELAY_MS = 40;
|
|
1899
1898
|
var MirrorSync = class {
|
|
1900
1899
|
doc;
|
|
1901
1900
|
registry = new NodeRegistry();
|
|
@@ -1904,14 +1903,11 @@ var MirrorSync = class {
|
|
|
1904
1903
|
actorId;
|
|
1905
1904
|
onFailure;
|
|
1906
1905
|
onLocalJournal;
|
|
1906
|
+
aroundRemote;
|
|
1907
1907
|
disposers = [];
|
|
1908
|
-
remoteDelayMs;
|
|
1909
1908
|
operation = 0;
|
|
1910
1909
|
applyingRemote = false;
|
|
1911
1910
|
failed = false;
|
|
1912
|
-
remoteDirty = false;
|
|
1913
|
-
remoteOrigin;
|
|
1914
|
-
remoteTimer;
|
|
1915
1911
|
/** Parts whose node ids must be re-registered before the next local journal; true means all. */
|
|
1916
1912
|
staleParts = null;
|
|
1917
1913
|
constructor(options) {
|
|
@@ -1920,7 +1916,7 @@ var MirrorSync = class {
|
|
|
1920
1916
|
this.actorId = options.actorId;
|
|
1921
1917
|
this.onFailure = options.onFailure;
|
|
1922
1918
|
this.onLocalJournal = options.onLocalJournal;
|
|
1923
|
-
this.
|
|
1919
|
+
this.aroundRemote = options.aroundRemote;
|
|
1924
1920
|
registerMirror(this.doc, this.registry);
|
|
1925
1921
|
this.cache = new MaterializeCache(this.doc);
|
|
1926
1922
|
this.disposers.push(() => this.cache.destroy());
|
|
@@ -1941,16 +1937,10 @@ var MirrorSync = class {
|
|
|
1941
1937
|
const onAfterTransaction = (transaction) => {
|
|
1942
1938
|
if (transaction.origin === LOCAL_ORIGIN || this.failed) return;
|
|
1943
1939
|
if (transaction.changed.size === 0 && transaction.changedParentTypes.size === 0) return;
|
|
1944
|
-
this.
|
|
1945
|
-
this.remoteOrigin = transaction.origin;
|
|
1946
|
-
if (this.remoteDelayMs <= 0) this.flushRemote();
|
|
1947
|
-
else if (this.remoteTimer === void 0) {
|
|
1948
|
-
this.remoteTimer = setTimeout(() => this.flushRemote(), this.remoteDelayMs);
|
|
1949
|
-
}
|
|
1940
|
+
this.publishRemote(transaction.origin);
|
|
1950
1941
|
};
|
|
1951
1942
|
this.doc.on("afterTransaction", onAfterTransaction);
|
|
1952
1943
|
this.disposers.push(() => this.doc.off("afterTransaction", onAfterTransaction));
|
|
1953
|
-
this.disposers.push(() => clearTimeout(this.remoteTimer));
|
|
1954
1944
|
}
|
|
1955
1945
|
get hasFailed() {
|
|
1956
1946
|
return this.failed;
|
|
@@ -1959,17 +1949,8 @@ var MirrorSync = class {
|
|
|
1959
1949
|
beforeRemote() {
|
|
1960
1950
|
this.port.flushPendingJournals();
|
|
1961
1951
|
}
|
|
1962
|
-
/** Publish any waiting remote change now. Call before a local operation runs. */
|
|
1963
|
-
flushRemote() {
|
|
1964
|
-
clearTimeout(this.remoteTimer);
|
|
1965
|
-
this.remoteTimer = void 0;
|
|
1966
|
-
if (!this.remoteDirty || this.failed) return;
|
|
1967
|
-
this.remoteDirty = false;
|
|
1968
|
-
this.publishRemote(this.remoteOrigin);
|
|
1969
|
-
}
|
|
1970
1952
|
/** Make the local tree equal to the room: used when the editor opened an older snapshot of it. */
|
|
1971
1953
|
adopt() {
|
|
1972
|
-
this.remoteDirty = false;
|
|
1973
1954
|
this.publishRemote(void 0);
|
|
1974
1955
|
}
|
|
1975
1956
|
/** Re-register node ids for parts a remote publication replaced; deferred until a local edit needs them. */
|
|
@@ -1979,23 +1960,29 @@ var MirrorSync = class {
|
|
|
1979
1960
|
this.staleParts = null;
|
|
1980
1961
|
}
|
|
1981
1962
|
publishRemote(origin) {
|
|
1963
|
+
if (this.failed) return;
|
|
1964
|
+
const published = this.aroundRemote?.();
|
|
1982
1965
|
this.applyingRemote = true;
|
|
1983
1966
|
const changed = this.cache.take();
|
|
1967
|
+
let ok = false;
|
|
1984
1968
|
try {
|
|
1985
1969
|
const result = this.port.applyRemotePackage(materialize(this.doc, this.cache, changed), {
|
|
1986
|
-
origin:
|
|
1970
|
+
// The editor's own origin for a peer's change: it carries the local caret only across those.
|
|
1971
|
+
origin: ORIGIN_IDS.mutationRemote,
|
|
1987
1972
|
actorId: typeof origin === "string" ? origin : this.actorId,
|
|
1988
1973
|
operationId: `${this.actorId}:remote:${this.operation++}`
|
|
1989
1974
|
});
|
|
1990
1975
|
if (!result.ok) throw new JournalError(result.reason);
|
|
1991
1976
|
if (changed === null || this.staleParts === true) this.staleParts = true;
|
|
1992
1977
|
else this.staleParts = /* @__PURE__ */ new Set([...this.staleParts ?? [], ...changed]);
|
|
1978
|
+
ok = true;
|
|
1993
1979
|
} catch (error) {
|
|
1994
1980
|
this.cache.restore(changed);
|
|
1995
1981
|
this.fail(error instanceof MaterializeError ? "materialize" : "apply", error);
|
|
1996
1982
|
} finally {
|
|
1997
1983
|
this.applyingRemote = false;
|
|
1998
1984
|
}
|
|
1985
|
+
if (ok) published?.();
|
|
1999
1986
|
}
|
|
2000
1987
|
fail(code, error) {
|
|
2001
1988
|
if (this.failed) return;
|
|
@@ -2049,7 +2036,6 @@ var DocxCollaborationSession = class {
|
|
|
2049
2036
|
doc;
|
|
2050
2037
|
awareness;
|
|
2051
2038
|
offlineEditing;
|
|
2052
|
-
remoteDelayMs;
|
|
2053
2039
|
tracker = createCollaborationStatusTracker("initializing");
|
|
2054
2040
|
statusListeners = /* @__PURE__ */ new Set();
|
|
2055
2041
|
participantListeners = /* @__PURE__ */ new Set();
|
|
@@ -2062,6 +2048,10 @@ var DocxCollaborationSession = class {
|
|
|
2062
2048
|
selectionsCache = [];
|
|
2063
2049
|
selectionsKey = "[]";
|
|
2064
2050
|
baselineVector;
|
|
2051
|
+
/** The selection the editor last published, carried across the remote changes since. */
|
|
2052
|
+
carried = null;
|
|
2053
|
+
selectionMove = null;
|
|
2054
|
+
inputFlush = null;
|
|
2065
2055
|
disposers = [];
|
|
2066
2056
|
constructor(options) {
|
|
2067
2057
|
this.documentId = options.documentId;
|
|
@@ -2070,7 +2060,6 @@ var DocxCollaborationSession = class {
|
|
|
2070
2060
|
this.doc = options.doc;
|
|
2071
2061
|
this.awareness = options.awareness;
|
|
2072
2062
|
this.offlineEditing = options.offlineEditing ?? false;
|
|
2073
|
-
this.remoteDelayMs = options.remoteDelayMs;
|
|
2074
2063
|
this.undoManager = new Y3.UndoManager(
|
|
2075
2064
|
[
|
|
2076
2065
|
this.doc.getMap("parts"),
|
|
@@ -2132,7 +2121,6 @@ var DocxCollaborationSession = class {
|
|
|
2132
2121
|
return this.port !== void 0;
|
|
2133
2122
|
}
|
|
2134
2123
|
gateOperations() {
|
|
2135
|
-
this.sync?.flushRemote();
|
|
2136
2124
|
switch (this.status()) {
|
|
2137
2125
|
case "ready":
|
|
2138
2126
|
return this.port ? null : "collaboration-session-not-attached";
|
|
@@ -2161,7 +2149,7 @@ var DocxCollaborationSession = class {
|
|
|
2161
2149
|
doc: this.doc,
|
|
2162
2150
|
port,
|
|
2163
2151
|
actorId: this.identity.actorId,
|
|
2164
|
-
|
|
2152
|
+
aroundRemote: () => this.carrySelection(),
|
|
2165
2153
|
onFailure: (code, detail) => {
|
|
2166
2154
|
this.markFailed(code === "journal" ? "local-mirror-failed" : "remote-apply-failed", detail);
|
|
2167
2155
|
},
|
|
@@ -2185,8 +2173,21 @@ var DocxCollaborationSession = class {
|
|
|
2185
2173
|
}
|
|
2186
2174
|
/** Transport hook: call before integrating inbound Yjs data so queued local edits are mirrored first. */
|
|
2187
2175
|
beforeRemote() {
|
|
2176
|
+
this.inputFlush?.();
|
|
2188
2177
|
this.sync?.beforeRemote();
|
|
2189
2178
|
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Bind the editor's pending-input flush (`PaginatedSurface.flushPendingInput`). The session writes
|
|
2181
|
+
* below the editor's input buffer, so it lands queued typing before a remote change and lays the
|
|
2182
|
+
* change out right after it: the editor carries its caret at that layout, and a keystroke before
|
|
2183
|
+
* it would otherwise use the caret from before the change. Returns the unbind function.
|
|
2184
|
+
*/
|
|
2185
|
+
bindEditorInput(flush) {
|
|
2186
|
+
this.inputFlush = flush;
|
|
2187
|
+
return () => {
|
|
2188
|
+
if (this.inputFlush === flush) this.inputFlush = null;
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2190
2191
|
// ── Undo ─────────────────────────────────────────────────────────────────
|
|
2191
2192
|
canUndo() {
|
|
2192
2193
|
return this.undoManager.undoStack.length > 0;
|
|
@@ -2199,7 +2200,6 @@ var DocxCollaborationSession = class {
|
|
|
2199
2200
|
if (this.gateOperations() !== null || !this.canUndo()) return false;
|
|
2200
2201
|
this.undoManager.stopCapturing();
|
|
2201
2202
|
this.undoManager.undo();
|
|
2202
|
-
this.sync?.flushRemote();
|
|
2203
2203
|
return true;
|
|
2204
2204
|
}
|
|
2205
2205
|
redo() {
|
|
@@ -2207,13 +2207,79 @@ var DocxCollaborationSession = class {
|
|
|
2207
2207
|
if (this.gateOperations() !== null || !this.canRedo()) return false;
|
|
2208
2208
|
this.undoManager.stopCapturing();
|
|
2209
2209
|
this.undoManager.redo();
|
|
2210
|
-
this.sync?.flushRemote();
|
|
2211
2210
|
return true;
|
|
2212
2211
|
}
|
|
2213
2212
|
// ── Presence ─────────────────────────────────────────────────────────────
|
|
2214
2213
|
setLocalSelection(selection) {
|
|
2214
|
+
this.carried = selection && selection.kind !== "cells" ? { from: null, selection } : null;
|
|
2215
|
+
this.selectionMove = null;
|
|
2215
2216
|
this.awareness.setLocalStateField("selection", selection);
|
|
2216
2217
|
}
|
|
2218
|
+
/** Where the last remote change carried the local selection; see `carrySelection`. */
|
|
2219
|
+
remoteSelectionMove() {
|
|
2220
|
+
return this.selectionMove;
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* Called before a remote change reaches the port: notes the selection's paragraphs and their text,
|
|
2224
|
+
* and returns what carries it across the change once the port holds the new tree. The editor
|
|
2225
|
+
* takes the carried selection when a local edit was coalesced with the remote change, where it
|
|
2226
|
+
* cannot map its caret by the text alone. Several remote changes before the editor publishes its
|
|
2227
|
+
* selection again chain, all from the selection it published.
|
|
2228
|
+
*/
|
|
2229
|
+
carrySelection() {
|
|
2230
|
+
const port = this.port;
|
|
2231
|
+
const carried = this.carried;
|
|
2232
|
+
const settle = () => this.inputFlush?.();
|
|
2233
|
+
if (!port || !carried) return settle;
|
|
2234
|
+
const before = (address) => {
|
|
2235
|
+
const paragraph = port.paragraphByStableId(address.paragraphId);
|
|
2236
|
+
if (!paragraph) return null;
|
|
2237
|
+
const offset = Math.min(address.offset, paragraph.text.length);
|
|
2238
|
+
return { nodeId: paragraph.nodeId, text: paragraph.text, offset };
|
|
2239
|
+
};
|
|
2240
|
+
const anchor = before(carried.selection.anchor);
|
|
2241
|
+
const head = before(carried.selection.head);
|
|
2242
|
+
if (!anchor || !head) {
|
|
2243
|
+
this.carried = null;
|
|
2244
|
+
this.selectionMove = null;
|
|
2245
|
+
return settle;
|
|
2246
|
+
}
|
|
2247
|
+
const from = carried.from ?? {
|
|
2248
|
+
anchor: { nodeId: anchor.nodeId, offset: anchor.offset },
|
|
2249
|
+
head: { nodeId: head.nodeId, offset: head.offset }
|
|
2250
|
+
};
|
|
2251
|
+
return () => {
|
|
2252
|
+
const after = (address, was) => {
|
|
2253
|
+
const paragraph = port.paragraphByStableId(address.paragraphId);
|
|
2254
|
+
if (!paragraph) return null;
|
|
2255
|
+
const offset = mapOffsetAcrossText(was.offset, was.text, paragraph.text);
|
|
2256
|
+
return { paragraphId: address.paragraphId, nodeId: paragraph.nodeId, offset };
|
|
2257
|
+
};
|
|
2258
|
+
const nextAnchor = after(carried.selection.anchor, anchor);
|
|
2259
|
+
const nextHead = after(carried.selection.head, head);
|
|
2260
|
+
if (!nextAnchor || !nextHead) {
|
|
2261
|
+
this.carried = null;
|
|
2262
|
+
this.selectionMove = null;
|
|
2263
|
+
} else {
|
|
2264
|
+
this.carried = {
|
|
2265
|
+
from,
|
|
2266
|
+
selection: {
|
|
2267
|
+
...carried.selection,
|
|
2268
|
+
anchor: { paragraphId: nextAnchor.paragraphId, offset: nextAnchor.offset },
|
|
2269
|
+
head: { paragraphId: nextHead.paragraphId, offset: nextHead.offset }
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
this.selectionMove = {
|
|
2273
|
+
from,
|
|
2274
|
+
to: {
|
|
2275
|
+
anchor: { nodeId: nextAnchor.nodeId, offset: nextAnchor.offset },
|
|
2276
|
+
head: { nodeId: nextHead.nodeId, offset: nextHead.offset }
|
|
2277
|
+
}
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
settle();
|
|
2281
|
+
};
|
|
2282
|
+
}
|
|
2217
2283
|
participants() {
|
|
2218
2284
|
return this.participantsCache;
|
|
2219
2285
|
}
|
|
@@ -2285,6 +2351,7 @@ var DocxCollaborationSession = class {
|
|
|
2285
2351
|
this.sync?.destroy();
|
|
2286
2352
|
this.sync = void 0;
|
|
2287
2353
|
this.port = void 0;
|
|
2354
|
+
this.inputFlush = null;
|
|
2288
2355
|
this.undoManager.destroy();
|
|
2289
2356
|
this.awareness.setLocalState(null);
|
|
2290
2357
|
for (const dispose of this.disposers.splice(0)) dispose();
|
|
@@ -2375,8 +2442,7 @@ function openRoomAutomation(options) {
|
|
|
2375
2442
|
doc: options.doc,
|
|
2376
2443
|
awareness,
|
|
2377
2444
|
documentId: options.documentId,
|
|
2378
|
-
identity: options.identity
|
|
2379
|
-
remoteDelayMs: 0
|
|
2445
|
+
identity: options.identity
|
|
2380
2446
|
});
|
|
2381
2447
|
session.markReady();
|
|
2382
2448
|
try {
|
|
@@ -2408,8 +2474,7 @@ function openRoomStore(options) {
|
|
|
2408
2474
|
doc: options.doc,
|
|
2409
2475
|
awareness,
|
|
2410
2476
|
documentId: options.documentId,
|
|
2411
|
-
identity: options.identity
|
|
2412
|
-
remoteDelayMs: 0
|
|
2477
|
+
identity: options.identity
|
|
2413
2478
|
});
|
|
2414
2479
|
session.markReady();
|
|
2415
2480
|
try {
|