@ones-editor/editor 2.2.2 → 2.2.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
@@ -36,7 +36,7 @@
36
36
  div.editor-root {
37
37
  --text-color: #303030;
38
38
  --primary-color: #0064ff;
39
- --background-selection: #0064ff1A;
39
+ --background-selection: #0064ff1a;
40
40
  --background-code: #cdcdcd40;
41
41
  }
42
42
  div.editor-root {
@@ -175,7 +175,8 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
175
175
  /* border: 1px solid #BCBEC0; */
176
176
  background-color: var(--background-code);
177
177
  padding: 4px;
178
- font: 0.8em Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
178
+ font-size: 0.8em;
179
+ font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
179
180
  }
180
181
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.text.style-sub, div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.inputting-insertion.style-sub {
181
182
  vertical-align: sub;
@@ -360,7 +361,7 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
360
361
  border-left: 4px solid #d4d6d9;
361
362
  color: #87888a;
362
363
  }
363
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level]) {
364
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level], [block-padding-level]) {
364
365
  padding-left: 8px;
365
366
  }
366
367
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="1"] {
@@ -2682,6 +2683,7 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
2682
2683
  color: var(--color-0);
2683
2684
  }
2684
2685
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] img.mathjax {
2686
+ flex-shrink: 0;
2685
2687
  -webkit-touch-callout: none;
2686
2688
  }
2687
2689
  div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] img.mathjax {
@@ -26388,6 +26390,10 @@ var __publicField = (obj, key, value) => {
26388
26390
  const firstBlock = getFirstChildBlock(nextContainer);
26389
26391
  return firstBlock;
26390
26392
  }
26393
+ const targetBlock = isFindPrev(type) ? getPrevBlock(parentComplexBlock) : getNextBlock(parentComplexBlock);
26394
+ if (targetBlock) {
26395
+ return targetBlock;
26396
+ }
26391
26397
  return findNextBlockInComplexBlock(editor, parentComplexBlock, type);
26392
26398
  }
26393
26399
  function findNextOrPrevOfParentBlock(editor, block, type) {
@@ -30569,6 +30575,11 @@ ${codeText}
30569
30575
  if (!value) {
30570
30576
  delete attributes[key];
30571
30577
  } else {
30578
+ const scriptKeys = ["style-sub", "style-super"];
30579
+ if (scriptKeys.includes(key)) {
30580
+ const [another] = scriptKeys.filter((keys) => keys !== key);
30581
+ delete attributes[another];
30582
+ }
30572
30583
  attributes[key] = value;
30573
30584
  }
30574
30585
  });
@@ -38878,7 +38889,7 @@ ${codeText}
38878
38889
  const TreeIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M8.80894 1.37566L9.19382 1.05649V1.05649L8.80894 1.37566ZM7.26945 1.37566L6.88457 1.05649V1.05649L7.26945 1.37566ZM12.7147 6.08541L13.0996 5.76623V5.76623L12.7147 6.08541ZM11.4874 7.72375V7.22375H10.1891L11.152 8.09459L11.4874 7.72375ZM14.159 10.1399L14.4944 9.76908L14.159 10.1399ZM10.0508 11.8816V11.3816H9.55085V11.8816H10.0508ZM10.0508 15V15.5H10.5508V15H10.0508ZM6.02806 15H5.52806V15.5H6.02806V15ZM6.02806 11.8816H6.52806V11.3816H6.02806V11.8816ZM1.91945 10.1399L2.25483 10.5108H2.25483L1.91945 10.1399ZM4.59108 7.72375L4.92646 8.09459L5.88936 7.22375H4.59108V7.72375ZM3.36368 6.0854L3.74855 6.40458L3.36368 6.0854ZM9.19382 1.05649C8.59399 0.333182 7.48441 0.333182 6.88457 1.05649L7.65432 1.69483C7.85427 1.45373 8.22413 1.45373 8.42407 1.69483L9.19382 1.05649ZM13.0996 5.76623L9.19382 1.05649L8.42407 1.69483L12.3298 6.40458L13.0996 5.76623ZM11.945 8.22375C13.215 8.22375 13.9103 6.74387 13.0996 5.76623L12.3298 6.40458C12.6001 6.73046 12.3683 7.22375 11.945 7.22375V8.22375ZM11.4874 8.22375H11.945V7.22375H11.4874V8.22375ZM14.4944 9.76908L11.8227 7.35292L11.152 8.09459L13.8236 10.5108L14.4944 9.76908ZM13.4882 12.3816C14.8612 12.3816 15.5126 10.69 14.4944 9.76908L13.8236 10.5108C14.163 10.8177 13.9459 11.3816 13.4882 11.3816V12.3816ZM10.0508 12.3816H13.4882V11.3816H10.0508V12.3816ZM9.55085 11.8816V15H10.5508V11.8816H9.55085ZM10.0508 14.5H6.02806V15.5H10.0508V14.5ZM6.52806 15V11.8816H5.52806V15H6.52806ZM2.59021 12.3816H6.02806V11.3816H2.59021V12.3816ZM1.58407 9.76909C0.565789 10.69 1.21726 12.3816 2.59021 12.3816V11.3816C2.13256 11.3816 1.9154 10.8177 2.25483 10.5108L1.58407 9.76909ZM4.2557 7.35292L1.58407 9.76909L2.25483 10.5108L4.92646 8.09459L4.2557 7.35292ZM4.13343 8.22375H4.59108V7.22375H4.13343V8.22375ZM2.97881 5.76623C2.16805 6.74387 2.86334 8.22375 4.13343 8.22375V7.22375C3.71007 7.22375 3.4783 6.73046 3.74855 6.40458L2.97881 5.76623ZM6.88457 1.05649L2.97881 5.76623L3.74855 6.40458L7.65432 1.69483L6.88457 1.05649Z" fill="currentColor"/>\n</svg>\n';
