@ones-editor/editor 2.2.0-beta.1 → 2.2.0-beta.3

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
@@ -24711,7 +24711,7 @@ var __publicField = (obj, key, value) => {
24711
24711
  __publicField(this, "composing", false);
24712
24712
  __publicField(this, "callbacks");
24713
24713
  __publicField(this, "inputElement");
24714
- __publicField(this, "handleBlur", () => {
24714
+ __publicField(this, "handleWindowBlur", () => {
24715
24715
  this.editor.emit("blur", this.editor);
24716
24716
  this.callbacks.onBlur();
24717
24717
  });
@@ -24738,7 +24738,8 @@ var __publicField = (obj, key, value) => {
24738
24738
  return;
24739
24739
  }
24740
24740
  setTimeout(() => {
24741
- this.handleBlur();
24741
+ this.editor.emit("blur", this.editor);
24742
+ this.callbacks.onBlur();
24742
24743
  });
24743
24744
  });
24744
24745
  __publicField(this, "handleDocumentSelectionChange", () => {
@@ -24753,7 +24754,8 @@ var __publicField = (obj, key, value) => {
24753
24754
  return;
24754
24755
  }
24755
24756
  }
24756
- this.handleBlur();
24757
+ this.editor.emit("blur", this.editor);
24758
+ this.callbacks.onBlur();
24757
24759
  }, 100);
24758
24760
  });
24759
24761
  __publicField(this, "handleEditorSelectionChanged", () => {
@@ -24867,7 +24869,7 @@ var __publicField = (obj, key, value) => {
24867
24869
  document.addEventListener("selectionchange", this.handleDocumentSelectionChange);
24868
24870
  this.editor.addListener("selectionChanged", this.handleEditorSelectionChanged);
24869
24871
  this.editor.addListener("readonlyChanged", this.handleReadonlyChanged);
24870
- window.addEventListener("blur", this.handleBlur);
24872
+ window.addEventListener("blur", this.handleWindowBlur);
24871
24873
  window.addEventListener("focus", this.handleWindowFocus);
24872
24874
  }
24873
24875
  isInCommandBar(target) {
@@ -24897,7 +24899,7 @@ var __publicField = (obj, key, value) => {
24897
24899
  input2.oninput = null;
24898
24900
  input2.oncopy = null;
24899
24901
  document.removeEventListener("paste", this.handlePaste);
24900
- window.removeEventListener("blur", this.handleBlur);
24902
+ window.removeEventListener("blur", this.handleWindowBlur);
24901
24903
  window.removeEventListener("focus", this.handleWindowFocus);
24902
24904
  input2.oncut = null;
24903
24905
  }
@@ -28299,16 +28301,7 @@ ${codeText}
28299
28301
  this.pasteDocs(docs, null, files);
28300
28302
  }
28301
28303
  });
