@ones-editor/editor 2.1.1-beta.11 → 2.1.1-beta.13

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
@@ -64301,17 +64301,43 @@ ${codeText}
64301
64301
  id: "add-comment",
64302
64302
  name: i18n$1.t("embedProperties.addComment"),
64303
64303
  icon: CommentIcon$1
64304
+ }, {
64305
+ id: "separator",
64306
+ name: "",
64307
+ type: "separator"
64304
64308
  }]);
64305
64309
  this.editor = editor;
64306
64310
  this.block = block;
64307
64311
  this.properties = properties;
64308
64312
  }
64309
64313
  get commands() {
64310
- var _a, _b, _c;
64314
+ var _a, _b, _c, _d;
64311
64315
  if (this.editor.readonly || clientType.isMobile) {
64312
64316
  return [];
64313
64317
  }
64314
- let standardCommands = this._commands;
64318
+ let standardCommands = [];
64319
+ if ((_a = this.properties) == null ? void 0 : _a.presetIds) {
64320
+ this.properties.presetIds.forEach((id) => {
64321
+ const command = this._commands.find((item) => item.id === id);
64322
+ if (command) {
64323
+ standardCommands.push(command);
64324
+ }
64325
+ });
64326
+ }
64327
+ if (((_b = this.properties) == null ? void 0 : _b.extCommands) && Array.isArray(this.properties.extCommands)) {
64328
+ standardCommands.push(...this.properties.extCommands);
64329
+ }
64330
+ if (((_c = this.properties) == null ? void 0 : _c.extCommands) instanceof Function) {
64331
+ standardCommands.push(...this.properties.extCommands(this.editor, this.block));
64332
+ }
64333
+ if ((_d = this.properties) == null ? void 0 : _d.extIds) {
64334
+ this.properties.extIds.forEach((id) => {
64335
+ const command = this._commands.find((item) => item.id === id);
64336
+ if (command) {
64337
+ standardCommands.push(command);
64338
+ }
64339
+ });
64340
+ }
64315
64341
  const { enableComments = true } = this.editor.options;
64316
64342
  if (!enableComments) {
64317
64343
  standardCommands = standardCommands.filter((command) => command.id !== "add-comment");
@@ -64321,24 +64347,7 @@ ${codeText}
64321
64347
  item.states = this.editor.isBlockWritable(this.block) ? [] : ["disabled"];
64322
64348
  }
64323
64349
  });
64324
- let commands = ((_a = this.properties) == null ? void 0 : _a.presetIds) ? standardCommands.filter((item) => {
64325
- var _a2, _b2;
64326
- return (_b2 = (_a2 = this.properties) == null ? void 0 : _a2.presetIds) == null ? void 0 : _b2.includes(item.id);
64327
- }) : [...standardCommands];
64328
- if ((_c = (_b = this.properties) == null ? void 0 : _b.extCommands) == null ? void 0 : _c.length) {
64329
- if (commands.length) {
64330
- commands.push({
64331
- id: genId(),
64332
- type: "separator",
64333
- name: ""
64334
- });
64335
- }
64336
- commands.push(...this.properties.extCommands);
64337
- }
64338
- if (commands.length <= 3) {
64339
- commands = commands.filter((command) => command.id !== "separator");
64340
- }
64341
- return commands;
64350
+ return standardCommands;
64342
64351
  }
64343
64352
  executeCommand(editor, block, item) {
64344
64353
  var _a, _b;
@@ -64469,16 +64478,6 @@ ${codeText}
64469
64478
  this.editor = editor;
64470
64479
  this.block = block;
64471
64480
  }