38879
38890
  const TimeIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 8C1.5 4.41023 4.41023 1.5 8 1.5C11.5898 1.5 14.5 4.41023 14.5 8C14.5 11.5898 11.5898 14.5 8 14.5C4.41023 14.5 1.5 11.5898 1.5 8ZM8 0.5C3.85794 0.5 0.5 3.85794 0.5 8C0.5 12.1421 3.85794 15.5 8 15.5C12.1421 15.5 15.5 12.1421 15.5 8C15.5 3.85794 12.1421 0.5 8 0.5ZM7.5 3V8V8.5H8H12V7.5H8.5V3H7.5Z" fill="currentColor"/>\n</svg>\n';
38880
38891
  const SearchIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M10.8597 11.4183L14.0962 14.8891M12.5 7.5C12.5 10.5376 10.0376 13 7 13C3.96243 13 1.5 10.5376 1.5 7.5C1.5 4.46243 3.96243 2 7 2C10.0376 2 12.5 4.46243 12.5 7.5Z" stroke="#87888A" stroke-width="2"/>\n</svg>\n';
38881
- const TextGroupIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2.49984 9.5L7.00009 9.5" stroke="#2D2D2E"/>\n<path d="M15.0001 13.5V6.5" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M15.0001 10C15.0001 11.3807 13.8808 12.5 12.5001 12.5C11.1194 12.5 10.0001 11.3807 10.0001 10C10.0001 8.61929 11.1194 7.5 12.5001 7.5C13.8808 7.5 15.0001 8.61929 15.0001 10Z" stroke="#2D2D2E"/>\n<path d="M1.00009 13.5L4.99984 2.5L8.50009 13.5" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
38892
+ const TextGroupIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2.49984 9.5L7.00009 9.5" stroke="currentColor"/>\n<path d="M15.0001 13.5V6.5" stroke="currentColor" stroke-linejoin="round"/>\n<path d="M15.0001 10C15.0001 11.3807 13.8808 12.5 12.5001 12.5C11.1194 12.5 10.0001 11.3807 10.0001 10C10.0001 8.61929 11.1194 7.5 12.5001 7.5C13.8808 7.5 15.0001 8.61929 15.0001 10Z" stroke="currentColor"/>\n<path d="M1.00009 13.5L4.99984 2.5L8.50009 13.5" stroke="currentColor" stroke-linejoin="round"/>\n</svg>\n';
38882
38893
  const TabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M14 2L2 2" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 6H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 10.5V5.5L5.5 8L2 10.5Z" fill="#2D2D2E"/>\n<path d="M14 10H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 14H2" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