28302
- __publicField(this, "onBlur", () => {
28303
- var _a;
28304
- for (const handler of this.handlers) {
28305
- if ((_a = handler.handleBlur) == null ? void 0 : _a.call(handler, this.editor)) {
28306
- return;
28307
- }
28308
- }
28309
- this.debounceBlur();
28310
- });
28311
- __publicField(this, "debounceBlur", debounce__default.default(() => {
28304
+ __publicField(this, "onBlur", debounce__default.default(() => {
28312
28305
  const range = this.editor.selection.range;
28313
28306
  if (!range.isCollapsed()) {
28314
28307
  let block = null;
@@ -28443,7 +28436,7 @@ ${codeText}
28443
28436
  }
28444
28437
  onFocus() {
28445
28438
  addClass(this.editor.rootElement, "active");
28446
- this.debounceBlur.cancel();
28439
+ this.onBlur.cancel();
28447
28440
  this.removeActiveForBlur.cancel();
28448
28441
  }
28449
28442
  addHandler(handler) {
@@ -59918,6 +59911,9 @@ $$${mathData.mathjaxText}$$
59918
59911
  md5Cache.set(src, key);
59919
59912
  return `${key}_width`;
59920
59913
  }
59914
+ function getImageWidthRealKey(widthKey) {
59915
+ return `${widthKey}_r`;
59916
+ }
59921
59917
  function getImageHeightKeyFromSrc(src) {
59922
59918
  if (md5Cache.has(src)) {
59923
59919
  const key2 = md5Cache.get(src);
@@ -59960,9 +59956,11 @@ $$${mathData.mathjaxText}$$
59960
59956
  src2 = `empty:${index2}`;
59961
59957
  }
59962
59958
  const widthKey = getImageWidthKeyFromSrc(src2);
59959
+ const widthRealKey = getImageWidthRealKey(widthKey);
59963
59960
  const heightKey = getImageHeightKeyFromSrc(src2);
59964
59961
  const flexKey = getImageFlexKeyFromSrc(index2);
59965
59962
  let width = data2[widthKey];
59963
+ const widthReal = data2[widthRealKey];
59966
59964
  let height = data2[heightKey];
59967
59965
  let flex = data2[flexKey];
59968
59966
  if (typeof width === "string") {
@@ -59974,7 +59972,11 @@ $$${mathData.mathjaxText}$$
59974
59972
  if (typeof flex === "string") {
59975
59973
  flex = Number.parseInt(flex, 10);
59976
59974
  }
59977
- return { src: src2, width: width != null ? width : "auto", height: height != null ? height : "auto", flex, virtualSize: !width || !height };
59975
+ const result = { src: src2, width: width != null ? width : "auto", height: height != null ? height : "auto", flex, virtualSize: !width || !height };
59976
+ if (widthReal) {
59977
+ result.widthReal = widthReal;
59978
+ }
59979
+ return result;
59978
59980
  };
59979
59981
  let images = [];
59980
59982
  const src = data2.src;
@@ -59995,6 +59997,52 @@ $$${mathData.mathjaxText}$$
59995
59997
  }
59996
59998
  return imageData.widthPercent;
59997
59999
  }
60000
+ function getWidthReal(blockData) {
60001
+ const images = getImages$1(blockData.embedData);
60002
+ if (images.length > 1) {
60003
+ return void 0;
60004
+ }
60005
+ const image = images[0];
60006
+ return image.widthReal;
60007
+ }
60008
+ function clearWidthReal(imageData) {
60009
+ const keys = Object.keys(imageData);
60010
+ keys.forEach((key) => {
60011
+ if (key.endsWith("_r")) {
60012
+ delete imageData[key];
60013
+ }
60014
+ });
60015
+ }
60016
+ function setWidthPercentAndWidthReal(blockData, widthPercent, widthReal) {
60017
+ const imageData = blockData.embedData;
60018
+ imageData.widthPercent = widthPercent;
60019
+ const images = getImages$1(blockData.embedData);
60020
+ clearWidthReal(blockData.embedData);
60021
+ if (images.length > 1) {
60022
+ return;
60023
+ }
60024
+ const image = images[0];
60025
+ const widthKey = getImageWidthKeyFromSrc(image.src);
60026
+ const widthRealKey = getImageWidthRealKey(widthKey);
60027
+ if (widthReal) {
60028
+ imageData[widthRealKey] = widthReal;
60029
+ } else if (isValidSize(image.width)) {
60030
+ imageData[widthRealKey] = image.width;
60031
+ }
60032
+ }
60033
+ function getHeightReal(blockData, containerElement) {
60034
+ const images = getImages$1(blockData.embedData);
60035
+ if (images.length > 1) {
60036
+ return void 0;
60037
+ }
60038
+ let containerWidth = containerElement.getBoundingClientRect().width;
60039
+ containerWidth -= Number.parseFloat(window.getComputedStyle(containerElement).paddingLeft) + Number.parseFloat(window.getComputedStyle(containerElement).paddingRight);
60040
+ const image = images[0];
60041
+ if (image.widthReal && image.width && image.width !== "auto" && image.height && image.height !== "auto") {
60042
+ return Math.min(image.widthReal, containerWidth) * image.height / image.width;
60043
+ }
60044
+ return void 0;
60045
+ }
59998
60046
  function calImageBlockStyleWidth(editor, blockData, parentContainerElement, failedLoad) {
59999
60047
  const images = getImages$1(blockData.embedData);
60000
60048
  if (images.length > 1) {
@@ -60003,26 +60051,33 @@ $$${mathData.mathjaxText}$$
60003
60051
  if (failedLoad) {
60004
60052
  return "100%";
60005
60053
  }
60054
+ const widthReal = getWidthReal(blockData);
60055
+ if (widthReal) {
60056
+ return `${widthReal}px`;
60057
+ }
60058
+ const image = images[0];
60006
60059
  const percent = getWidthPercent(blockData);
60007
60060
  const totalWidth = editor.rootContainer.getBoundingClientRect().width;
60008
60061
  if (percent) {
60009
60062
  const parentWidth = getContainerContentWidth(parentContainerElement);
60010
60063
  return `${Math.min(totalWidth * percent / 100, parentWidth)}px`;
60011
60064
  }
60012
- if (isValidSize(images[0].width)) {
60013
- return `${images[0].width}px`;
60065
+ if (isValidSize(image.width)) {
60066
+ return `${image.width}px`;
60014
60067
  }
60015
60068
  return "auto";
60016
60069
  }
60017
- function toImageEmbedData(images, widthPercent) {
60070
+ function toImageEmbedData(editor, images, widthPercent) {
60018
60071
  const src = images.map((image) => image.src).join("|");
60019
60072
  const result = {
60020
60073
  src,
60021
60074
  widthPercent
60022
60075
  };
60076
+ const editorWidth = editor.rootContainer.clientWidth;
60023
60077
  images.forEach((image, index2) => {
60024
60078
  const src2 = image.src || `empty:${index2}`;
60025
60079
  const widthKey = getImageWidthKeyFromSrc(src2);
60080
+ const widthRealKey = getImageWidthRealKey(widthKey);
60026
60081
  if (widthKey && isValidSize(image.width)) {
60027
60082
  result[widthKey] = image.width;
60028
60083
  }
@@ -60033,6 +60088,12 @@ $$${mathData.mathjaxText}$$
60033
60088
  assert(logger$1z, image.flex, "no image flex");
60034
60089
  const flexKey = getImageFlexKeyFromSrc(index2);
60035
60090
  result[flexKey] = image.flex;
60091
+ if (widthKey && images.length === 1) {
60092
+ if (widthPercent && image.width !== "auto") {
60093
+ const widthReal = widthPercent === 100 ? image.width : editorWidth * widthPercent / 100;
60094
+ result[widthRealKey] = widthReal;
60095
+ }
60096
+ }
60036
60097
  });
60037
60098
  return result;
60038
60099
  }
@@ -60057,7 +60118,8 @@ $$${mathData.mathjaxText}$$
60057
60118
  const imageHeight = image.height;
60058
60119
  return imageHeight === "auto" ? "auto" : `${imageHeight}px`;
60059
60120
  }
60060
- let totalWidth = parentContainer.getBoundingClientRect().width * (widthPercent / 100);
60121
+ const containerWidth = parentContainer.getBoundingClientRect().width;
60122
+ let totalWidth = containerWidth * (widthPercent / 100);
60061
60123
  totalWidth -= Number.parseFloat(window.getComputedStyle(parentContainer).paddingLeft) + Number.parseFloat(window.getComputedStyle(parentContainer).paddingRight);
60062
60124
  if (parentContainer === editor.rootContainer && parentContainer !== parentContainerElement) {
60063
60125
  totalWidth = Math.min(totalWidth, getContainerContentWidth(parentContainerElement));
@@ -60067,6 +60129,10 @@ $$${mathData.mathjaxText}$$
60067
60129
  if (image.virtualSize) {
60068
60130
  return "";
60069
60131
  }
60132
+ const heightReal = getHeightReal(imageData, parentContainerElement);
60133
+ if (heightReal) {
60134
+ return `${heightReal}px`;
60135
+ }
60070
60136
  const width = image.width === "auto" ? DEFAULT_WIDTH$1 : image.width;
60071
60137
  const imageHeight = image.height / (width / totalWidth);
60072
60138
  return `${imageHeight}px`;
@@ -60228,7 +60294,7 @@ $$${mathData.mathjaxText}$$
60228
60294
  }
60229
60295
  setDefaultCursor("");
60230
60296
  this.unbindEvents();
60231
- this.emit("resized", this);
60297
+ this.emit("resized", this, event);
60232
60298
  const element = this.getResizableElement();
60233
60299
  if (!element || !this.block) {
60234
60300
  return;
@@ -60427,7 +60493,7 @@ $$${mathData.mathjaxText}$$
60427
60493
  }
60428
60494
  const block = this.data.block;
60429
60495
  const imageObject = getImageObject(this.editor, block);
60430
- imageObject.setResizing(true);
60496
+ imageObject.setDisableResizing(true);
60431
60497
  }
60432
60498
  onDragging(drag, event, elem, deltaX, deltaY) {
60433
60499
  const block = this.data.block;
@@ -60461,7 +60527,7 @@ $$${mathData.mathjaxText}$$
60461
60527
  imageContainers[i].style.flexGrow = `${flex}`;
60462
60528
  }
60463
60529
  const blockData = cloneDeep__default.default(this.editor.getBlockData(block));
60464
- const embedData = toImageEmbedData(images, getWidthPercent(blockData));
60530
+ const embedData = toImageEmbedData(this.editor, images, getWidthPercent(blockData));
60465
60531
  blockData.embedData = embedData;
60466
60532
  updateImageBlockSize(this.editor, blockData, block, null);
60467
60533
  }
@@ -60474,7 +60540,7 @@ $$${mathData.mathjaxText}$$
60474
60540
  return flex2;
60475
60541
  });
60476
60542
  imageObject.updateFlex(flex);
60477
- imageObject.setResizing(false);
60543
+ imageObject.setDisableResizing(false);
60478
60544
  }
60479
60545
  }
60480
60546
  function getParentImageSplitter(eventTarget) {
@@ -60834,6 +60900,7 @@ $$${mathData.mathjaxText}$$
60834
60900
  __publicField(this, "images", []);
60835
60901
  __publicField(this, "selectedIndex", -1);
60836
60902
  __publicField(this, "blockResizer");
60903
+ __publicField(this, "disableResizing", false);
60837
60904
  __publicField(this, "resizing", false);
60838
60905
  __publicField(this, "parentContainerResizerObserver", null);
60839
60906
  __publicField(this, "autoFix", false);
@@ -60857,7 +60924,7 @@ $$${mathData.mathjaxText}$$
60857
60924
  if (this.isEmpty()) {
60858
60925
  return;
60859
60926
  }
60860
- if (this.resizing) {
60927
+ if (this.disableResizing) {
60861
60928
  return;
60862
60929
  }
60863
60930
  const block = this.editor.findBlockById(this.blockData.id);
@@ -60865,7 +60932,28 @@ $$${mathData.mathjaxText}$$
60865
60932
  return;
60866
60933
  }
60867
60934
  if (getParentContainer(block) === container) {
60868
- updateImageBlockSize(this.editor, this.blockData, block, null);
60935
+ const resizeObj = block.resizeObj || [];
60936
+ const rect = container.getBoundingClientRect();
60937
+ const now = Date.now();
60938
+ let found = false;
60939
+ for (let i = resizeObj.length - 1; i >= 0; i--) {
60940
+ if (now - resizeObj[i].time > 200) {
60941
+ resizeObj.splice(i, 1);
60942
+ continue;
60943
+ }
60944
+ if (rect.width === resizeObj[i].width) {
60945
+ found = true;
60946
+ break;
60947
+ }
60948
+ }
60949
+ resizeObj.push({
60950
+ time: now,
60951
+ width: rect.width
60952
+ });
60953
+ block.resizeObj = resizeObj;
60954
+ if (!found) {
60955
+ updateImageBlockSize(this.editor, this.blockData, block, null);
60956
+ }
60869
60957
  }
60870
60958
  });
