@ones-editor/editor 1.1.18-beta.13 → 1.1.18-beta.15

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/index.js CHANGED
@@ -34350,7 +34350,9 @@ ${codeText}
34350
34350
  this.events.emit("writeConflictError", error2);
34351
34351
  }
34352
34352
  emitMaxUsersError() {
34353
- this.events.emit("maxUsersError");
34353
+ const err = new Error(MaxUserError.msg);
34354
+ err.code = MaxUserError.err;
34355
+ this.events.emit("maxUsersError", err);
34354
34356
  this.end(false);
34355
34357
  }
34356
34358
  handleMessage(message) {
@@ -35681,6 +35683,12 @@ ${codeText}
35681
35683
  return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35682
35684
  });
35683
35685
  });
35686
+ this.client.onMaxUsersError((err) => {
35687
+ this.callbacks.forEach((cb) => {
35688
+ var _a;
35689
+ return (_a = cb.onError) == null ? void 0 : _a.call(cb, err);
35690
+ });
35691
+ });
35684
35692
  this.client.onWriteConflictError(this.handleWriteConflictError);
35685
35693
  }
35686
35694
  clearEvents() {
@@ -43407,7 +43415,8 @@ ${codeText}
43407
43415
  let prevBlock = getPrevBlock(block);
43408
43416
  while (prevBlock) {
43409
43417
  if (!isListBlock(prevBlock)) {
43410
- return null;
43418
+ prevBlock = getPrevBlock(prevBlock);
43419
+ continue;
43411
43420
  }
43412
43421
  const { level: testLevel, groupId: testGroupId, type: testType } = getListBlockProperties(prevBlock);
43413
43422
  if (testLevel < level) {
@@ -44214,8 +44223,10 @@ ${codeText}
44214
44223
  }
44215
44224
  const newBlock = editor.insertBlock(getContainerId(container), blockIndex, newBlockData, createBlockSimpleDocRange(newBlockData.id, 0));
44216
44225
  editor.deleteBlock(draggedBlock);
44217
- const fixStart2 = new FixStartByList(editor, newBlock);
44218
- fixStart2.fix();
44226
+ if (groupId !== oldData.groupId) {
44227
+ const fixStart2 = new FixStartByList(editor, newBlock);
44228
+ fixStart2.fix();
44229
+ }
44219
44230
  fixStart1 == null ? void 0 : fixStart1.fix();
44220
44231
  return true;
44221
44232
  }
@@ -45098,6 +45109,7 @@ ${codeText}
45098
45109
  }
45099
45110
  class ListBlockInputHandler {
45100
45111
  constructor(editor) {
45112
+ __publicField(this, "fixStartByList", null);
45101
45113
  this.editor = editor;
45102
45114
  }
45103
45115
  handleBeforeKeyDown(editor, event) {
@@ -45139,6 +45151,66 @@ ${codeText}
45139
45151
  }
45140
45152
  return this.editor.undoManager.runInGroup(() => handleTab$2(this.editor));
45141
45153
  }
45154
+ getPreListBlock(editor) {
45155
+ const startBlock = editor.selection.startBlock;
45156
+ if (isListBlock(startBlock)) {
45157
+ return startBlock;
45158
+ }
45159
+ const preBlock = getPrevBlock(startBlock);
45160
+ if (preBlock && isListBlock(preBlock)) {
45161
+ return preBlock;
45162
+ }
45163
+ return null;
45164
+ }
45165
+ async handleBeforePasteDoc(editor, doc2) {
45166
+ const preBlock = this.getPreListBlock(editor);
45167
+ const preBlockData = preBlock ? editor.getBlockData(preBlock) : null;
45168
+ if (preBlock) {
45169
+ this.fixStartByList = new FixStartByWillDeletedList(editor, preBlock);
45170
+ }
45171
+ const groupIds = /* @__PURE__ */ new Map();
45172
+ const getGroupId = (id) => {
45173
+ if (groupIds.has(id)) {
45174
+ return groupIds.get(id);
45175
+ }
45176
+ return id;
45177
+ };
45178
+ Object.values(doc2.blocks).forEach((blocks) => {
45179
+ blocks.forEach((block, index2) => {
45180
+ var _a;
45181
+ if (block.type === "list") {
45182
+ const preDocBlock = (_a = blocks[index2 - 1]) != null ? _a : preBlockData;
45183
+ let needReset = !preDocBlock || preDocBlock.type !== "list" || preDocBlock.level !== block.level;
45184
+ if (needReset && index2 !== 0) {
45185
+ needReset = getGroupId(preDocBlock.groupId) !== block.groupId;
45186
+ }
45187
+ if (needReset) {
45188
+ block.start = 1;
45189
+ const newGroupId = genId();
45190
+ groupIds.set(newGroupId, block.groupId);
45191
+ block.groupId = newGroupId;
45192
+ } else {
45193
+ if (index2 === 0 && isListBlock(editor.selection.startBlock)) {
45194
+ block.start = preDocBlock.start;
45195
+ } else {
45196
+ block.start = preDocBlock.start + 1;
45197
+ }
45198
+ block.groupId = preDocBlock.groupId;
45199
+ }
45200
+ }
45201
+ });
45202
+ });
45203
+ return false;
45204
+ }
45205
+ async handleAfterPaste(editor) {
45206
+ editor.undoManager.runInGroup(() => {
45207
+ if (this.fixStartByList) {
45208
+ this.fixStartByList.fix();
45209
+ this.fixStartByList = null;
45210
+ }
45211
+ });
45212
+ return false;
45213
+ }
45142
45214
  }
45143
45215
  class ListClearSelectionHandler {
45144
45216
  constructor(editor) {
@@ -77058,7 +77130,7 @@ ${data.flowchartText}
77058
77130
  }
77059
77131
  }
77060
77132
  });
77061
- editor.version = "1.1.18-beta.13";
77133
+ editor.version = "1.1.18-beta.15";
77062
77134
  if (Logger$2.level === LogLevel.DEBUG) {
77063
77135
  window.setReauthFail = (fail) => {
77064
77136
  window.isReauthError = fail;
@@ -77146,7 +77218,7 @@ ${data.flowchartText}
77146
77218
  });
77147
77219
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
77148
77220
  OnesEditorToolbar.register(editor);
77149
- editor.version = "1.1.18-beta.13";
77221
+ editor.version = "1.1.18-beta.15";
77150
77222
  return editor;
77151
77223
  }
77152
77224
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "1.1.18-beta.13",
3
+ "version": "1.1.18-beta.15",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",