38883
38894
  const ShiftTabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 2H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M7 6H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M5.5 10.5V5.5L2 8L5.5 10.5Z" fill="#2D2D2E"/>\n<path d="M7 10H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 14H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
38884
38895
  const TableEditIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M8 14.5H2.5C1.94772 14.5 1.5 14.0523 1.5 13.5V2.5C1.5 1.94772 1.94772 1.5 2.5 1.5H13.5C14.0523 1.5 14.5 1.94772 14.5 2.5V8" stroke="#2D2D2E"/>\n<path d="M1.6 4.8H14.4" stroke="#2D2D2E"/>\n<path d="M1.6 9.6H8.00078" stroke="#2D2D2E"/>\n<path d="M5.6 1.6L5.6 14.4" stroke="#2D2D2E"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5043 8.98727L11.6789 8.22924C11.7097 8.09564 11.8387 8 11.9881 8H12.8119C12.9613 8 13.0903 8.09564 13.1211 8.22924L13.2957 8.98727C13.3177 9.08256 13.3912 9.16027 13.488 9.20102C13.569 9.23514 13.648 9.2726 13.7248 9.31318C13.8018 9.35372 13.877 9.3976 13.95 9.44477C14.037 9.50098 14.1474 9.52034 14.2487 9.49008L15.0543 9.24927C15.1963 9.20683 15.3514 9.26108 15.4261 9.37933L15.9576 10.2206C16.0323 10.3389 16.0062 10.4888 15.895 10.5799L15.2639 11.0972C15.1846 11.1622 15.1477 11.2593 15.1575 11.3562C15.1657 11.4375 15.1698 11.5189 15.1697 11.6C15.1698 11.6811 15.1658 11.7625 15.1576 11.8438C15.1478 11.9407 15.1847 12.0378 15.264 12.1028L15.895 12.62C16.0062 12.7112 16.0324 12.8611 15.9577 12.9793L15.4262 13.8206C15.3515 13.9389 15.1963 13.9931 15.0544 13.9507L14.2487 13.7099C14.1474 13.6796 14.037 13.699 13.95 13.7552C13.877 13.8024 13.8018 13.8463 13.7248 13.8868C13.648 13.9274 13.569 13.9649 13.488 13.999C13.3912 14.0397 13.3177 14.1174 13.2957 14.2127L13.1211 14.9708C13.0903 15.1044 12.9613 15.2 12.8119 15.2H11.9881C11.8387 15.2 11.7097 15.1044 11.6789 14.9708L11.5043 14.2127C11.4823 14.1174 11.4088 14.0397 11.312 13.999C11.231 13.9649 11.152 13.9274 11.0752 13.8868C10.9982 13.8463 10.923 13.8024 10.85 13.7552C10.763 13.699 10.6526 13.6796 10.5513 13.7099L9.74565 13.9507C9.60366 13.9931 9.44854 13.9389 9.37384 13.8206L8.84234 12.9793C8.76764 12.8611 8.79378 12.7112 8.905 12.62L9.53602 12.1028C9.61534 12.0378 9.6522 11.9407 9.64243 11.8438C9.63424 11.7625 9.63023 11.6811 9.63031 11.6C9.63023 11.5189 9.63426 11.4375 9.64247 11.3562C9.65226 11.2593 9.61539 11.1622 9.53607 11.0972L8.90506 10.5799C8.79384 10.4888 8.7677 10.3389 8.8424 10.2206L9.3739 9.37933C9.4486 9.26108 9.60371 9.20683 9.74571 9.24927L10.5514 9.49008C10.6526 9.52034 10.7631 9.50098 10.8501 9.44477C10.923 9.3976 10.9982 9.35372 11.0752 9.31318C11.152 9.2726 11.231 9.23514 11.312 9.20102C11.4088 9.16027 11.4823 9.08256 11.5043 8.98727ZM12.3278 12.5136C12.8866 12.5136 13.3396 12.0996 13.3396 11.5889C13.3396 11.0783 12.8866 10.6643 12.3278 10.6643C11.769 10.6643 11.316 11.0783 11.316 11.5889C11.316 12.0996 11.769 12.5136 12.3278 12.5136Z" fill="#2D2D2E"/>\n</svg>\n';
@@ -48213,6 +48224,44 @@ ${codeText}
48213
48224
  "Shift+Tab": handleShiftTab$3,
48214
48225
  "Backspace": handleBackspace$2
