@ones-editor/editor 2.8.36 → 2.8.37-beta.1

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.
@@ -3,13 +3,13 @@ import { TypedEmitter } from 'tiny-typed-emitter';
3
3
  import type { GetReferenceClientRect, Placement } from 'tippy.js';
4
4
  export { Placement };
5
5
  export interface CommandBarEvents {
6
- 'show': (bar: AbstractCommandBar) => void;
7
- 'shown': (bar: AbstractCommandBar) => void;
8
- 'click': (bar: AbstractCommandBar, item: CommandItem, elem: HTMLElement) => void;
9
- 'close': (bar: AbstractCommandBar) => void;
10
- 'selectionChange': (bar: AbstractCommandBar, id: string) => void;
11
- 'closing': (bar: AbstractCommandBar, event: MouseEvent | TouchEvent) => boolean | undefined;
12
- 'subBarShown': (bar: AbstractCommandBar, subBar: AbstractCommandBar) => void;
6
+ show: (bar: AbstractCommandBar) => void;
7
+ shown: (bar: AbstractCommandBar) => void;
8
+ click: (bar: AbstractCommandBar, item: CommandItem, elem: HTMLElement) => void;
9
+ close: (bar: AbstractCommandBar) => void;
10
+ selectionChange: (bar: AbstractCommandBar, id: string) => void;
11
+ closing: (bar: AbstractCommandBar, event: MouseEvent | TouchEvent) => boolean | undefined;
12
+ subBarShown: (bar: AbstractCommandBar, subBar: AbstractCommandBar) => void;
13
13
  }