60871
60959
  __publicField(this, "handleResizing", (resizer, rect) => {
@@ -60873,6 +60961,8 @@ $$${mathData.mathjaxText}$$
60873
60961
  if (!block) {
60874
60962
  return;
60875
60963
  }
60964
+ this.resizing = true;
60965
+ window.isDragging = true;
60876
60966
  if (!this.autoFix) {
60877
60967
  this.setAutoFix(true);
60878
60968
  }
@@ -60885,25 +60975,42 @@ $$${mathData.mathjaxText}$$
60885
60975
  if (newWidth < 50) {
60886
60976
  newWidth = 50;
60887
60977
  }
60888
- const widthPercent = newWidth * 100 / totalWidth;
60889
- this.blockData.embedData.widthPercent = widthPercent;
60978
+ let widthPercent = newWidth * 100 / totalWidth;
60979
+ if (newWidth === blockRect.width) {
60980
+ widthPercent = 100;
60981
+ }
60982
+ const rootBlock = getRootBlock(block);
60983
+ if (getBlockType(rootBlock) !== "layout" && widthPercent === 100) {
60984
+ widthPercent = 99.99;
60985
+ }
60986
+ setWidthPercentAndWidthReal(this.blockData, widthPercent, newWidth);
60890
60987
  updateImageBlockSize(this.editor, this.blockData, block, null);
60891
60988
  });
