@ones-editor/editor 2.1.1-beta.70 → 2.1.1-beta.72

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="lodash" />
2
1
  import { TypedEmitter } from 'tiny-typed-emitter';
3
2
  import { CloseReason, CommandItem, Closeable } from '../../../../@ones-editor/core';
4
3
  import { AbstractManualCommandBar, AbstractCommandBar, CommandBarEvents, CommandBarOptions, CommandItemElement, CreateManualCommandBarFunction, ManualShowCommandBarOptions, SelectItemFrom } from './types';
@@ -31,7 +30,8 @@ export default abstract class CommandBar extends TypedEmitter<CommandBarEvents>
31
30
  private getSelectedItemIndex;
32
31
  private getPrevItemIndex;
33
32
  private getNextItemIndex;
34
- protected clearSelectedItem: import("lodash").DebouncedFunc<() => void>;
33
+ protected clearSelectedItem(): void;
34
+ private debounceClearSelectedItem;
35
35
  selectItem(id: string, from?: SelectItemFrom): void;
36
36
  private lastEnterPauseTime;
37
37
  private startPauseMouseEnter;
package/dist/index.js CHANGED
@@ -148,6 +148,7 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
148
148
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.text.link:hover, div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.inputting-insertion.link:hover {
149
149
  cursor: pointer;
150
150
  color: #0053cf;
151
+ text-decoration: underline;
151
152
  }
152
153
  div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.text.link.style-strikethrough:hover, div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] > span.inputting-insertion.link.style-strikethrough:hover {
153
154
  text-decoration: underline line-through;
@@ -39112,16 +39113,7 @@ ${codeText}
39112
39113
  disablePageScroll(this.id);
39113
39114
  }
39114
39115
  });
39115
- __publicField(this, "clearSelectedItem", debounce__default.default(() => {
39116
- const item = this.getSelectedItem();
39117
- if (!item) {
39118
- return;
39119
- }
39120
- const elem = this.getItemElementById(item.id);
39121
- if (elem) {
39122
- removeClass(elem, "selected");
39123
- }
39124
- }, 200));
39116
+ __publicField(this, "debounceClearSelectedItem", debounce__default.default(this.clearSelectedItem, 200));
39125
39117
  __publicField(this, "lastEnterPauseTime", 0);
39126
39118
  __publicField(this, "startPauseMouseEnter", () => {
39127
39119
  this.lastEnterPauseTime = Date.now();
@@ -39182,7 +39174,7 @@ ${codeText}
39182
39174
  }
39183
39175
  if (clientType.isMobile) {
39184
39176
  this.selectItem(id);
39185
- this.clearSelectedItem();
39177
+ this.debounceClearSelectedItem();
39186
39178
  }
39187
39179
  if (item.children && item.children.length > 0 && item.manualShowChildren) {
39188
39180
  this.showSubCommandBar(item.childrenMenuId);
@@ -39353,6 +39345,16 @@ ${codeText}
39353
39345
  }
39354
39346
  }
39355
39347
  }
39348
+ clearSelectedItem() {
39349
+ const item = this.getSelectedItem();
39350
+ if (!item) {
39351
+ return;
39352
+ }
39353
+ const elem = this.getItemElementById(item.id);
39354
+ if (elem) {
39355
+ removeClass(elem, "selected");
39356
+ }
39357
+ }
39356
39358
  selectItem(id, from = "event") {
39357
39359
  const exists = this.getSelectedItem();
39358
39360
  if (exists) {
@@ -50738,6 +50740,7 @@ ${codeText}
50738
50740
  }
50739
50741
  const block = this.hoveringBlock;
50740
50742
  const child = this.hoveringTextChild;
50743
+ const isBoxChild = child && isTextBlockContentBoxChild(child);
50741
50744
  const { commands, element } = getObjectCommands(this.editor, block, child);
50742
50745
  if (!commands.length || !element) {
50743
50746
  this.toolbar.close("fromHover");
@@ -50762,7 +50765,7 @@ ${codeText}
50762
50765
  lineRects.push(y);
50763
50766
  });
50764
50767
  if (lineRects.length > 1) {
50765
- rect = child ? clientRects[clientRects.length - 1] : clientRects[0];
50768
+ rect = isBoxChild ? clientRects[clientRects.length - 1] : clientRects[0];
50766
50769
  if (event) {
50767
50770
  for (let i = 0; i < clientRects.length; i++) {
50768
50771
  const clientRect = clientRects[i];
@@ -50775,7 +50778,7 @@ ${codeText}
50775
50778
  }
50776
50779
  } else {
50777
50780
  rect = element.getBoundingClientRect();
50778
- if (child) {
50781
+ if (isBoxChild) {
50779
50782
  const childRect = child.getBoundingClientRect();
50780
50783
  return new DOMRect(childRect.x, childRect.y, childRect.width, childRect.height);
50781
50784
  }
@@ -61533,6 +61536,10 @@ $$${mathData.mathjaxText}$$
61533
61536
  return false;
61534
61537
  }
61535
61538
  filterCommands(editor, block, range, commands) {
61539
+ const { start, end } = editor.selection.range;
61540
+ if (start.blockId === end.blockId && isCodeBlock(block)) {
61541
+ return [];
61542
+ }
61536
61543
  if (isCodeTextBlock(editor, block)) {
61537
61544
  return [];
61538
61545
  }
@@ -65020,9 +65027,12 @@ ${codeText}
65020
65027
  });
65021
65028
  }