64472
- createIconItem(icon, active, parent) {
64473
- if (!icon)
64474
- return null;
64475
- const className = ["style-icon", "text-style-item"];
64476
- if (active) {
64477
- className.push("active");
64478
- }
64479
- const button2 = createIconButton(icon, className, parent);
64480
- return button2;
64481
- }
64482
64481
  get commands() {
64483
64482
  if (this.editor.readonly) {
64484
64483
  return this._commands.filter((item) => item.id === "download");
@@ -64486,14 +64485,9 @@ ${codeText}
64486
64485
  const currentAlign = this.block.getAttribute("data-style-align");
64487
64486
  const items = this._commands.map((item) => {
64488
64487
  if (item.id === currentAlign) {
64489
- return {
64490
- ...item,
64491
- element: () => {
64492
- const container = createElement("div", ["image-tooltip-align-style-section"], null);
64493
- this.createIconItem(item.icon, true, container);
64494
- return container;
64495
- }
64496
- };
64488
+ const states = item.states || [];
64489
+ states.push("checked");
64490
+ return { ...item, states };
64497
64491
  }
64498
64492
  return item;
64499
64493
  });
@@ -80488,77 +80482,40 @@ ${codeText}
80488
80482
  }
80489
80483
  addDrawioEmptyStatus(embed);
80490
80484
  }