60892
- __publicField(this, "handleResized", () => {
60989
+ __publicField(this, "handleResized", (resizer, event) => {
60893
60990
  const block = this.editor.findBlockById(this.blockData.id);
60894
60991
  if (!block) {
60895
60992
  return;
60896
60993
  }
60897
- const embedData = toImageEmbedData(this.images, getWidthPercent(this.blockData));
60898
- this.editor.updateEmbedData(block, embedData);
60994
+ this.resizing = false;
60995
+ window.isDragging = false;
60996
+ const rootBlock = getRootBlock(block);
60997
+ const widthPercent = getWidthPercent(this.blockData);
60998
+ const embedData = toImageEmbedData(this.editor, this.images, widthPercent);
60999
+ if (getBlockType(rootBlock) === "layout" && widthPercent === 100) {
61000
+ clearWidthReal(embedData);
61001
+ }
60899
61002
  this.blockResizer.enableResize(block);
61003
+ if (!block.contains(event.target)) {
61004
+ this.disableResizer();
61005
+ }
61006
+ this.editor.updateEmbedData(block, embedData);
60900
61007
  });
60901
61008
  __publicField(this, "fixImageSizes", debounce__default.default(() => {
60902
61009
  const block = this.editor.findBlockById(this.blockData.id);
60903
61010
  if (!block) {
60904
61011
  return;
60905
61012
  }
60906
- const embedData = toImageEmbedData(this.images, getWidthPercent(this.blockData));
61013
+ const embedData = toImageEmbedData(this.editor, this.images, getWidthPercent(this.blockData));
60907
61014
  this.editor.updateEmbedData(block, embedData);
60908
61015
  }, 1e3));
60909
61016
  this.editor = editor;
@@ -60967,8 +61074,8 @@ $$${mathData.mathjaxText}$$
60967
61074
  isEmpty() {
60968
61075
  return this.images.length === 1 && isEmptyImage$1(this.images[0]);
60969
61076
  }
60970
- setResizing(resizing) {
60971
- this.resizing = resizing;
61077
+ setDisableResizing(disable) {
61078
+ this.disableResizing = disable;
60972
61079
  }
60973
61080
  getSelectedIndex() {
60974
61081
  return this.selectedIndex;
@@ -61024,6 +61131,9 @@ $$${mathData.mathjaxText}$$
61024
61131
  }
61025
61132
  }
61026
61133
  disableResizer() {
61134
+ if (this.resizing) {
61135
+ return;
61136
+ }
61027
61137
  this.blockResizer.disableResize();
61028
61138
  }
61029
61139
  fixImageSize(index2, image) {
@@ -61061,7 +61171,7 @@ $$${mathData.mathjaxText}$$
61061
61171
  if (this.selectedIndex >= newImages.length) {
61062
61172
  this.selectedIndex = newImages.length - 1;
61063
61173
  }
61064
- const embedData = toImageEmbedData(newImages, getWidthPercent(this.blockData));
61174
+ const embedData = toImageEmbedData(this.editor, newImages, getWidthPercent(this.blockData));
61065
61175
  this.editor.updateEmbedData(block, embedData);
61066
61176
  return true;
61067
61177
  }
@@ -61080,7 +61190,7 @@ $$${mathData.mathjaxText}$$
61080
61190
  imageData.virtualSize = false;
61081
61191
  this.images[0].flex = NaN;
61082
61192
  calcImagesFlexIfNeeded(this.images);
61083
- const embedData = toImageEmbedData(this.images, getWidthPercent(this.blockData));
61193
+ const embedData = toImageEmbedData(this.editor, this.images, getWidthPercent(this.blockData));
61084
61194
  this.editor.updateEmbedData(block, embedData);
61085
61195
  }
61086
61196
  const newImageData = {
@@ -61115,7 +61225,7 @@ $$${mathData.mathjaxText}$$
61115
61225
  return false;
61116
61226
  }
61117
61227
  removeClass(block2, "media-block-uploading");
61118
- const embedData = toImageEmbedData(this.images, getWidthPercent(this.blockData));
61228
+ const embedData = toImageEmbedData(this.editor, this.images, getWidthPercent(this.blockData));
61119
61229
  this.editor.updateEmbedData(block2, embedData);
61120
61230
  return true;
61121
61231
  } catch (err) {
@@ -61140,7 +61250,7 @@ $$${mathData.mathjaxText}$$
61140
61250
  for (let i = 0; i < this.images.length; i++) {
61141
61251
  this.images[i].flex = flex[i];
61142
61252
  }
61143
- const embedData = toImageEmbedData(this.images, getWidthPercent(this.blockData));
61253
+ const embedData = toImageEmbedData(this.editor, this.images, getWidthPercent(this.blockData));
61144
61254
  this.editor.updateEmbedData(block, embedData);
61145
61255
  }