14
14
  export interface ManualShowCommandBarOptions {
15
15
  placement?: Placement;
@@ -50,6 +50,7 @@ export type CommandBarContentElement = HTMLElement & {
50
50
  __neverUse: 'CommandBarContentElement';
51
51
  };
52
52
  export interface CommandBarOptions {
53
+ rootId?: string;
53
54
  id?: string;
54
55
  parentItem?: CommandItem;
55
56
  itemElementTag?: keyof HTMLElementTagNameMap;
package/dist/index.js CHANGED
@@ -8875,6 +8875,35 @@ div.editor-root.compact.no-heading-collapse.no-block-menu > .editor-content {
8875
8875
  }
8876
8876
  [data-command-bar-id=main-toolbar-more-menu] .editor-command-bar.toolbar .command-item.hidden, [data-command-bar-id=main-toolbar-more-menu] .editor-command-bar.menu .command-item.hidden {
8877
8877
  display: flex;
8878
+ }
8879
+ .editor-main-toolbar-root {
8880
+ display: flex;
8881
+ width: 100%;
8882
+ height: 100%;
8883
+ }
8884
+ .editor-main-toolbar-root .editor-main-toolbar-resizer {
8885
+ position: relative;
8886
+ flex-grow: 1;
8887
+ flex-shrink: 1;
8888
+ }
8889
+ .editor-main-toolbar-root .editor-main-toolbar-resizer .editor-main-toolbar-container {
8890
+ position: absolute;
8891
+ left: 0;
8892
+ right: 0;
8893
+ top: 0;
8894
+ bottom: 0;
8895
+ display: flex;
8896
+ align-items: center;
8897
+ }
8898
+ .editor-main-toolbar-root .editor-main-toolbar-resizer .editor-main-toolbar-container .editor-command-bar-root {
8899
+ overflow: hidden !important;
8900
+ }
8901
+ .editor-main-toolbar-root [data-command-bar-root-id=main-toolbar-fullscreen] {
8902
+ flex-grow: 0 !important;
8903
+ flex-shrink: 0 !important;
8904
+ display: flex;
8905
+ align-items: center;
8906
+ justify-content: center;
8878
8907
  }`)),document.head.appendChild(t)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
8879
8908
  var __defProp = Object.defineProperty;
8880
8909
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -41754,6 +41783,9 @@ ${codeText}
41754
41783
  }
41755
41784
  const content = createElement("div", ["editor-command-bar-root"], null);
41756
41785
  content.setAttribute("data-keep-editor-focus", "");
41786
+ if (this.options.rootId) {
41787
+ content.setAttribute("data-command-bar-root-id", this.options.rootId);
41788
+ }
41757
41789
  if (this.options.header) {
41758
41790
  const headerElem = createElement("div", ["editor-command-bar-header"], null);
41759
41791
  if (this.options.header instanceof Function) {
@@ -54814,7 +54846,7 @@ ${codeText}
54814
54846
  const svg = await mathjax2Svg(editor, tex);
54815
54847
  const data2 = svg;
54816
54848
  const file2 = new File([data2], "math.svg");
54817
- const path = await editor.doc.uploadResource(file2);
54849
+ const path = await editor.doc.uploadResource(file2, { resourceType: "graph" });
54818
54850
  return path.resourceId;
54819
54851
  }
54820
54852
  async function convertAndUploadMathjaxForEmbed(editor, tex) {
@@ -54822,7 +54854,7 @@ ${codeText}
54822
54854
  const perfectState = analyzeMathjaxSvgWidth(svg);
54823
54855
  const data2 = svg;
54824
54856
  const file2 = new File([data2], "math.svg");
54825
- const path = await editor.doc.uploadResource(file2);
54857
+ const path = await editor.doc.uploadResource(file2, { resourceType: "graph" });
54826
54858
  return {
54827
54859
  resourceId: path.resourceId,
54828
54860
  ...perfectState
@@ -64826,7 +64858,8 @@ $$${mathData.mathjaxText}$$
64826
64858
  const res = await this.editor.doc.uploadResource(file2, {
64827
64859
  onProgress: (progress) => {
64828
64860
  setImageUploading(imageContainer, progress);
64829
- }
64861
+ },
64862
+ resourceType: "image"
64830
64863
  });
64831
64864
  removeClass(imageContainer, "uploading");
64832
64865
  this.images[index2].src = res.resourceId;
@@ -68803,7 +68836,7 @@ ${codeText}
68803
68836
  }
68804
68837
  const fileName = `image.${ext}`;
68805
68838
  const file2 = new File([blob], fileName, { type: mimeString });
68806
- const ret = await editor.doc.uploadResource(file2);
68839
+ const ret = await editor.doc.uploadResource(file2, { resourceType: "paste" });
68807
68840
  return ret.resourceId;
68808
68841
  }
68809
68842
  return src;
@@ -85902,7 +85935,7 @@ ${docStr}
85902
85935
  const file2 = new File([buffer], `${genId()}.svg`, {
85903
85936
  type: "image/svg+xml"
85904
85937
  });
85905
- const ret = await editor.doc.uploadResource(file2);
85938
+ const ret = await editor.doc.uploadResource(file2, { resourceType: "graph" });
85906
85939
  return ret.resourceId;
85907
85940
  }
85908
85941
  const _MermaidInstance = class extends GraphBase {
@@ -86140,7 +86173,7 @@ ${data2.mermaidText}
86140
86173
  const file2 = new File([buffer], `${genId()}.svg`, {
86141
86174
  type: "image/svg+xml"
86142
86175
  });
86143
- const resource = await editor.doc.uploadResource(file2);
86176
+ const resource = await editor.doc.uploadResource(file2, { resourceType: "graph" });
86144
86177
  return resource.resourceId;
86145
86178
  }
86146
86179
  const _FlowChartInstance = class extends GraphBase {
@@ -86595,7 +86628,7 @@ ${data2.flowchartText}
86595
86628
  });
86596
86629
  const targetBlock = editor.findBlockById(getBlockId(block));
86597
86630
  if (targetBlock) {
86598
- const res = await editor.doc.uploadResource(file2);
86631
+ const res = await editor.doc.uploadResource(file2, { resourceType: "graph" });
86599
86632
  const { resourceId } = res;
86600
86633
  const oldData = editor.getBlockData(targetBlock);
86601
86634
  const oldEmbedData = oldData.embedData;
@@ -86647,31 +86680,40 @@ ${data2.flowchartText}
86647
86680
  const xml = drawIoData.xmlSvg || drawIoData.xml || "";
86648
86681
  switch (msg.event) {
86649
86682
  case "configure":
86650
- iframe.contentWindow.postMessage(JSON.stringify({
86651
- action: "configure",
86652
- config: {
86653
- defaultFonts: ["Humor Sans", "Helvetica", "Times New Roman"]
86654
- }
86655
- }), "*");
86683
+ iframe.contentWindow.postMessage(
86684
+ JSON.stringify({
86685
+ action: "configure",
86686
+ config: {
86687
+ defaultFonts: ["Humor Sans", "Helvetica", "Times New Roman"]
86688
+ }
86689
+ }),
86690
+ "*"
86691
+ );
86656
86692
  break;
86657
86693
  case "init":
86658
- iframe.contentWindow.postMessage(JSON.stringify({
86659
- action: "load",
86660
- saveAndExit: 1,
86661
- noSaveBtn: 1,
86662
- noExitBtn: 0,
86663
- xml
86664
- }), "*");
86694
+ iframe.contentWindow.postMessage(
86695
+ JSON.stringify({
86696
+ action: "load",
86697
+ saveAndExit: 1,
86698
+ noSaveBtn: 1,
86699
+ noExitBtn: 0,
86700
+ xml
86701
+ }),
86702
+ "*"
86703
+ );
86665
86704
  loaded();
86666
86705
  loadingHandler.removeLoading();
86667
86706
  break;
86668
86707
  case "save":
86669
86708
  exportFlag = "save";
86670
- iframe.contentWindow.postMessage(JSON.stringify({
86671
- action: "export",
86672
- format: "xmlsvg",
86673
- spin: "Saving graph"
86674
- }), "*");
86709
+ iframe.contentWindow.postMessage(
86710
+ JSON.stringify({
86711
+ action: "export",
86712
+ format: "xmlsvg",
86713
+ spin: "Saving graph"
86714
+ }),
86715
+ "*"
86716
+ );
86675
86717
  break;
86676
86718
  case "export":
86677
86719
  if (exportFlag !== "auto") {
@@ -86697,12 +86739,15 @@ ${data2.flowchartText}
86697
86739
  allowRetry: true,
86698
86740
  onOk: () => {
86699
86741
  setTimeout(() => {
86700
- drawioIframeWindow.postMessage(JSON.stringify({
86701
- action: "export",
86702
- format: "xmlsvg",
86703
- spin: i18n$1.t("drawio.save"),
86704
- autoSave: exportFlag
86705
- }), "*");
86742
+ drawioIframeWindow.postMessage(
86743
+ JSON.stringify({
86744
+ action: "export",
86745
+ format: "xmlsvg",
86746
+ spin: i18n$1.t("drawio.save"),
86747
+ autoSave: exportFlag
86748
+ }),
86749
+ "*"
86750
+ );
86706
86751
  }, 1e3);
86707
86752
  },
86708
86753
  onClose: () => {
@@ -86768,12 +86813,15 @@ ${data2.flowchartText}
86768
86813
  if (!drawioIframe || !drawioIframe.contentWindow) {
86769
86814
  return;
86770
86815
  }
86771
- drawioIframe.contentWindow.postMessage(JSON.stringify({
86772
- action: "export",
86773
- format: "xmlsvg",
86774
- spin: "Saving graph",
86775
- autoSave: true
86776
- }), "*");
86816
+ drawioIframe.contentWindow.postMessage(
86817
+ JSON.stringify({
86818
+ action: "export",
86819
+ format: "xmlsvg",
86820
+ spin: "Saving graph",
86821
+ autoSave: true
86822
+ }),
86823
+ "*"
86824
+ );
86777
86825
  }, SAVE_DELAY_TIME);
86778
86826
  };
86779
86827
  const exit = () => {
@@ -86913,10 +86961,12 @@ ${data2.flowchartText}
86913
86961
  }
86914
86962
  function updateGraphByXml(mxFile, embed, editor) {
86915
86963
  assert(logger$i, editor, "parameter missing");
86916
- initDrawIo(editor).then(() => loopCheckResourceWasLoaded({
86917
- checker: () => !!(window.mxUtils && window.mxGraph && window.mxCodec),
86918
- maxRetryTime: 5e3
86919
- })).then(() => {
86964
+ initDrawIo(editor).then(
86965
+ () => loopCheckResourceWasLoaded({
86966
+ checker: () => !!(window.mxUtils && window.mxGraph && window.mxCodec),
86967
+ maxRetryTime: 5e3
86968
+ })
86969
+ ).then(() => {
86920
86970
  const { mxUtils, mxGraph: MxGraph, mxCodec: MxCodec, Graph } = window;
86921
86971
  assert(logger$i, mxUtils, "External resource loading exception: mxUtils");
86922
86972
  assert(logger$i, MxGraph, "External resource loading exception: MxGraph");
@@ -86936,7 +86986,10 @@ ${data2.flowchartText}
86936
86986
  const raw = atob(diagramBase64);
86937
86987
  const pako = window.pako;
86938
86988
  assert(logger$i, pako, "External resource loading exception: pako");
86939
- const encodedXml = pako.inflateRaw(Uint8Array.from(raw, (c) => c.charCodeAt(0)), { to: "string" });
86989
+ const encodedXml = pako.inflateRaw(
86990
+ Uint8Array.from(raw, (c) => c.charCodeAt(0)),
86991
+ { to: "string" }
86992
+ );
86940
86993
  const xml = decodeURIComponent(encodedXml);
86941
86994
  xmlDoc = mxUtils.parseXml(xml);
86942
86995
  } else {
@@ -87270,7 +87323,7 @@ ${data2.flowchartText}
87270
87323
  if (!plantumlImgFile) {
87271
87324
  return await Promise.resolve(url);
87272
87325
  }
87273
- const uploadResourceResult = await editor.doc.uploadResource(plantumlImgFile);
87326
+ const uploadResourceResult = await editor.doc.uploadResource(plantumlImgFile, { resourceType: "graph" });
87274
87327
  return uploadResourceResult.resourceId;
87275
87328
  } catch (error2) {
87276
87329
  return Promise.resolve(url);
@@ -90805,7 +90858,8 @@ ${data2.plantumlText}
90805
90858
  const { resourceId } = await editor.doc.uploadResource(file2, {
90806
90859
  onProgress: (progress) => {
90807
90860
  this.renderProgress(progress, file2);
90808
- }
90861
+ },
90862
+ resourceType: "media"
90809
90863
  });
90810
90864
  const { name, type, size } = file2;
90811
90865
  const newBlockData = {
@@ -90943,7 +90997,11 @@ ${data2.plantumlText}
90943
90997
  renderEmpty(blockData) {
90944
90998
  assert(logger$9, this.abstract, "no abstract");
90945
90999
  assert(logger$9, this.mediaContainer, "The media element not exist");
90946
- const empty = createElement("div", ["media-empty", "embed-selected-content", "embed-hover-content"], this.mediaContainer);
91000
+ const empty = createElement(
91001
+ "div",
91002
+ ["media-empty", "embed-selected-content", "embed-hover-content"],
91003
+ this.mediaContainer
91004
+ );
90947
91005
  empty.innerHTML = this.abstract.mediaIcon;
90948
91006
  this.updateMediaContent(empty);
90949
91007
  const { editor } = this.options;
@@ -90964,7 +91022,7 @@ ${data2.plantumlText}
90964
91022
  }
90965
91023
  await editor.doc.addResources([resourceId]);
90966
91024
  const serviceAppId = (_b = (_a = editor.doc).getServerMeta) == null ? void 0 : _b.call(_a).appId;
90967
- if (resourceUrl !== blockData.embedData.src && (serviceAppId && blockData.embedData.src.includes(serviceAppId))) {
91025
+ if (resourceUrl !== blockData.embedData.src && serviceAppId && blockData.embedData.src.includes(serviceAppId)) {
90968
91026
  const block = getParentBlock(content);
90969
91027
  if (block && !editor.readonly && editor.isBlockWritable(block)) {
90970
91028
  const newBlockData = cloneDeep__default.default(blockData);
@@ -94101,11 +94159,11 @@ ${JSON.stringify(error2, null, 2)}`);
94101
94159
  this.fixedToolbar = (_a = editor.findCustom("main-toolbar-fixed-toolbar")) == null ? void 0 : _a.toolbar;
94102
94160
  if (this.fixedToolbar) {
94103
94161
  const content = this.fixedToolbar.content;
94104
- const toolbar2 = content.closest(".editor-command-bar-root");
94162
+ const resizer = content.closest(".editor-main-toolbar-resizer");
94105
94163
  this.observer = new ResizeObserver(() => {
94106
94164
  this.updateItems();
94107
94165
  });
94108
- this.observer.observe(toolbar2);
94166
+ this.observer.observe(resizer);
94109
94167
  editor.addCustom("main-toolbar-more-item", () => this);
94110
94168
  }
94111
94169
  });