48215
48226
  };
48227
+ function getListType(listData) {
48228
+ if (listData.textOnly) {
48229
+ return "text-only";
48230
+ }
48231
+ if (listData.checkbox) {
48232
+ return listData.checkbox;
48233
+ }
48234
+ if (listData.ordered) {
48235
+ return "ordered";
48236
+ }
48237
+ return "unordered";
48238
+ }
48239
+ function getListMarker(listData) {
48240
+ var _a, _b;
48241
+ if (listData.checkbox) {
48242
+ return "";
48243
+ }
48244
+ const level = (_a = listData.level) != null ? _a : 1;
48245
+ if (listData.ordered) {
48246
+ const num = getListNumber(level, (_b = listData.start) != null ? _b : 1);
48247
+ return `${num}.`;
48248
+ }
48249
+ return getListBullet(level);
48250
+ }
48251
+ function pickTextBlockData(listBlockData) {
48252
+ const textBlockData = {
48253
+ id: genId(),
48254
+ type: "text",
48255
+ text: listBlockData.text
48256
+ };
48257
+ const keys = ["heading", "quoted", "align"];
48258
+ for (const key of keys) {
48259
+ if (listBlockData[key] !== void 0) {
48260
+ textBlockData[key] = listBlockData[key];
48261
+ }
48262
+ }
48263
+ return textBlockData;
48264
+ }
48216
48265
  function findPreviousBrotherWithHeading(block, heading, level = 1) {
48217
48266
  if (!heading) {
48218
48267
  return null;
@@ -48309,7 +48358,9 @@ ${codeText}
48309
48358
  const fixStart = new FixStartByBlock(editor, srcBlock, { start: 1 });
48310
48359
  fixStart.fix();
48311
48360
  }
48361
+ const pickedTextBlock = pickTextBlockData(srcData);
48312
48362
  const blockData = {
48363
+ ...pickedTextBlock,
48313
48364
  id: genId(),
48314
48365
  type: "list",
48315
48366
  level,
@@ -48318,12 +48369,6 @@ ${codeText}
48318
48369
  ordered: false,
48319
48370
  text: text2
48320
48371
  };
48321
- if (srcData.quoted) {
48322
- blockData.quoted = true;
48323
- }
48324
- if (srcData.heading) {
48325
- blockData.heading = srcData.heading;
48326
- }
48327
48372
  if (type === "ordered") {
48328
48373
  blockData.ordered = true;
48329
48374
  } else if (type === "checked" || type === "unchecked") {
@@ -48337,30 +48382,6 @@ ${codeText}
48337
48382
  }
48338
48383
  };
48339
48384
  }
48340
- function getListType(listData) {
48341
- if (listData.textOnly) {
48342
- return "text-only";
48343
- }
48344
- if (listData.checkbox) {
48345
- return listData.checkbox;
48346
- }
48347
- if (listData.ordered) {
48348
- return "ordered";
48349
- }
48350
- return "unordered";
48351
- }
48352
- function getListMarker(listData) {
48353
- var _a, _b;
48354
- if (listData.checkbox) {
48355
- return "";
48356
- }
48357
- const level = (_a = listData.level) != null ? _a : 1;
48358
- if (listData.ordered) {
48359
- const num = getListNumber(level, (_b = listData.start) != null ? _b : 1);
48360
- return `${num}.`;
48361
- }
48362
- return getListBullet(level);
48363
- }
48364
48385
  function isCheck(type) {
48365
48386
  return type === "checked" || type === "unchecked";
48366
48387
  }