61146
61256
  resetFlex() {
@@ -61151,7 +61261,7 @@ $$${mathData.mathjaxText}$$
61151
61261
  const newImages = cloneDeep__default.default(this.images);
61152
61262
  newImages[0].flex = NaN;
61153
61263
  calcImagesFlexIfNeeded(newImages);
61154
- const embedData = toImageEmbedData(newImages, getWidthPercent(this.blockData));
61264
+ const embedData = toImageEmbedData(this.editor, newImages, getWidthPercent(this.blockData));
61155
61265
  this.editor.updateEmbedData(block, embedData);
61156
61266
  }
61157
61267
  setData(blockData) {
@@ -64278,13 +64388,13 @@ ${codeText}
64278
64388
  const image = images[0];
64279
64389
  const widthPercent = 100 * (image.flex / totalFlex);
64280
64390
  image.flex = 1;
64281
- const embedData2 = toImageEmbedData([image], widthPercent);
64391
+ const embedData2 = toImageEmbedData(editor, [image], widthPercent);
64282
64392
  editor.updateEmbedData(block, embedData2);
64283
64393
  return;
64284
64394
  }
64285
64395
  images[0].flex = NaN;
64286
64396
  calcImagesFlexIfNeeded(images);
64287
- const embedData = toImageEmbedData(images, imageObject.getWidthPercent());
64397
+ const embedData = toImageEmbedData(editor, images, imageObject.getWidthPercent());
64288
64398
  editor.updateEmbedData(block, embedData);
64289
64399
  }
64290
64400
  function processInsertFilesToImage(editor, files, targetBlock, insertPos) {
@@ -64320,7 +64430,7 @@ ${codeText}
64320
64430
  virtualSize: true
64321
64431
  };
64322
64432
  images.splice(insertIndex, 0, itemData);
64323
- const embedData = toImageEmbedData(images, imageObject.getWidthPercent());
64433
+ const embedData = toImageEmbedData(editor, images, imageObject.getWidthPercent());
64324
64434
  editor.updateEmbedData(targetBlock, embedData);
64325
64435
  imageObject.replaceImage(insertIndex, file2);
64326
64436
  insertIndex += 1;
@@ -64352,9 +64462,9 @@ ${codeText}
64352
64462
  if (insertPos === "after") {
64353
64463
  blockIndex += 1;
64354
64464
  }
64355
- const width = draggedImage.boundingRect.width;
64356
- const widthPercent = 100 * (width / editor.rootContainer.getBoundingClientRect().width);
64357
- const embedData = toImageEmbedData([draggedImage.image], widthPercent);
64465
+ const sourceData = editor.getBlockData(block);
64466
+ const widthPercent = sourceData.embedData.widthPercent;
64467
+ const embedData = toImageEmbedData(editor, [draggedImage.image], widthPercent);
64358
64468
  const blockData = {
64359
64469
  id: genId(),
64360
64470
  type: "embed",
@@ -64399,7 +64509,7 @@ ${codeText}
64399
64509
  images.splice(fromIndex, 1);
64400
64510
  images.splice(toIndex, 0, image);
64401
64511
  }