65022
65029
  const { enableComments = true } = this.editor.options;
65023
- if (!enableComments) {
65030
+ if (!enableComments || this.editor.readonly) {
65024
65031
  standardCommands = standardCommands.filter((command) => command.id !== "add-comment");
65025
65032
  }
65033
+ if (this.editor.readonly) {
65034
+ standardCommands = standardCommands.filter((command) => command.id !== "edit");
65035
+ }
65026
65036
  standardCommands.forEach((item) => {
65027
65037
  if (item.id === "add-comment" || item.id === "edit") {
65028
65038
  item.states = this.editor.isBlockWritable(this.block) ? [] : ["disabled"];
@@ -79804,15 +79814,15 @@ ${content}
79804
79814
  const commands = this.getCommands();
79805
79815
  this.toolbar.updateItems(commands);
79806
79816
  const focusBlock = this.editor.selection.focusedBlock;
79807
- const rect = getBlockCaretRect(this.editor, focusBlock, this.editor.selection.range.start);
79808
- const anchor2 = createBlockAnchor(this.editor, focusBlock, "editor-quick-menu", rect);
79817
+ const rect = getBlockCaretRect(this.editor, focusBlock, this.editor.selection.range.focus);
79818
+ const anchor2 = createBlockAnchor(this.editor, focusBlock, "editor-cursor-toolbar", rect);
79809
79819
  this.toolbar.manualShow(anchor2, {
79810
79820
  placement: "top",
79811
79821
  offset: [0, 14]
79812
79822
  });
79813
79823
  });
79814
79824
  __publicField(this, "close", () => {
79815
- this.toolbar.close("clickItem");
79825
+ this.toolbar.close("cancelBar");
79816
79826
  });
79817
79827
  this.editor = editor;
79818
79828
  this.toolbar = new ManualToolbar([], void 0, {
@@ -80123,6 +80133,14 @@ ${content}
80123
80133
  this.mobileToolbar.addListener("subBarShown", this.handleSubBarShow);
80124
80134
  this.mobileToolbar.addListener("click", this.handleClick);
80125
80135
  this.editor.addListener("selectionChanged", this.handleSelectionChange);
80136
+ setTimeout(() => {
80137
+ const container = this.bar.firstChild;
80138
+ if (container.scrollWidth > container.clientWidth) {
80139
+ container.classList.add("overflowing");
80140
+ } else {
80141
+ container.classList.remove("overflowing");
80142
+ }
80143
+ }, 500);
80126
80144
  }
80127
80145
  destroy() {
80128
80146
  this.editor.removeListener("selectionChanged", this.handleSelectionChange);
@@ -80154,9 +80172,8 @@ ${content}
80154
80172
  constructor(editor) {
80155
80173
  __publicField(this, "commandBar");
80156
80174
  __publicField(this, "observer");
80157
- __publicField(this, "showKeyboard", false);
80158
80175
  __publicField(this, "toggleDelay", clientType.isSafari ? 800 : 100);
80159
- __publicField(this, "toggle", debounce__default.default(() => {
80176
+ __publicField(this, "layoutBar", debounce__default.default(() => {
80160
80177
  const offsetHeight = Math.max(this.clientHeight - this.virtualViewportHeight, 0);
80161
80178
  this.commandBar.bar.style.bottom = `${offsetHeight}px`;
80162
80179
  }, this.toggleDelay));
@@ -80170,33 +80187,18 @@ ${content}
80170
80187
  }
80171
80188
  }, 100));
80172
80189
  __publicField(this, "handleFocusIn", () => {
80173
- if (!this.showKeyboard) {
80174
- this.showKeyboard = true;
80175
- }
80176
- this.toggle();
80190
+ this.layoutBar();
80177
80191
  });
80178
80192
  __publicField(this, "handleFocusOut", () => {
80179
- if (this.showKeyboard) {
80180
- this.showKeyboard = false;
80181
- }
80182
- this.toggle();
80193
+ this.layoutBar();
80183
80194
  });
80184
80195
  this.editor = editor;
80185
- createMobileBottomMenu();
80186
80196
  this.commandBar = new MobileToolbarHandler(editor, document.body);
80187
80197
  this.observer = new ActiveElementObserver({
80188
80198
  onFocused: this.handleFocusIn,
80189
80199
  onBlurred: this.handleFocusOut
80190
80200
  });
80191
- this.toggle();
80192
- setTimeout(() => {
80193
- const container = this.commandBar.bar.firstChild;
80194
- if (container.scrollWidth > container.clientWidth) {
80195
- container.classList.add("overflowing");
80196
- } else {
80197
- container.classList.remove("overflowing");
80198
- }
80199
- }, 500);
80201
+ this.layoutBar();
80200
80202
  this.editor.scrollContainer.addEventListener("scroll", this.handScroll);
80201
80203
  }
80202
80204
  get window() {
@@ -80366,6 +80368,7 @@ ${content}
80366
80368
  this.gripper = new SelectionGripper(this.editor);
80367
80369
  this.cursorToolbar = createCursorToolbar(this.editor);
80368
80370
  this.mobileEmbedMask = new MobileEmbedMask(this.editor);
80371
+ createMobileBottomMenu();
80369
80372
  }
80370
80373
  destroy() {
80371
80374
  this.editor.removeListener("selectionChanged", this.handleSelectionChange);
@@ -82228,8 +82231,8 @@ ${content}
82228
82231
  }
82229
82232
  function getBlockProperties$5(editor, block) {
82230
82233
  const properties = getStandardEmbedBlockProperties(editor, block, {
82231
- presetIds: editor.readonly ? [] : ["add-comment"],
82232
- extCommands: [{
82234
+ presetIds: ["add-comment"],
82235
+ extCommands: editor.readonly ? [] : [{
82233
82236
  id: "refresh",
82234
82237
  name: i18n$1.t("webpage.command.refresh"),
82235
82238
  icon: RefreshIcon
@@ -83043,8 +83046,8 @@ ${content}
83043
83046
  states: !drawioImg ? ["disabled"] : []
83044
83047
  }];
83045
83048
  },
83046
- presetIds: editor.readonly ? [] : ["edit"],
83047
- extIds: editor.readonly ? [] : ["separator", "add-comment"]
83049
+ presetIds: ["edit"],
83050
+ extIds: ["separator", "add-comment"]
83048
83051
  });
83049
83052
  return { ...properties, abstract: i18n$1.t("drawio.abstract") };
83050
83053
  }
@@ -83278,19 +83281,14 @@ ${content}
83278
83281
  plantuml: "https://plantuml.com/"
83279
83282
  };
83280
83283
  class GraphBlockCommands {
83281
- constructor(editor, graphType, properties) {
83282
- this.editor = editor;
83284
+ constructor(graphType, properties) {
83285
+ __publicField(this, "presetIds", ["edit"]);
83286
+ __publicField(this, "extIds", ["separator", "add-comment"]);
83283
83287
  this.graphType = graphType;
83284
83288
  this.properties = properties;
83285
83289
  }
83286
- get presetIds() {
83287
- return this.editor.readonly ? [] : ["edit"];
83288
- }
83289
- get extIds() {
83290
- return this.editor.readonly ? [] : ["separator", "add-comment"];
83291
- }
83292
83290
  extCommands(editor, block) {
83293
- const commands = [
83291
+ let commands = [
83294
83292
  {
83295
83293
  id: "help",
83296
83294
  name: i18n$1.t("graph.help"),
@@ -83306,6 +83304,9 @@ ${content}
83306
83304
  icon: DownloadIcon$1,
83307
83305
  states: !graphImgSrc ? ["disabled"] : []
83308
83306
  });
83307
+ if (editor.readonly) {
83308
+ commands = commands.filter((c) => c.id !== "help");
83309
+ }
83309
83310
  return commands;
83310
83311
  }
83311
83312
  handleExecuteCommand(editor, block, item) {
@@ -83328,7 +83329,7 @@ ${content}
83328
83329
  }
83329
83330
  }
83330
83331
  function getGraphEmbedBlockProperties(editor, block, type, properties) {
83331
- const standardProperties = getStandardEmbedBlockProperties(editor, block, new GraphBlockCommands(editor, type, properties));
83332
+ const standardProperties = getStandardEmbedBlockProperties(editor, block, new GraphBlockCommands(type, properties));
83332
83333
  return { ...standardProperties, abstract: lodash.exports.capitalize(type) };
83333
83334
  }
83334
83335
  class GraphBase {
@@ -86801,7 +86802,7 @@ ${data2.flowchartText}
86801
86802
  }
86802
86803
  }
86803
86804
  });
86804
- editor.version = "2.1.1-beta.70";
86805
+ editor.version = "2.1.1-beta.72";
86805
86806
  if (Logger$2.level === LogLevel.DEBUG) {
86806
86807
  window.setReauthFail = (fail) => {
86807
86808
  window.isReauthError = fail;
@@ -86902,7 +86903,7 @@ ${data2.flowchartText}
86902
86903
  });
86903
86904
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
86904
86905
  OnesEditorToolbar.register(editor);
86905
- editor.version = "2.1.1-beta.70";
86906
+ editor.version = "2.1.1-beta.72";
86906
86907
  return editor;
86907
86908
  }
86908
86909
  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.1.1-beta.70",
3
+ "version": "2.1.1-beta.72",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",