@ones-editor/editor 2.8.37 → 2.8.39
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/@ones-editor/core/src/core/selection/range/simple-range.d.ts +2 -2
- package/@ones-editor/core/src/core/types.d.ts +2 -0
- package/@ones-editor/main-toolbar/src/items/comment.d.ts +1 -0
- package/@ones-editor/sharedb-doc/src/doc/auth-connection.d.ts +1 -0
- package/@ones-editor/sharedb-doc/src/doc/edit-status.d.ts +1 -1
- package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +96 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26314,6 +26314,9 @@ var __publicField = (obj, key, value) => {
|
|
|
26314
26314
|
}
|
|
26315
26315
|
}
|
|
26316
26316
|
function editorScrollIntoView(editor) {
|
|
26317
|
+
if (!editor.scrollable()) {
|
|
26318
|
+
return;
|
|
26319
|
+
}
|
|
26317
26320
|
if (!isElementVisible(editor.rootContainer)) {
|
|
26318
26321
|
logger$3R.warn("editorScrollIntoView: editor is not visible");
|
|
26319
26322
|
return;
|
|
@@ -31657,6 +31660,7 @@ ${codeText}
|
|
|
31657
31660
|
__publicField(this, "inputHandlers", new EditorInputHandlers(this));
|
|
31658
31661
|
__publicField(this, "settingsProvider");
|
|
31659
31662
|
__publicField(this, "_readonly", false);
|
|
31663
|
+
__publicField(this, "_scrollable", true);
|
|
31660
31664
|
__publicField(this, "getColor", (index2) => {
|
|
31661
31665
|
const colors = this.options.colors;
|
|
31662
31666
|
if (colors.length === 0) {
|
|
@@ -31884,6 +31888,12 @@ ${codeText}
|
|
|
31884
31888
|
return false;
|
|
31885
31889
|
return elem.closest("div.editor-root") === this.rootElement;
|
|
31886
31890
|
}
|
|
31891
|
+
scrollable() {
|
|
31892
|
+
return this._scrollable;
|
|
31893
|
+
}
|
|
31894
|
+
setScrollable(scrollable2) {
|
|
31895
|
+
this._scrollable = scrollable2;
|
|
31896
|
+
}
|
|
31887
31897
|
insertBlock(containerId, blockIndex, blockData, newRange, options) {
|
|
31888
31898
|
const defaultPos = { blockId: blockData.id, offset: 0 };
|
|
31889
31899
|
const defaultRange = { anchor: defaultPos, focus: defaultPos };
|
|
@@ -37991,6 +38001,7 @@ ${codeText}
|
|
|
37991
38001
|
}
|
|
37992
38002
|
try {
|
|
37993
38003
|
origHandleMessage(msg);
|
|
38004
|
+
this.emit("opReceived");
|
|
37994
38005
|
} catch (err) {
|
|
37995
38006
|
if ((err == null ? void 0 : err.type) === "writeConflict") {
|
|
37996
38007
|
this.emitWriteConflictError(err, msg);
|
|
@@ -39077,9 +39088,9 @@ ${codeText}
|
|
|
39077
39088
|
}
|
|
39078
39089
|
setStatus(status) {
|
|
39079
39090
|
var _a, _b, _c;
|
|
39080
|
-
if (status === "clean") {
|
|
39091
|
+
if (status === "clean" || status === "busy") {
|
|
39081
39092
|
if (this.dirtyTimeout) {
|
|
39082
|
-
logger$2U.info(
|
|
39093
|
+
logger$2U.info(`on ${status}`);
|
|
39083
39094
|
clearTimeout(this.dirtyTimeout);
|
|
39084
39095
|
this.dirtyTimeout = null;
|
|
39085
39096
|
}
|
|
@@ -39151,6 +39162,9 @@ ${codeText}
|
|
|
39151
39162
|
__publicField(this, "handleWriteConflictError", (error2) => {
|
|
39152
39163
|
this.handleReset(`write conflict: ${error2.message}, ${JSON.stringify(error2.orgMsg)}`);
|
|
39153
39164
|
});
|
|
39165
|
+
__publicField(this, "handleOpReceived", () => {
|
|
39166
|
+
this.editStatus.setStatus("busy");
|
|
39167
|
+
});
|
|
39154
39168
|
__publicField(this, "insertObject", async (rootObjectName, index2, obj) => {
|
|
39155
39169
|
const ops = [rootObjectName, index2, { i: obj }];
|
|
39156
39170
|
return this.submitOp(ops);
|
|
@@ -39244,7 +39258,10 @@ ${codeText}
|
|
|
39244
39258
|
if (containers.length === 0) {
|
|
39245
39259
|
return Promise.resolve();
|
|
39246
39260
|
}
|
|
39247
|
-
const ops = containers.map(({ containerId, blocks }) => [
|
|
39261
|
+
const ops = containers.map(({ containerId, blocks }) => [
|
|
39262
|
+
docObjectContainerId2EditorDocContainerId(containerId),
|
|
39263
|
+
{ i: blocks }
|
|
39264
|
+
]);
|
|
39248
39265
|
return this.submitOp([ops]);
|
|
39249
39266
|
});
|
|
39250
39267
|
__publicField(this, "submitDeleteChildContainer", async (containerId) => {
|
|
@@ -39263,7 +39280,10 @@ ${codeText}
|
|
|
39263
39280
|
if (delta.delete.length === 0 && Object.keys(delta.insert).length === 0) {
|
|
39264
39281
|
return Promise.resolve();
|
|
39265
39282
|
}
|
|
39266
|
-
const ops = [
|
|
39283
|
+
const ops = [
|
|
39284
|
+
docObjectContainerId2EditorDocContainerId(containerId),
|
|
39285
|
+
index2
|
|
39286
|
+
];
|
|
39267
39287
|
const deletedKeysSet = new Set(delta.delete);
|
|
39268
39288
|
Object.entries(delta.insert).forEach(([key, value]) => {
|
|
39269
39289
|
if (deletedKeysSet.has(key)) {
|
|
@@ -39314,6 +39334,7 @@ ${codeText}
|
|
|
39314
39334
|
this.disableLogout = disableLogout;
|
|
39315
39335
|
this.registerCallback(this.remoteCaretHandler);
|
|
39316
39336
|
this.editStatus = new EditStatus(options);
|
|
39337
|
+
this.client.connection.addListener("opReceived", this.handleOpReceived);
|
|
39317
39338
|
}
|
|
39318
39339
|
beginBatchUpdate() {
|
|
39319
39340
|
this.doc.preventCompose = false;
|
|
@@ -39498,7 +39519,9 @@ ${codeText}
|
|
|
39498
39519
|
this.endBatchUpdate();
|
|
39499
39520
|
}
|
|
39500
39521
|
getComments() {
|
|
39501
|
-
const comments = Object.values(this.data().comments).map(
|
|
39522
|
+
const comments = Object.values(this.data().comments).map(
|
|
39523
|
+
(comment) => shareDBDocCommentToComment(comment)
|
|
39524
|
+
);
|
|
39502
39525
|
return comments;
|
|
39503
39526
|
}
|
|
39504
39527
|
getComment(commentId) {
|
|
@@ -39538,47 +39561,59 @@ ${codeText}
|
|
|
39538
39561
|
}
|
|
39539
39562
|
onDeleteBlock(containerId, blockIndex, local) {
|
|
39540
39563
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39541
|
-
this.callbacks.forEach(
|
|
39542
|
-
|
|
39543
|
-
|
|
39544
|
-
|
|
39564
|
+
this.callbacks.forEach(
|
|
39565
|
+
(cb) => {
|
|
39566
|
+
var _a;
|
|
39567
|
+
return (_a = cb.onDeleteBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, local);
|
|
39568
|
+
}
|
|
39569
|
+
);
|
|
39545
39570
|
}
|
|
39546
39571
|
onInsertBlock(containerId, blockIndex, data2, local) {
|
|
39547
39572
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39548
|
-
this.callbacks.forEach(
|
|
39549
|
-
|
|
39550
|
-
|
|
39551
|
-
|
|
39573
|
+
this.callbacks.forEach(
|
|
39574
|
+
(cb) => {
|
|
39575
|
+
var _a;
|
|
39576
|
+
return (_a = cb.onInsertBlock) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, data2, local);
|
|
39577
|
+
}
|
|
39578
|
+
);
|
|
39552
39579
|
}
|
|
39553
39580
|
onUpdateBlockData(containerId, blockIndex, delta, local) {
|
|
39554
39581
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39555
|
-
this.callbacks.forEach(
|
|
39556
|
-
|
|
39557
|
-
|
|
39558
|
-
|
|
39582
|
+
this.callbacks.forEach(
|
|
39583
|
+
(cb) => {
|
|
39584
|
+
var _a;
|
|
39585
|
+
return (_a = cb.onUpdateBlockData) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, delta, local);
|
|
39586
|
+
}
|
|
39587
|
+
);
|
|
39559
39588
|
}
|
|
39560
39589
|
onUpdateBlockText(containerId, blockIndex, actions2, local) {
|
|
39561
39590
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39562
|
-
this.callbacks.forEach(
|
|
39563
|
-
|
|
39564
|
-
|
|
39565
|
-
|
|
39591
|
+
this.callbacks.forEach(
|
|
39592
|
+
(cb) => {
|
|
39593
|
+
var _a;
|
|
39594
|
+
return (_a = cb.onUpdateBlockText) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blockIndex, actions2, local);
|
|
39595
|
+
}
|
|
39596
|
+
);
|
|
39566
39597
|
}
|
|
39567
39598
|
onDeleteContainer(containerId, local) {
|
|
39568
39599
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39569
39600
|
assert(logger$2T, containerId !== "root", "should not delete root container in doc");
|
|
39570
|
-
this.callbacks.forEach(
|
|
39571
|
-
|
|
39572
|
-
|
|
39573
|
-
|
|
39601
|
+
this.callbacks.forEach(
|
|
39602
|
+
(cb) => {
|
|
39603
|
+
var _a;
|
|
39604
|
+
return (_a = cb.onDeleteChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), local);
|
|
39605
|
+
}
|
|
39606
|
+
);
|
|
39574
39607
|
}
|
|
39575
39608
|
onCreateContainer(containerId, blocks, local) {
|
|
39576
39609
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
39577
39610
|
assert(logger$2T, containerId !== "root", "should not create root container in doc");
|
|
39578
|
-
this.callbacks.forEach(
|
|
39579
|
-
|
|
39580
|
-
|
|
39581
|
-
|
|
39611
|
+
this.callbacks.forEach(
|
|
39612
|
+
(cb) => {
|
|
39613
|
+
var _a;
|
|
39614
|
+
return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, editorDpcContainerId2DocObjectContainerId(containerId), blocks, local);
|
|
39615
|
+
}
|
|
39616
|
+
);
|
|
39582
39617
|
}
|
|
39583
39618
|
onDeleteComment(commentId, local) {
|
|
39584
39619
|
assert(logger$2T, this.callbacks.length > 0, "no callbacks");
|
|
@@ -69978,6 +70013,9 @@ ${codeText}
|
|
|
69978
70013
|
}
|
|
69979
70014
|
});
|
|
69980
70015
|
__publicField(this, "handleSelectionChanged", () => {
|
|
70016
|
+
if (!this.editor.scrollable()) {
|
|
70017
|
+
return;
|
|
70018
|
+
}
|
|
69981
70019
|
setTimeout(() => {
|
|
69982
70020
|
var _a;
|
|
69983
70021
|
const commentIds = getCommentsFromSelection(this.editor);
|
|
@@ -70287,7 +70325,14 @@ ${codeText}
|
|
|
70287
70325
|
}
|
|
70288
70326
|
onCreateComment(commentId, local) {
|
|
70289
70327
|
const comment = this.commentsProvider.getComment(commentId);
|
|
70290
|
-
|
|
70328
|
+
try {
|
|
70329
|
+
this.editor.setScrollable(false);
|
|
70330
|
+
this.list.handleCreateComment(comment, local);
|
|
70331
|
+
} finally {
|
|
70332
|
+
setTimeout(() => {
|
|
70333
|
+
this.editor.setScrollable(true);
|
|
70334
|
+
}, 1e3);
|
|
70335
|
+
}
|
|
70291
70336
|
this.updateCommentCount();
|
|
70292
70337
|
}
|
|
70293
70338
|
onDeleteComment(commentId, local) {
|
|
@@ -70854,7 +70899,14 @@ ${codeText}
|
|
|
70854
70899
|
const range = createBlockSimpleRange(editor, block, selectedBlock.start.offset, selectedBlock.end.offset);
|
|
70855
70900
|
const command = `comment-${comment.id.toLocaleLowerCase()}`;
|
|
70856
70901
|
const value = comment.id;
|
|
70857
|
-
|
|
70902
|
+
try {
|
|
70903
|
+
editor.setScrollable(false);
|
|
70904
|
+
editorAddTextAttribute(editor, block, range, command, value);
|
|
70905
|
+
} finally {
|
|
70906
|
+
setTimeout(() => {
|
|
70907
|
+
editor.setScrollable(true);
|
|
70908
|
+
}, 1e3);
|
|
70909
|
+
}
|
|
70858
70910
|
}
|
|
70859
70911
|
function addCommentToTextBlocks(editor, range, provider) {
|
|
70860
70912
|
const selectedBlocks = getAllSelectedBlocks(editor, { range });
|
|
@@ -93245,9 +93297,19 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
93245
93297
|
__publicField(this, "id", "comment");
|
|
93246
93298
|
__publicField(this, "name", i18n$1.t("comment.command"));
|
|
93247
93299
|
__publicField(this, "icon", CommentIcon$1);
|
|
93300
|
+
__publicField(this, "adding", false);
|
|
93248
93301
|
}
|
|
93249
93302
|
onClick(editor, item) {
|
|
93250
|
-
|
|
93303
|
+
if (this.adding) {
|
|
93304
|
+
return;
|
|
93305
|
+
}
|
|
93306
|
+
this.adding = true;
|
|
93307
|
+
setTimeout(() => {
|
|
93308
|
+
editorAddComment(editor);
|
|
93309
|
+
setTimeout(() => {
|
|
93310
|
+
this.adding = false;
|
|
93311
|
+
}, 300);
|
|
93312
|
+
}, 300);
|
|
93251
93313
|
}
|
|
93252
93314
|
}
|
|
93253
93315
|
class ColorItem extends TextColorItem {
|
|
@@ -93857,7 +93919,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
93857
93919
|
}
|
|
93858
93920
|
}
|
|
93859
93921
|
});
|
|
93860
|
-
editor.version = "2.8.
|
|
93922
|
+
editor.version = "2.8.39";
|
|
93861
93923
|
return editor;
|
|
93862
93924
|
}
|
|
93863
93925
|
function isDoc(doc2) {
|
|
@@ -93970,7 +94032,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
93970
94032
|
}
|
|
93971
94033
|
});
|
|
93972
94034
|
OnesEditorToolbar.register(editor);
|
|
93973
|
-
editor.version = "2.8.
|
|
94035
|
+
editor.version = "2.8.39";
|
|
93974
94036
|
return editor;
|
|
93975
94037
|
}
|
|
93976
94038
|
async function showDocVersions(editor, options, serverUrl) {
|