@@ -48511,17 +48532,7 @@ ${codeText}
48511
48532
  function convertListToTextBlock(editor, block) {
48512
48533
  ensureIsListBlock(block);
48513
48534
  const listBlockData = editor.getBlockData(block);
48514
- const textBlockData = {
48515
- id: genId(),
48516
- type: "text",
48517
- text: listBlockData.text
48518
- };
48519
- if (listBlockData.heading) {
48520
- textBlockData.heading = listBlockData.heading;
48521
- }
48522
- if (listBlockData.heading) {
48523
- textBlockData.heading = listBlockData.heading;
48524
- }
48535
+ const textBlockData = pickTextBlockData(listBlockData);
48525
48536
  const container = getParentContainer(block);
48526
48537
  const blockIndex = getBlockIndex(block);
48527
48538
  editor.deleteBlock(block);
@@ -49732,7 +49743,7 @@ ${codeText}
49732
49743
  __publicField(this, "onShow", () => {
49733
49744
  const scrollContainer = getScrollContainer$1(document.body);
49734
49745
  const clientHeight = scrollContainer.clientHeight;
49735
- this.linkPopup.content.style.maxHeight = `${clientHeight - 20}px`;
49746
+ this.linkPopup.content.style.height = `${clientHeight - 20}px`;
49736
49747
  this.emit("show");
49737
49748
  });
49738
49749
  __publicField(this, "close", () => {
@@ -50912,6 +50923,7 @@ ${codeText}
50912
50923
  class MathjaxStateData {
50913
50924
  constructor() {
50914
50925
  __publicField(this, "dataUrl", "");
50926
+ __publicField(this, "texWidth", null);
50915
50927
  __publicField(this, "error", null);
50916
50928
  }
50917
50929
  destroy() {
@@ -50924,6 +50936,9 @@ ${codeText}
50924
50936
  this.dataUrl = "";
50925
50937
  this.error = error2;
50926
50938
  }
50939
+ setTexWidth(tex, width) {
50940
+ this.texWidth = [tex, width];
50941
+ }
50927
50942
  }
50928
50943
  const logger$1R = getLogger("mathjax-converter");
50929
50944
  const MATHJAX_SCRIPT_ID = "MathJax-script";
@@ -51222,6 +51237,20 @@ ${codeText}
51222
51237
  }
51223
51238
  }
51224
51239
  });
51240
+ const [tex, width] = state.texWidth || [];
51241
+ if (tex === mathData.tex && width) {
51242
+ img.style.width = `${width}px`;
51243
+ } else {
51244
+ mathjax2Svg(editor, mathData.tex).then((svg) => {
51245
+ const { width: width2 } = analyzeMathjaxSvgWidth(svg);
51246
+ state.setTexWidth(mathData.tex, width2);
51247
+ const boxElement2 = editor.findBoxById(mathData.id);
51248
+ const imgElement = boxElement2 == null ? void 0 : boxElement2.querySelector("img");
51249
+ if (imgElement) {
51250
+ imgElement.style.width = `${width2}px`;
51251
+ }
51252
+ });
51253
+ }
51225
51254
  editor.domEvents.addEventListener(img, "load", updateCaret);
51226
51255
  return;
51227
51256
  }
@@ -79808,14 +79837,14 @@ ${content}
79808
79837
  this.providers.push(new InsertMenuProvider(editor));
79809
79838
  }
79810
79839
  get whiteList() {
79811
- const list2 = ["insert-image", "insert-table", "insert-link", "insert-hr"];
79840
+ let list2 = ["insert-image", "insert-table", "insert-link", "insert-hr"];
79812
79841
  const focusBlock = this.editor.selection.focusedBlock;
79813
79842
  if (!isRootBlock(focusBlock)) {
79814
- return list2.filter((id) => id !== "insert-table");
79843
+ list2 = list2.filter((id) => id !== "insert-table");
79815
79844
  }
79816
79845
  const o = this.editor.getComponentOptions("mobile");
79817
79846
  if (o == null ? void 0 : o.isAndroidApp) {
79818
- return list2.filter((id) => id !== "insert-image");
79847
+ list2 = list2.filter((id) => id !== "insert-image");
79819
79848
  }
79820
79849
  return list2;
79821
79850
  }
@@ -86873,7 +86902,7 @@ ${data2.flowchartText}
86873
86902
  }
86874
86903
  }
86875
86904
  });
86876
- editor.version = "2.2.2";
86905
+ editor.version = "2.2.3";
86877
86906
  if (Logger$2.level === LogLevel.DEBUG) {
86878
86907
  window.setReauthFail = (fail) => {
86879
86908
  window.isReauthError = fail;
@@ -86974,7 +87003,7 @@ ${data2.flowchartText}
86974
87003
  });
86975
87004
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
86976
87005
  OnesEditorToolbar.register(editor);
86977
- editor.version = "2.2.2";
87006
+ editor.version = "2.2.3";
86978
87007
  return editor;
86979
87008
  }
86980
87009
  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.2",
3
+ "version": "2.2.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",