64402
- const embedData = toImageEmbedData(images, imageObject.getWidthPercent());
64512
+ const embedData = toImageEmbedData(editor, images, imageObject.getWidthPercent());
64403
64513
  editor.updateEmbedData(targetBlock, embedData);
64404
64514
  imageObject.setSelectedIndex(resultIndex);
64405
64515
  (_a2 = editor.findCustom("drag-handler")) == null ? void 0 : _a2.handleDragEnd();
@@ -64407,7 +64517,7 @@ ${codeText}
64407
64517
  images.splice(imageInsertIndex, 0, draggedImage.image);
64408
64518
  images[0].flex = NaN;
64409
64519
  calcImagesFlexIfNeeded(images);
64410
- const embedData = toImageEmbedData(images, imageObject.getWidthPercent());
64520
+ const embedData = toImageEmbedData(editor, images, imageObject.getWidthPercent());
64411
64521
  editor.updateEmbedData(targetBlock, embedData);
64412
64522
  deleteImageFromBlock(editor, sourceBlock, draggedImage.index);
64413
64523
  (_b2 = editor.findCustom("drag-handler")) == null ? void 0 : _b2.handleDragEnd();
@@ -64751,7 +64861,7 @@ ${codeText}
64751
64861
  function getImageClipboardData(editor, img, imageObject, index2) {
64752
64862
  const imageData = imageObject.getImages()[index2];
64753
64863
  const widthPercent = imageObject.getImages().length === 1 ? imageObject.getWidthPercent() : imageData.flex * 100;
64754
- const embedData = toImageEmbedData([imageData], widthPercent);
64864
+ const embedData = toImageEmbedData(editor, [imageData], widthPercent);
64755
64865
  const blockData = {
64756
64866
  id: genId(),
64757
64867
  type: "embed",
@@ -65471,7 +65581,7 @@ ${codeText}
65471
65581
  flex: 1,
65472
65582
  virtualSize: false
65473
65583
  };
65474
- const embedData = toImageEmbedData([imageItem], widthPercent);
65584
+ const embedData = toImageEmbedData(editor, [imageItem], widthPercent);
65475
65585
  const blockData = {
65476
65586
  id: genId(),
65477
65587
  type: "embed",
@@ -80667,6 +80777,10 @@ ${content}
80667
80777
  }
80668
80778
  if (sourceBlock && !(isHeadingBlock$1(sourceBlock) && isCollapsedHeadingBlock(sourceBlock))) {
80669
80779
  const sourceBlockData = editor.getBlockData(sourceBlock);
80780
+ if (sourceBlock && isEmbedBlock(sourceBlock) && getEmbedType(sourceBlock) === "image") {
80781
+ clearWidthReal(sourceBlockData.embedData);
80782
+ sourceBlockData.embedData.widthPercent = 100;
80783
+ }
80670
80784
  newContainerID = createContainer$1(editor.doc, cloneBlock(editor.editorBlocks, editor.doc.toJSON(), sourceBlockData));
80671
80785
  editor.deleteBlock(sourceBlock);
80672
80786
  } else {
@@ -80696,6 +80810,11 @@ ${content}
80696
80810
  blockData.children.splice(removeIndex, 1);
80697
80811
  if (blockData.children.length === 1) {
80698
80812
  const remainContent = cloneChildContainer(editor.editorBlocks, editor.doc.toJSON(), blockData.children[0]);
80813
+ remainContent.blocks.root.forEach((remainBlockData) => {
80814
+ if (remainBlockData.type === "embed" && remainBlockData.embedType === "image" && remainBlockData.embedData.widthPercent === 100) {
80815
+ setWidthPercentAndWidthReal(remainBlockData, 100);
80816
+ }
80817
+ });
80699
80818
  editor.insertDocAt(editor.getContainerById("root"), editor.getBlockIndex(layoutBlock), remainContent);
80700
80819
  editor.deleteBlock(layoutBlock);
80701
80820
  return;
@@ -80967,11 +81086,13 @@ ${content}
80967
81086
  } else {
80968
81087
  if (isEmbedBlock(source) && getEmbedType(source) === "image") {
80969
81088
  sourceData = editor.getBlockData(source);
81089
+ clearWidthReal(sourceData.embedData);
80970
81090
  sourceData.embedData.widthPercent = 100;
80971
81091
  }
80972
81092
  let targetData;
80973
81093
  if (isEmbedBlock(target) && getEmbedType(target) === "image") {
80974
81094
  targetData = editor.getBlockData(target);
81095
+ clearWidthReal(targetData.embedData);
80975
81096
  targetData.embedData.widthPercent = 100;
80976
81097
  }
80977
81098
  const cols = position === "left" ? [source, target] : [target, source];
@@ -81486,6 +81607,7 @@ ${content}
81486
81607
  this.dragRecord.dragItem = dragger;
81487
81608
  this.showDragging();
81488
81609
  document.addEventListener("mousemove", this.handleDragging);
81610
+ window.isDragging = true;
81489
81611
  });
81490
81612
  __publicField(this, "handleDragging", (event) => {
81491
81613
  if (!this.dragRecord)
@@ -81547,6 +81669,7 @@ ${content}
81547
81669
  __publicField(this, "handleMouseUp", () => {
81548
81670
  document.removeEventListener("mousemove", this.handleDragging);
81549
81671
  this.updateBlockData();
81672
+ window.isDragging = false;
81550
81673
  this.hideDragging();
81551
81674
  this.draggingRef = null;
81552
81675
  this.dragRecord = null;
@@ -86870,7 +86993,7 @@ ${data2.flowchartText}
86870
86993
  }
86871
86994
  }
86872
86995
  });
86873
- editor.version = "2.2.0-beta.1";
86996
+ editor.version = "2.2.0-beta.3";
86874
86997
  if (Logger$2.level === LogLevel.DEBUG) {
86875
86998
  window.setReauthFail = (fail) => {
86876
86999
  window.isReauthError = fail;
@@ -86971,7 +87094,7 @@ ${data2.flowchartText}
86971
87094
  });
86972
87095
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
86973
87096
  OnesEditorToolbar.register(editor);
86974
- editor.version = "2.2.0-beta.1";
87097
+ editor.version = "2.2.0-beta.3";
86975
87098
  return editor;
86976
87099
  }
86977
87100
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.2.0-beta.1",
3
+ "version": "2.2.0-beta.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",