@@ -94223,8 +94281,6 @@ ${JSON.stringify(error2, null, 2)}`);
94223
94281
  new AlignCenterItem(),
94224
94282
  new AlignRightItem(),
94225
94283
  new SeparatorItem(),
94226
- new InsertImageItem(),
94227
- new SeparatorItem(),
94228
94284
  new InsertItem(editor),
94229
94285
  new SeparatorItem(),
94230
94286
  new FindReplaceItem(),
@@ -94296,8 +94352,9 @@ ${JSON.stringify(error2, null, 2)}`);
94296
94352
  });
94297
94353
  const style = "";
94298
94354
  class MainToolbar {
94299
- constructor(editor, parent) {
94355
+ constructor(editor, parent, options = {}) {
94300
94356
  __publicField(this, "toolbar");
94357
+ __publicField(this, "toolbarFullScreen");
94301
94358
  __publicField(this, "handleClick", (bar2, item) => {
94302
94359
  const command = item;
94303
94360
  if (command.onClick) {
@@ -94334,7 +94391,11 @@ ${JSON.stringify(error2, null, 2)}`);
94334
94391
  this.updateState();
94335
94392
  });
94336
94393
  this.editor = editor;
94337
- this.toolbar = new FixedToolbar(parent, this.getItems(), {
94394
+ this.options = options;
94395
+ const root2 = createElement("div", ["editor-main-toolbar-root"], parent);
94396
+ const container = createElement("div", ["editor-main-toolbar-resizer"], root2);
94397
+ const resizer = createElement("div", ["editor-main-toolbar-container"], container);
94398
+ this.toolbar = new FixedToolbar(resizer, this.getItems(), {
94338
94399
  tooltipId: editor.clientId,
94339
94400
  id: "main-toolbar"
94340
94401
  });
@@ -94346,9 +94407,31 @@ ${JSON.stringify(error2, null, 2)}`);
94346
94407
  destroy: () => {
94347
94408
  }
94348
94409
  }));
94410
+ if (options.enableFullScreen) {
94411
+ const fullScreenItem = {
94412
+ id: "main-toolbar-fullscreen",
94413
+ icon: FullScreenIcon,
94414
+ name: i18n$1.t("toolbar.fullscreen")
94415
+ };
94416
+ this.toolbarFullScreen = new FixedToolbar(root2, [fullScreenItem], {
94417
+ tooltipId: editor.clientId,
94418
+ id: "main-toolbar-fullscreen",
94419
+ rootId: "main-toolbar-fullscreen"
94420
+ });
94421
+ this.toolbarFullScreen.addListener("click", (bar2, item) => {
94422
+ var _a;
94423
+ if (item.id === "main-toolbar-fullscreen") {
94424
+ (_a = options.onFullScreenClick) == null ? void 0 : _a.call(options, this.editor, item);
94425
+ this.handleSelectionChanged();
94426
+ }
94427
+ });
94428
+ }
94349
94429
  }
94350
94430
  destroy() {
94431
+ var _a;
94351
94432
  this.toolbar.destroy();
94433
+ this.editor.removeListener("selectionChanged", this.handleSelectionChanged);
94434
+ (_a = this.toolbarFullScreen) == null ? void 0 : _a.destroy();
94352
94435
  }
94353
94436
  setItems(items) {
94354
94437
  this.toolbar.updateItems(items);
@@ -94641,7 +94724,7 @@ ${JSON.stringify(error2, null, 2)}`);
94641
94724
  }
94642
94725
  }
94643
94726
  });
94644
- editor.version = "2.8.36";
94727
+ editor.version = "2.8.37-beta.1";
94645
94728
  return editor;
94646
94729
  }
94647
94730
  function isDoc(doc2) {
@@ -94755,7 +94838,7 @@ ${JSON.stringify(error2, null, 2)}`);
94755
94838
  }
94756
94839
  });
94757
94840
  OnesEditorToolbar.register(editor);
94758
- editor.version = "2.8.36";
94841
+ editor.version = "2.8.37-beta.1";
94759
94842
  return editor;
94760
94843
  }
94761
94844
  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.8.36",
3
+ "version": "2.8.37-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {