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

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.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { OnesEditor, DocObject, OnesEditorDoc } from '../@ones-editor/core';
2
2
  import * as OnesEditorIcons from '../@ones-editor/ui-base/src/icons';
3
3
  import { OnesEditorVersionsDialog, VersionDialogOptions } from '../@ones-editor/versions';
4
+ import { isLayoutBlock } from '../@ones-editor/layout-block';
4
5
  import ShareDBDocVersionsProvider from './versions/versions-provider';
5
6
  import { CreateLocalEditorOptions, CreateOnesEditorOptions } from './types';
6
7
  import './lang';
@@ -28,7 +29,7 @@ export { resetListStart, getListAllNextBrothers, toMindmap, Mindmap } from '../@
28
29
  export * from '../@ones-editor/exclusive-block';
29
30
  export * from '../@ones-editor/templates';
30
31
  export * from 'tiny-typed-emitter';
31
- export { ShareDBDocVersionsProvider, OnesEditorIcons };
32
+ export { ShareDBDocVersionsProvider, OnesEditorIcons, isLayoutBlock };
32
33
  export type { FileBoxData, FileEmbedData } from '../@ones-editor/file';
33
34
  export { type DocListBlock } from '../@ones-editor/list-block';
34
35
  export declare function createOnesEditor(root: HTMLElement, options: CreateOnesEditorOptions): Promise<OnesEditor>;
package/dist/index.js CHANGED
@@ -49878,9 +49878,6 @@ ${codeText}
49878
49878
  if (this.toolbarType === "object" && ((_a = this.toolbar.subBar) == null ? void 0 : _a.isVisible)) {
49879
49879
  return;
49880
49880
  }
49881
- if (this.hoveringBlock === block && this.hoveringTextChild === child) {
49882
- return;
49883
- }
49884
49881
  this.hoveringBlock = block;
49885
49882
  this.hoveringTextChild = child;
49886
49883
  if (this.toolbarType === "text" && this.toolbar.isVisible) {
@@ -50539,7 +50536,16 @@ ${codeText}
50539
50536
  function handleClickBox$3(editor, box, event) {
50540
50537
  const parentBlock = getParentBlock(box);
50541
50538
  assert(logger$1Q, parentBlock, "failed to get block");
50542
- if (editor.readonly || !editor.isBlockWritable(parentBlock)) {
50539
+ if (!editor.isBlockWritable(parentBlock)) {
50540
+ return;
50541
+ }
50542
+ if (editor.readonly) {
50543
+ const block = getParentBlock(box);
50544
+ if (!block) {
50545
+ return;
50546
+ }
50547
+ const offset = getChildOffset(block, box);
50548
+ editor.selection.selectBlock(block, offset.start, offset.end);
50543
50549
  return;
50544
50550
  }
50545
50551
  editMathjaxBox(editor, box);
@@ -64473,12 +64479,27 @@ ${codeText}
64473
64479
  icon: CommentIcon$1
64474
64480
  }
64475
64481
  ]);
64482
+ __publicField(this, "isHoveringImageEmpty", () => {
64483
+ const ele = OnesEditorHoveringBlock.get(this.editor).hoveringElem;
64484
+ if (isImageBlock(this.block)) {
64485
+ const images = getImageContainersByBlock(this.block);
64486
+ if (images.length === 1) {
64487
+ if (ele && !(ele instanceof HTMLImageElement)) {
64488
+ return true;
64489
+ }
64490
+ }
64491
+ }
64492
+ return false;
64493
+ });
64476
64494
  this.editor = editor;
64477
64495
  this.block = block;
64478
64496
  this.editor = editor;
64479
64497
  this.block = block;
64480
64498
  }
64481
64499
  get commands() {
64500
+ if (this.isHoveringImageEmpty()) {
64501
+ return [];
64502
+ }
64482
64503
  if (this.editor.readonly) {
64483
64504
  return this._commands.filter((item) => item.id === "download");
64484
64505
  }
@@ -82084,7 +82105,7 @@ ${data2.flowchartText}
82084
82105
  }
82085
82106
  const AudioEmbed = new Audio();
82086
82107
  getLogger("video-resizer");
82087
- function isVideoBlock(block) {
82108
+ function isVideoBlock$1(block) {
82088
82109
  return block && isEmbedBlock(block) && getEmbedType(block) === "video";
82089
82110
  }
82090
82111
  const MIN_WIDTH = 50;
@@ -82099,10 +82120,10 @@ ${data2.flowchartText}
82099
82120
  if (window.isDragging) {
82100
82121
  return;
82101
82122
  }
82102
- if (oldBlock && isVideoBlock(oldBlock)) {
82123
+ if (oldBlock && isVideoBlock$1(oldBlock)) {
82103
82124
  this.disableBlockResize(oldBlock);
82104
82125
  }
82105
- if (newBlock && isVideoBlock(newBlock) && this.editor.isBlockWritable(newBlock)) {
82126
+ if (newBlock && isVideoBlock$1(newBlock) && this.editor.isBlockWritable(newBlock)) {
82106
82127
  const resizableElement = this.getVideoElement(newBlock);
82107
82128
  if (!resizableElement) {
82108
82129
  return;
@@ -82174,6 +82195,7 @@ ${data2.flowchartText}
82174
82195
  this.currentResizableElement = resizableElement;
82175
82196
  }
82176
82197
  }
82198
+ const isVideoBlock = (block) => getBlockType(block) === "embed" && getEmbedType(block) === "video";
82177
82199
  class ImageHoveringToolbarCommands {
82178
82200
  constructor(editor, block) {
82179
82201
  __publicField(this, "group", "hovering-toolbar");
@@ -82204,12 +82226,24 @@ ${data2.flowchartText}
82204
82226
  icon: AlignRightIcon
82205
82227
  }
82206
82228
  ]);
82229
+ __publicField(this, "isHoveringImageEmpty", () => {
82230
+ const ele = OnesEditorHoveringBlock.get(this.editor).hoveringElem;
82231
+ if (isVideoBlock(this.block)) {
82232
+ if (ele && !(ele instanceof HTMLVideoElement)) {
82233
+ return true;
82234
+ }
82235
+ }
82236
+ return false;
82237
+ });
82207
82238
  this.editor = editor;
82208
82239
  this.block = block;
82209
82240
  this.editor = editor;
82210
82241
  this.block = block;
82211
82242
  }
82212
82243
  get commands() {
82244
+ if (this.isHoveringImageEmpty()) {
82245
+ return [];
82246
+ }
82213
82247
  if (this.editor.readonly)
82214
82248
  return [];
82215
82249
  const currentAlign = this.block.getAttribute("data-style-align");
@@ -84844,7 +84878,7 @@ ${data2.flowchartText}
84844
84878
  }
84845
84879
  }
84846
84880
  });
84847
- editor.version = "2.1.1-beta.13";
84881
+ editor.version = "2.1.1-beta.15";
84848
84882
  if (Logger$2.level === LogLevel.DEBUG) {
84849
84883
  window.setReauthFail = (fail) => {
84850
84884
  window.isReauthError = fail;
@@ -84941,7 +84975,7 @@ ${data2.flowchartText}
84941
84975
  });
84942
84976
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
84943
84977
  OnesEditorToolbar.register(editor);
84944
- editor.version = "2.1.1-beta.13";
84978
+ editor.version = "2.1.1-beta.15";
84945
84979
  return editor;
84946
84980
  }
84947
84981
  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.13",
3
+ "version": "2.1.1-beta.15",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",