80491
- class DrawIoBlockCommands extends StandardEmbedBlockCommands {
80492
- constructor(editor, block) {
80493
- super(editor, block, {
80494
- handleExecuteCommand(editor2, block2, item) {
80495
- if (item.id === "edit") {
80496
- const data2 = editor2.getBlockData(block2).embedData;
80497
- editGraph(editor2, block2, data2, false);
80498
- return true;
80499
- }
80500
- if (item.id === "download") {
80501
- const image = block2.querySelector(".editor-drawio-content img");
80502
- if (!(image instanceof HTMLImageElement))
80503
- return true;
80504
- downloadImageAsPng(image.src);
80485
+ function getBlockProperties$5(editor, block) {
80486
+ const properties = getStandardEmbedBlockProperties(editor, block, {
80487
+ handleExecuteCommand: (editor2, block2, item) => {
80488
+ if (item.id === "edit") {
80489
+ const data2 = editor2.getBlockData(block2).embedData;
80490
+ editGraph(editor2, block2, data2, false);
80491
+ return true;
80492
+ }
80493
+ if (item.id === "download") {
80494
+ const image = block2.querySelector(".editor-drawio-content img");
80495
+ if (!(image instanceof HTMLImageElement))
80505
80496
  return true;
80506
- }
80507
- return false;
80497
+ downloadImageAsPng(image.src);
80498
+ return true;
80508
80499
  }
80509
- });
80510
- __publicField(this, "group", "hovering-toolbar");
80511
- __publicField(this, "_commands", [
80512
- {
80513
- id: "edit",
80514
- name: i18n$1.t("graph.edit"),
80515
- icon: EditIcon
80516
- },
80517
- {
80500
+ return false;
80501
+ },
80502
+ extCommands: (editor2, block2) => {
80503
+ if (editor2.readonly) {
80504
+ return [];
80505
+ }
80506
+ const blockContent = getBlockContent(block2);
80507
+ const drawioImg = blockContent.querySelector(".editor-drawio-content img");
80508
+ return [{
80518
80509
  id: "download",
80519
80510
  name: i18n$1.t("common.downloadAsImage"),
80520
- icon: DownloadIcon$1
80521
- },
80522
- {
80523
- id: "separator",
80524
- type: "separator",
80525
- name: ""
80526
- },
80527
- {
80528
- id: "add-comment",
80529
- name: i18n$1.t("graph.comment"),
80530
- icon: CommentIcon$1
80531
- }
80532
- ]);
80533
- this.editor = editor;
80534
- this.block = block;
80535
- }
80536
- get commands() {
80537
- let commands;
80538
- if (this.editor.readonly) {
80539
- commands = this._commands.filter((command) => command.id === "download");
80540
- } else {
80541
- commands = super.commands;
80542
- }
80543
- const blockContent = getBlockContent(this.block);
80544
- const drawioImg = blockContent.querySelector(".editor-drawio-content img");
80545
- if (!drawioImg) {
80546
- commands.forEach((command) => {
80547
- if (command.id === "download") {
80548
- command.states = ["disabled"];
80549
- }
80550
- });
80551
- }
80552
- return commands;
80553
- }
80554
- }
80555
- function getBlockProperties$5(editor, block) {
80556
- return {
80557
- blockCommands: {
80558
- "hovering-toolbar": new DrawIoBlockCommands(editor, block)
80511
+ icon: DownloadIcon$1,
80512
+ states: !drawioImg ? ["disabled"] : []
80513
+ }];
80559
80514
  },
80560
- abstract: i18n$1.t("drawio.abstract")
80561
- };
80515
+ presetIds: ["edit"],
80516
+ extIds: ["separator", "add-comment"]
80517
+ });
80518
+ return { ...properties, abstract: i18n$1.t("drawio.abstract") };
80562
80519
  }
80563
80520
  const enUS$5 = {
80564
80521
  drawio: {
@@ -80787,80 +80744,57 @@ ${codeText}
80787
80744
  flowchart: "https://flowchart.js.org/",
80788
80745
  plantuml: "https://plantuml.com/"
80789
80746
  };
80790
- class GraphBlockCommands extends StandardEmbedBlockCommands {
80791
- constructor(editor, block, graphType, properties) {
80792
- super(editor, block, properties);
80793
- __publicField(this, "group", "hovering-toolbar");
80794
- __publicField(this, "_commands", [
80795
- {
80796
- id: "edit",
80797
- name: i18n$1.t("graph.edit"),
80798
- icon: EditIcon
80799
- },
80800
- {
80801
- id: "download",
80802
- name: i18n$1.t("common.downloadAsImage"),
80803
- icon: DownloadIcon$1
80804
- },
80747
+ class GraphBlockCommands {
80748
+ constructor(graphType, properties) {
80749
+ __publicField(this, "presetIds", ["edit"]);
80750
+ __publicField(this, "extIds", ["separator", "add-comment"]);
80751
+ this.graphType = graphType;
80752
+ this.properties = properties;
80753
+ }
80754
+ extCommands(editor, block) {
80755
+ const commands = [
80805
80756
  {
80806
80757
  id: "help",
80807
80758
  name: i18n$1.t("graph.help"),
80808
80759
  icon: HelpIcon
80809
- },
80810
- {
80811
- id: "separator",
80812
- type: "separator",
80813
- name: ""
80814
- },
80815
- {
80816
- id: "add-comment",
80817
- name: i18n$1.t("graph.comment"),
80818
- icon: CommentIcon$1
80819
80760
  }
80820
- ]);
80821
- this.editor = editor;
80822
- this.block = block;
80823
- this.graphType = graphType;
80824
- this.properties = properties;
80825
- }
80826
- get commands() {
80827
- let commands;
80828
- if (this.editor.readonly) {
80829
- commands = this._commands.filter((command) => command.id === "download");
80830
- } else {
80831
- commands = super.commands;
80761
+ ];
80762
+ if (editor.readonly) {
80763
+ return commands;
80832
80764
  }
80833
- const blockContent = getBlockContent(this.block);
80765
+ const blockContent = getBlockContent(block);
80834
80766
  const graphImg = blockContent.querySelector("img.graph-embed-image");
80835
80767
  const graphImgSrc = graphImg == null ? void 0 : graphImg.src;
80836
- if (!graphImgSrc) {
80837
- commands.forEach((command) => {
80838
- if (command.id === "download") {
80839
- command.states = ["disabled"];
80840
- }
80841
- });
80842
- }
80768
+ commands.unshift({
80769
+ id: "download",
80770
+ name: i18n$1.t("common.downloadAsImage"),
80771
+ icon: DownloadIcon$1,
80772
+ states: !graphImgSrc ? ["disabled"] : []
80773
+ });
80843
80774
  return commands;
80844
80775
  }
80845
- executeCommand(editor, block, item) {
80776
+ handleExecuteCommand(editor, block, item) {
80846
80777
  var _a, _b;
80847
80778
  if ((_b = (_a = this.properties) == null ? void 0 : _a.handleExecuteCommand) == null ? void 0 : _b.call(_a, editor, block, item)) {
80848
- return;
80779
+ return true;
80849
80780
  }
80850
- if (item.id === "edit")
80851
- ;
80852
- else if (item.id === "help") {
80781
+ if (item.id === "help") {
80853
80782
  window.open(GraphDocumentUrl[this.graphType]);
80783
+ return true;
80854
80784
  }
80785
+ if (item.id === "download") {
80786
+ const graphImage = block.querySelector("img.graph-embed-image");
80787
+ if (!(graphImage instanceof HTMLImageElement))
80788
+ return true;
80789
+ downloadImageAsPng(graphImage.src);
80790
+ return true;
80791
+ }
80792
+ return false;
80855
80793
  }
80856
80794
  }
80857
80795
  function getGraphEmbedBlockProperties(editor, block, type, properties) {
80858
- return {
80859
- blockCommands: {
80860
- "hovering-toolbar": new GraphBlockCommands(editor, block, type, properties)
80861
- },
80862
- abstract: lodash.exports.capitalize(type)
80863
- };
80796
+ const standardProperties = getStandardEmbedBlockProperties(editor, block, new GraphBlockCommands(type, properties));
80797
+ return { ...standardProperties, abstract: lodash.exports.capitalize(type) };
80864
80798
  }
80865
80799
  class GraphBase {
80866
80800
  constructor(editor, graphType, codeEmbedDataKey) {
@@ -81095,20 +81029,6 @@ ${codeText}
81095
81029
  this.editGraph(content);
81096
81030
  return true;
81097
81031
  }
81098
- if (item.id === "add-comment") {
81099
- if (editor.readonly) {
81100
- return true;
81101
- }
81102
- addCommentToBlock(editor, block2);
81103
- return true;
81104
- }
81105
- if (item.id === "download") {
81106
- const graphImage = block2.querySelector("img.graph-embed-image");
81107
- if (!(graphImage instanceof HTMLImageElement))
81108
- return true;
81109
- downloadImageAsPng(graphImage.src);
81110
- return true;
81111
- }
81112
81032
  return false;
81113
81033
  }
81114
81034
  });
@@ -82289,30 +82209,15 @@ ${data2.flowchartText}
82289
82209
  this.editor = editor;
82290
82210
  this.block = block;
82291
82211
  }
82292
- createIconItem(icon, active, parent) {
82293
- if (!icon)
82294
- return null;
82295
- const className = ["style-icon", "text-style-item"];
82296
- if (active) {
82297
- className.push("active");
82298
- }
82299
- const button2 = createIconButton(icon, className, parent);
82300
- return button2;
82301
- }
82302
82212
  get commands() {
82303
82213
  if (this.editor.readonly)
82304
82214
  return [];
82305
82215
  const currentAlign = this.block.getAttribute("data-style-align");
82306
82216
  const items = this._commands.map((item) => {
82307
82217
  if (item.id === currentAlign) {
82308
- return {
82309
- ...item,
82310
- element: () => {
82311
- const container = createElement("div", ["video-tooltip-align-style-section"], null);
82312
- this.createIconItem(item.icon, true, container);
82313
- return container;
82314
- }
82315
- };
82218
+ const states = item.states || [];
82219
+ states.push("checked");
82220
+ return { ...item, states };
82316
82221
  }
82317
82222
  return item;
82318
82223
  });
@@ -84939,7 +84844,7 @@ ${data2.flowchartText}
84939
84844
  }
84940
84845
  }
84941
84846
  });
84942
- editor.version = "2.1.1-beta.11";
84847
+ editor.version = "2.1.1-beta.13";
84943
84848
  if (Logger$2.level === LogLevel.DEBUG) {
84944
84849
  window.setReauthFail = (fail) => {
84945
84850
  window.isReauthError = fail;
@@ -85036,7 +84941,7 @@ ${data2.flowchartText}
85036
84941
  });
85037
84942
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
85038
84943
  OnesEditorToolbar.register(editor);
85039
- editor.version = "2.1.1-beta.11";
84944
+ editor.version = "2.1.1-beta.13";
85040
84945
  return editor;
85041
84946
  }
85042
84947
  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.11",
3
+ "version": "2.1.1-beta.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",