@worktile/theia 2.3.0-next.1 → 2.3.0

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.
Files changed (36) hide show
  1. package/bundles/worktile-theia.umd.js +144 -471
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/constants/default.d.ts +0 -2
  4. package/editor.component.d.ts +0 -2
  5. package/editor.module.d.ts +24 -26
  6. package/esm2015/constants/default.js +1 -2
  7. package/esm2015/editor.component.js +17 -14
  8. package/esm2015/editor.module.js +3 -6
  9. package/esm2015/interfaces/editor.js +1 -1
  10. package/esm2015/plugins/align/align.editor.js +6 -2
  11. package/esm2015/plugins/image/image.component.js +13 -8
  12. package/esm2015/utils/dom.js +5 -3
  13. package/esm2015/utils/index.js +3 -1
  14. package/fesm2015/worktile-theia.js +137 -462
  15. package/fesm2015/worktile-theia.js.map +1 -1
  16. package/interfaces/editor.d.ts +1 -6
  17. package/package.json +1 -1
  18. package/plugins/image/image.component.scss +0 -7
  19. package/plugins/table/components/table.component.scss +2 -2
  20. package/styles/editor.scss +160 -133
  21. package/styles/index.scss +1 -2
  22. package/styles/typo.scss +12 -1
  23. package/utils/index.d.ts +2 -0
  24. package/esm2015/plugins/dnd/component/dnd.component.js +0 -254
  25. package/esm2015/plugins/dnd/utils/get-current-target.js +0 -19
  26. package/esm2015/plugins/dnd/utils/get-hover-direction.js +0 -13
  27. package/esm2015/plugins/dnd/utils/is-valid-drag.js +0 -38
  28. package/esm2015/plugins/dnd/utils/move-drag-node.js +0 -30
  29. package/esm2015/plugins/dnd/utils/remove-drop-thumb-line.js +0 -10
  30. package/plugins/dnd/component/dnd.component.d.ts +0 -42
  31. package/plugins/dnd/component/dnd.component.scss +0 -60
  32. package/plugins/dnd/utils/get-current-target.d.ts +0 -2
  33. package/plugins/dnd/utils/get-hover-direction.d.ts +0 -3
  34. package/plugins/dnd/utils/is-valid-drag.d.ts +0 -3
  35. package/plugins/dnd/utils/move-drag-node.d.ts +0 -2
  36. package/plugins/dnd/utils/remove-drop-thumb-line.d.ts +0 -2
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Component, ChangeDetectionStrategy, HostBinding, Input, HostListener, ViewContainerRef, ChangeDetectorRef, Injectable, Inject, ViewChild, Directive, ElementRef, TemplateRef, EventEmitter, Output, Pipe, forwardRef, NgModule } from '@angular/core';
2
+ import { InjectionToken, Component, ChangeDetectionStrategy, HostBinding, Input, HostListener, ViewContainerRef, ChangeDetectorRef, Injectable, Inject, ViewChild, Directive, ElementRef, TemplateRef, Pipe, EventEmitter, forwardRef, Output, NgModule } from '@angular/core';
3
3
  import * as i10 from '@angular/common';
4
4
  import { DOCUMENT, CommonModule } from '@angular/common';
5
5
  import * as i4$1 from '@angular/forms';
6
6
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
7
7
  import * as i1 from 'slate-angular';
8
- import { BaseTextComponent, BaseElementComponent, AngularEditor, NODE_TO_PARENT, NODE_TO_INDEX, IS_SAFARI, hotkeys, getPlainText as getPlainText$1, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, ELEMENT_TO_COMPONENT, EDITOR_TO_ELEMENT, isComponentType, withAngular, SlateModule } from 'slate-angular';
8
+ import { BaseTextComponent, BaseElementComponent, AngularEditor, NODE_TO_PARENT, NODE_TO_INDEX, EDITOR_TO_ELEMENT, IS_SAFARI, hotkeys, getPlainText as getPlainText$1, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, ELEMENT_TO_COMPONENT, isComponentType, withAngular, SlateModule } from 'slate-angular';
9
9
  import { mixinUnsubscribe, MixinBase } from 'ngx-tethys/core';
10
10
  import isHotkey, { isKeyHotkey } from 'is-hotkey';
11
11
  import { Element as Element$1, Editor, Range, Node, Span, Path, Text, Point, Transforms, Operation, createEditor } from 'slate';
@@ -69,7 +69,6 @@ const CLIPBOARD_FORMAT_KEY = 'x-theia-fragment';
69
69
  const DEFAULT_SCROLL_CONTAINER = '.the-editable-container';
70
70
  const ELEMENT_UNIQUE_ID = 'key';
71
71
  const ZERO_WIDTH_CHAR = '\u200B';
72
- const DROP_THUMB_LINE = 'drop-thumb-line';
73
72
  var TheMode;
74
73
  (function (TheMode) {
75
74
  TheMode["fullMode"] = "full";
@@ -2152,6 +2151,110 @@ const isCleanEmptyParagraph = (editor) => {
2152
2151
  return false;
2153
2152
  };
2154
2153
 
2154
+ const mergeElementOptions = (elementOptions) => {
2155
+ elementOptions = elementOptions.filter(item => item.inValidChildrenTypes.length > 0);
2156
+ const combinationData = [...DefaultElementOptions, ...elementOptions];
2157
+ const dataInfo = {};
2158
+ combinationData.forEach(item => {
2159
+ const { type, inValidChildrenTypes, isIndivisible, isSecondaryContainer } = item;
2160
+ if (!dataInfo[type]) {
2161
+ dataInfo[type] = {
2162
+ type,
2163
+ inValidChildrenTypes,
2164
+ isIndivisible,
2165
+ isSecondaryContainer
2166
+ };
2167
+ }
2168
+ dataInfo[type].inValidChildrenTypes = Array.from(new Set([...inValidChildrenTypes, ...dataInfo[type].inValidChildrenTypes]));
2169
+ });
2170
+ return dataInfo;
2171
+ };
2172
+
2173
+ /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
2174
+ function coercePixelsFromCssValue(cssValue) {
2175
+ const match = cssValue.match(/(\d+(\.\d+)?)px/);
2176
+ if (match) {
2177
+ return Number(match[1]);
2178
+ }
2179
+ }
2180
+ function getElementWidth(element) {
2181
+ // Optimization: Check style.width first as we probably set it already before reading
2182
+ // offsetWidth which triggers layout.
2183
+ return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
2184
+ }
2185
+ function getElementHeight(element) {
2186
+ return Math.round(element.getBoundingClientRect().height);
2187
+ }
2188
+ function getColsTotalWidth(cols) {
2189
+ return cols.reduce((total, col) => {
2190
+ return total + getElementWidth(col);
2191
+ }, 0);
2192
+ }
2193
+ function getRowsTotalHeight(rows) {
2194
+ return rows.reduce((total, row) => {
2195
+ return total + getElementHeight(row);
2196
+ }, 0);
2197
+ }
2198
+ function useElementStyle(el, element) {
2199
+ if (element.align) {
2200
+ el.style.textAlign = element.align || Alignment.left;
2201
+ }
2202
+ if (element.textIndent) {
2203
+ el.style.textIndent = element.textIndent + 'em';
2204
+ }
2205
+ if (element.verticalAlign) {
2206
+ el.style.verticalAlign = element.verticalAlign;
2207
+ }
2208
+ }
2209
+ function getElementClassByPrefix(el, prefix) {
2210
+ let matchClass = null;
2211
+ el.classList.forEach((value, key) => {
2212
+ if (value.includes(prefix)) {
2213
+ matchClass = value;
2214
+ }
2215
+ });
2216
+ return matchClass;
2217
+ }
2218
+ function findRelativeElementByPoint(editor, x, y, mode) {
2219
+ const editableElement = EDITOR_TO_ELEMENT.get(editor);
2220
+ const rectEditable = editableElement.getBoundingClientRect();
2221
+ if (x > rectEditable.x && x < rectEditable.x + rectEditable.width) {
2222
+ let { paddingLeft } = window.getComputedStyle(editableElement, null);
2223
+ const paddingLeftPixels = coercePixelsFromCssValue(paddingLeft);
2224
+ const startX = rectEditable.left + paddingLeftPixels;
2225
+ let relativeElement = document.elementFromPoint(mode === 'highest' ? startX : x, y);
2226
+ return relativeElement;
2227
+ }
2228
+ return null;
2229
+ }
2230
+ function findNodeEntryByPoint(editor, x, y, mode) {
2231
+ const editableElement = EDITOR_TO_ELEMENT.get(editor);
2232
+ let rootElement = null;
2233
+ let relativeElement = findRelativeElementByPoint(editor, x, y, mode);
2234
+ // 获取最顶层的DOM
2235
+ if (mode === 'highest') {
2236
+ while (relativeElement && editableElement.contains(relativeElement)) {
2237
+ relativeElement = relativeElement.closest('[data-slate-node="element"]');
2238
+ if (relativeElement) {
2239
+ rootElement = relativeElement;
2240
+ relativeElement = relativeElement.parentElement;
2241
+ }
2242
+ }
2243
+ }
2244
+ if (!mode) {
2245
+ if (relativeElement && editableElement.contains(relativeElement)) {
2246
+ relativeElement = relativeElement.closest('[data-slate-node="element"]');
2247
+ rootElement = relativeElement;
2248
+ }
2249
+ }
2250
+ if (rootElement) {
2251
+ const node = AngularEditor.toSlateNode(editor, rootElement);
2252
+ const path = AngularEditor.findPath(editor, node);
2253
+ return [node, path];
2254
+ }
2255
+ return null;
2256
+ }
2257
+
2155
2258
  const withDeserializeMd = (options) => (editor) => {
2156
2259
  const { insertData, onKeydown } = editor;
2157
2260
  editor.onKeydown = (event) => {
@@ -2256,25 +2359,6 @@ const isMarkdownStynx = content => {
2256
2359
  return regexps.some(regexp => regexp.test(content));
2257
2360
  };
2258
2361
 
2259
- const mergeElementOptions = (elementOptions) => {
2260
- elementOptions = elementOptions.filter(item => item.inValidChildrenTypes.length > 0);
2261
- const combinationData = [...DefaultElementOptions, ...elementOptions];
2262
- const dataInfo = {};
2263
- combinationData.forEach(item => {
2264
- const { type, inValidChildrenTypes, isIndivisible, isSecondaryContainer } = item;
2265
- if (!dataInfo[type]) {
2266
- dataInfo[type] = {
2267
- type,
2268
- inValidChildrenTypes,
2269
- isIndivisible,
2270
- isSecondaryContainer
2271
- };
2272
- }
2273
- dataInfo[type].inValidChildrenTypes = Array.from(new Set([...inValidChildrenTypes, ...dataInfo[type].inValidChildrenTypes]));
2274
- });
2275
- return dataInfo;
2276
- };
2277
-
2278
2362
  const withAutoInsertData = (validChildren) => (editor) => {
2279
2363
  const { insertData } = editor;
2280
2364
  let allElementOptions = DefaultElementOptions;
@@ -2606,13 +2690,13 @@ class TheImageComponent extends TheBaseElementComponent {
2606
2690
  {
2607
2691
  key: LayoutTypes.wrapLeft,
2608
2692
  icon: 'wrap-left',
2609
- name: '隐藏左边',
2693
+ name: '图片居左',
2610
2694
  handle: (e, key) => this.setImageNode(e, { layout: key })
2611
2695
  },
2612
2696
  {
2613
2697
  key: LayoutTypes.wrapRight,
2614
2698
  icon: 'wrap-right',
2615
- name: '隐藏右边',
2699
+ name: '图片居右',
2616
2700
  handle: (e, key) => this.setImageNode(e, { layout: key })
2617
2701
  },
2618
2702
  {
@@ -2808,7 +2892,8 @@ class TheImageComponent extends TheBaseElementComponent {
2808
2892
  $event.stopPropagation();
2809
2893
  }
2810
2894
  isShouldOpen() {
2811
- return !(this === null || this === void 0 ? void 0 : this.readonly) && (this === null || this === void 0 ? void 0 : this.isCollapsed) && !this.uploading && !this.isOpen;
2895
+ const { theOptions: { richMedia } } = this.theContextService.getOptions();
2896
+ return !(this === null || this === void 0 ? void 0 : this.readonly) && richMedia && (this === null || this === void 0 ? void 0 : this.isCollapsed) && !this.uploading && !this.isOpen;
2812
2897
  }
2813
2898
  isShouldClose() {
2814
2899
  return this.isOpen && ((this === null || this === void 0 ? void 0 : this.readonly) || !(this === null || this === void 0 ? void 0 : this.isCollapsed) || this.uploading);
@@ -2817,16 +2902,20 @@ class TheImageComponent extends TheBaseElementComponent {
2817
2902
  var _a;
2818
2903
  this.layoutToolbarRef = this.thyPopover.open(this.layoutToolbar, {
2819
2904
  origin: this.imageContent,
2820
- panelClass: ['the-image-toolbar'],
2905
+ panelClass: ['the-block-toolbar'],
2821
2906
  placement: 'bottom',
2822
2907
  insideClosable: false,
2823
2908
  backdropClosable: true,
2824
2909
  hasBackdrop: false,
2825
- offset: 60,
2910
+ offset: 10,
2826
2911
  viewContainerRef: this.viewContainerRef,
2827
2912
  scrollStrategy: this.overlay.scrollStrategies.reposition()
2828
2913
  });
2829
2914
  (_a = this.layoutToolbarRef) === null || _a === void 0 ? void 0 : _a.getOverlayRef().updatePositionStrategy(this.createPositionStrategy());
2915
+ setTimeout(() => {
2916
+ var _a;
2917
+ (_a = this.layoutToolbarRef) === null || _a === void 0 ? void 0 : _a.getOverlayRef().updatePosition();
2918
+ }, 150);
2830
2919
  }
2831
2920
  closeLayoutToolbar() {
2832
2921
  var _a;
@@ -2867,7 +2956,7 @@ class TheImageComponent extends TheBaseElementComponent {
2867
2956
  overlayX: 'center',
2868
2957
  overlayY: 'top',
2869
2958
  offsetX: 0,
2870
- offsetY: 60
2959
+ offsetY: 10
2871
2960
  };
2872
2961
  return this.overlay
2873
2962
  .position()
@@ -2879,7 +2968,7 @@ class TheImageComponent extends TheBaseElementComponent {
2879
2968
  }
2880
2969
  }
2881
2970
  TheImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheImageComponent, deps: [{ token: i0.ElementRef }, { token: i1$2.DomSanitizer }, { token: THE_UPLOAD_SERVICE_TOKEN }, { token: i0.ChangeDetectorRef }, { token: TheContextService }, { token: i1$3.ThyPopover }, { token: i2.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
2882
- TheImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheImageComponent, selector: "the-image, [theImage]", viewQueries: [{ propertyName: "imageContent", first: true, predicate: ["imageContent"], descendants: true }, { propertyName: "img", first: true, predicate: ["img"], descendants: true }, { propertyName: "layoutToolbar", first: true, predicate: ["layoutToolbar"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n\n<div class=\"image-container\" contenteditable=\"false\" [style.textAlign]=\"imageEntry.align\">\n <div\n #imageContent\n *ngIf=\"imageEntry.thumbUrl\"\n class=\"image-content\"\n [class.pointer]=\"!selection\"\n [ngStyle]=\"{\n 'width.px':\n imageEntry?.layout && imageEntry?.width > layoutDefaultWidth && !imageEntry?.reSized\n ? layoutDefaultWidth\n : imageEntry.width,\n 'height.px': imageEntry.height\n }\"\n >\n <img #img class=\"main-image\" [src]=\"imageEntry.thumbUrl\" [alt]=\"imageEntry.name\" />\n <div *ngIf=\"selection\" class=\"image-profile\" [class.outline]=\"selection\">\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left top\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right top\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right bottom\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left bottom\"></span>\n </div>\n <div *ngIf=\"uploading\" class=\"uploading\">\n <div class=\"uploading-percentage\">\n <thy-progress thyType=\"primary\" [thyValue]=\"percentage\" thySize=\"sm\"></thy-progress>\n <thy-icon (click)=\"cancelUpload($event)\" thyIconName=\"close-circle-bold-fill\" thyIconLegging=\"true\"></thy-icon>\n </div>\n </div>\n <div *ngIf=\"!uploading\" class=\"layer\" (mousedown)=\"preview($event)\" [class.readonly]=\"readonly\"></div>\n </div>\n <div *ngIf=\"!imageEntry.thumbUrl\" class=\"image-loading\" contenteditable=\"false\">\n <thy-icon thyIconName=\"image\"></thy-icon>\n </div>\n</div>\n\n<ng-template #layoutToolbar>\n <div class=\"the-block-operate\" contenteditable=\"false\">\n <thy-icon-nav>\n <ng-container *ngFor=\"let item of layoutOptions\">\n <a\n *ngIf=\"item.key !== 'split'\"\n href=\"javascript:;\"\n thyIconNavLink\n [ngClass]=\"{ 'remove-link': item.key === 'remove' }\"\n [thyIconNavLinkIcon]=\"item.icon\"\n [thyTooltip]=\"item.name\"\n [thyIconNavLinkActive]=\"layoutActive(item.key)\"\n thyTooltipPlacement=\"top\"\n (mousedown)=\"item?.handle($event, item.key)\"\n ></a>\n <nav-split-line *ngIf=\"item.key === 'split'\"></nav-split-line>\n </ng-container>\n </thy-icon-nav>\n </div>\n</ng-template>\n", components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { type: i6.ThyProgressComponent, selector: "thy-progress", inputs: ["thyType", "thySize", "thyValue", "thyMax", "thyTips"] }, { type: i4.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { type: i3.ThyIconNavComponent, selector: "thy-icon-nav", inputs: ["thyType"] }, { type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i10.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }] });
2971
+ TheImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheImageComponent, selector: "the-image, [theImage]", viewQueries: [{ propertyName: "imageContent", first: true, predicate: ["imageContent"], descendants: true }, { propertyName: "img", first: true, predicate: ["img"], descendants: true }, { propertyName: "layoutToolbar", first: true, predicate: ["layoutToolbar"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n\n<div class=\"image-container\" contenteditable=\"false\" [style.textAlign]=\"imageEntry.align\">\n <div\n #imageContent\n *ngIf=\"imageEntry.thumbUrl\"\n class=\"image-content\"\n [class.pointer]=\"!selection\"\n [ngStyle]=\"{\n 'width.px':\n imageEntry?.layout && imageEntry?.width > layoutDefaultWidth && !imageEntry?.reSized\n ? layoutDefaultWidth\n : imageEntry.width,\n 'height.px': imageEntry.height\n }\"\n >\n <img #img class=\"main-image\" [src]=\"imageEntry.thumbUrl\" [alt]=\"imageEntry.name\" />\n <div *ngIf=\"selection\" class=\"image-profile\" [class.outline]=\"selection\">\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left top\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right top\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, 'xl')\" class=\"image-pointer right bottom\"></span>\n <span *ngIf=\"isCollapsed\" (mousedown)=\"startDrag($event, '-xl')\" class=\"image-pointer left bottom\"></span>\n </div>\n <div *ngIf=\"uploading\" class=\"uploading\">\n <div class=\"uploading-percentage\">\n <thy-progress thyType=\"primary\" [thyValue]=\"percentage\" thySize=\"sm\"></thy-progress>\n <thy-icon (click)=\"cancelUpload($event)\" thyIconName=\"close-circle-bold-fill\" thyIconLegging=\"true\"></thy-icon>\n </div>\n </div>\n <div *ngIf=\"!uploading\" class=\"layer\" (mousedown)=\"preview($event)\" [class.readonly]=\"readonly\"></div>\n </div>\n <div *ngIf=\"!imageEntry.thumbUrl\" class=\"image-loading\" contenteditable=\"false\">\n <thy-icon thyIconName=\"image\"></thy-icon>\n </div>\n</div>\n\n<ng-template #layoutToolbar>\n <div class=\"the-block-toolbar-popover\" contenteditable=\"false\">\n <thy-icon-nav>\n <ng-container *ngFor=\"let item of layoutOptions\">\n <a\n *ngIf=\"item.key !== 'split'\"\n href=\"javascript:;\"\n thyIconNavLink\n [ngClass]=\"{ 'remove-link': item.key === 'remove' }\"\n [thyIconNavLinkIcon]=\"item.icon\"\n [thyTooltip]=\"item.name\"\n [thyIconNavLinkActive]=\"layoutActive(item.key)\"\n thyTooltipPlacement=\"top\"\n (mousedown)=\"item?.handle($event, item.key)\"\n ></a>\n <nav-split-line *ngIf=\"item.key === 'split'\"></nav-split-line>\n </ng-container>\n </thy-icon-nav>\n </div>\n</ng-template>\n", components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { type: i6.ThyProgressComponent, selector: "thy-progress", inputs: ["thyType", "thySize", "thyValue", "thyMax", "thyTips"] }, { type: i4.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { type: i3.ThyIconNavComponent, selector: "thy-icon-nav", inputs: ["thyType"] }, { type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i10.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }] });
2883
2972
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheImageComponent, decorators: [{
2884
2973
  type: Component,
2885
2974
  args: [{
@@ -5842,7 +5931,10 @@ const AlignEditor = {
5842
5931
  return false;
5843
5932
  },
5844
5933
  isDisabled(editor) {
5845
- if (editor.selection) {
5934
+ var _a;
5935
+ const contextService = (_a = editor === null || editor === void 0 ? void 0 : editor.injector) === null || _a === void 0 ? void 0 : _a.get(TheContextService);
5936
+ const { theOptions: { richMedia } } = contextService.getOptions();
5937
+ if (richMedia && editor.selection) {
5846
5938
  const disableGroup = [ElementKinds.image];
5847
5939
  const anchorBlock$1 = anchorBlock(editor);
5848
5940
  return anchorBlock$1 && disableGroup.includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
@@ -8070,89 +8162,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
8070
8162
  type: Injectable
8071
8163
  }], ctorParameters: function () { return []; } });
8072
8164
 
8073
- /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
8074
- function coercePixelsFromCssValue(cssValue) {
8075
- const match = cssValue.match(/(\d+(\.\d+)?)px/);
8076
- if (match) {
8077
- return Number(match[1]);
8078
- }
8079
- }
8080
- function getElementWidth(element) {
8081
- // Optimization: Check style.width first as we probably set it already before reading
8082
- // offsetWidth which triggers layout.
8083
- return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
8084
- }
8085
- function getElementHeight(element) {
8086
- return Math.round(element.getBoundingClientRect().height);
8087
- }
8088
- function getColsTotalWidth(cols) {
8089
- return cols.reduce((total, col) => {
8090
- return total + getElementWidth(col);
8091
- }, 0);
8092
- }
8093
- function getRowsTotalHeight(rows) {
8094
- return rows.reduce((total, row) => {
8095
- return total + getElementHeight(row);
8096
- }, 0);
8097
- }
8098
- function useElementStyle(el, element) {
8099
- if (element.align) {
8100
- el.style.textAlign = element.align || Alignment.left;
8101
- }
8102
- if (element.textIndent) {
8103
- el.style.textIndent = element.textIndent + 'em';
8104
- }
8105
- if (element.verticalAlign) {
8106
- el.style.verticalAlign = element.verticalAlign;
8107
- }
8108
- }
8109
- function getElementClassByPrefix(el, prefix) {
8110
- let matchClass = null;
8111
- el.classList.forEach((value, key) => {
8112
- if (value.includes(prefix)) {
8113
- matchClass = value;
8114
- }
8115
- });
8116
- return matchClass;
8117
- }
8118
- function findRelativeElementByPoint(editor, x, y, mode) {
8119
- const editableElement = EDITOR_TO_ELEMENT.get(editor);
8120
- const rectEditable = editableElement.getBoundingClientRect();
8121
- if (x > rectEditable.x && x < rectEditable.x + rectEditable.width) {
8122
- const centerX = rectEditable.x + rectEditable.width / 2;
8123
- let relativeElement = document.elementFromPoint(mode === 'highest' ? centerX : x, y);
8124
- return relativeElement;
8125
- }
8126
- return null;
8127
- }
8128
- function findNodeEntryByPoint(editor, x, y, mode) {
8129
- const editableElement = EDITOR_TO_ELEMENT.get(editor);
8130
- let rootElement = null;
8131
- let relativeElement = findRelativeElementByPoint(editor, x, y, mode);
8132
- // 获取最顶层的DOM
8133
- if (mode === 'highest') {
8134
- while (relativeElement && editableElement.contains(relativeElement)) {
8135
- relativeElement = relativeElement.closest('[data-slate-node="element"]');
8136
- if (relativeElement) {
8137
- rootElement = relativeElement;
8138
- relativeElement = relativeElement.parentElement;
8139
- }
8140
- }
8141
- }
8142
- if (!mode) {
8143
- if (relativeElement && editableElement.contains(relativeElement)) {
8144
- relativeElement = relativeElement.closest('[data-slate-node="element"]');
8145
- rootElement = relativeElement;
8146
- }
8147
- }
8148
- if (rootElement) {
8149
- const node = AngularEditor.toSlateNode(editor, rootElement);
8150
- const path = AngularEditor.findPath(editor, node);
8151
- return [node, path];
8152
- }
8153
- return null;
8154
- }
8155
-
8156
8165
  function splitCell(editor) {
8157
8166
  const opts = new TableOptions$1();
8158
8167
  const { anchor } = editor.selection;
@@ -12405,341 +12414,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
12405
12414
  args: ['mousedown', ['$event']]
12406
12415
  }] } });
12407
12416
 
12408
- const getCurrentTarget = (editor, event) => {
12409
- const editorElement = EDITOR_TO_ELEMENT.get(editor);
12410
- const { left, right } = editorElement.getBoundingClientRect();
12411
- let { paddingLeft, paddingRight } = window.getComputedStyle(editorElement, null);
12412
- const paddingLeftPixels = coercePixelsFromCssValue(paddingLeft);
12413
- const paddingRightPixels = coercePixelsFromCssValue(paddingRight);
12414
- let x = event.x;
12415
- if (event.x <= left + paddingLeftPixels || event.x >= right - paddingRightPixels) {
12416
- x = left + paddingLeftPixels;
12417
- }
12418
- const nodeEntry = findNodeEntryByPoint(editor, x, event.y);
12419
- if (nodeEntry) {
12420
- return TheEditor.toDOMNode(editor, nodeEntry[0]);
12421
- }
12422
- };
12423
-
12424
- const getHoverDirection = (editor, event) => {
12425
- const rootNode = getCurrentTarget(editor, event);
12426
- if (rootNode) {
12427
- const { top, bottom } = rootNode.getBoundingClientRect();
12428
- const middleHeight = (bottom - top) / 2;
12429
- if (top + middleHeight > event.clientY) {
12430
- return 'top';
12431
- }
12432
- return 'bottom';
12433
- }
12434
- };
12435
-
12436
- const removeDropThumbLine = (editor) => {
12437
- const element = EDITOR_TO_ELEMENT.get(editor);
12438
- const dropThumbLine = element.querySelector('.' + DROP_THUMB_LINE);
12439
- if (dropThumbLine) {
12440
- dropThumbLine.remove();
12441
- }
12442
- };
12443
-
12444
- const moveDragNode = (editor, dragNode, event) => {
12445
- event.stopPropagation();
12446
- const element = EDITOR_TO_ELEMENT.get(editor);
12447
- const dropThumbLine = element.querySelector('.' + DROP_THUMB_LINE);
12448
- const parentElement = dropThumbLine && dropThumbLine.parentNode;
12449
- if (parentElement) {
12450
- const node = TheEditor.toSlateNode(editor, parentElement);
12451
- let dropPath = node && TheEditor.findPath(editor, node);
12452
- if (dropPath.length) {
12453
- const dragPath = dragNode.path;
12454
- const before = Path.isBefore(dragPath, dropPath) && Path.isSibling(dragPath, dropPath);
12455
- dropPath = before ? dropPath : Path.next(dropPath);
12456
- if (dropPath.length) {
12457
- Editor.withoutNormalizing(editor, () => {
12458
- Transforms.moveNodes(editor, {
12459
- at: dragPath,
12460
- to: dropPath
12461
- });
12462
- });
12463
- }
12464
- }
12465
- }
12466
- removeDropThumbLine(editor);
12467
- };
12468
-
12469
- const isValidDrag = (editor, dragNode, currentTarget) => {
12470
- var _a;
12471
- const node = TheEditor.toSlateNode(editor, currentTarget);
12472
- const dropPath = TheEditor.findPath(editor, node);
12473
- const dragPath = TheEditor.findPath(editor, dragNode);
12474
- if (dragPath[0] === dropPath[0] && dropPath.length > 1) {
12475
- // 阻止list元素拖入自身
12476
- return false;
12477
- }
12478
- let allElementOptions = DefaultElementOptions;
12479
- if ((_a = editor.extraElementOptions) === null || _a === void 0 ? void 0 : _a.length) {
12480
- const extraInfo = mergeElementOptions(editor.extraElementOptions);
12481
- allElementOptions = Object.values(extraInfo);
12482
- }
12483
- const types = allElementOptions.map(item => item.type);
12484
- if (types.indexOf(node.type) > -1 && allElementOptions[types.indexOf(node.type)].isSecondaryContainer) {
12485
- // 阻止向table-celld等二级容器中拖入
12486
- return false;
12487
- }
12488
- let containerParent = Editor.above(editor, {
12489
- at: dropPath,
12490
- mode: 'lowest',
12491
- match: (node) => {
12492
- return node && node.type && types.includes(node.type);
12493
- }
12494
- });
12495
- if (containerParent) {
12496
- const { inValidChildrenTypes } = allElementOptions.find(item => item.type === containerParent[0].type);
12497
- if (inValidChildrenTypes.includes(dragNode.type)) {
12498
- return false;
12499
- }
12500
- }
12501
- return true;
12502
- };
12503
-
12504
- const SNAPSHOT_PADDING_WIDTH = 5;
12505
- const SNAPSHOT_LIMI_HEIGHT = 70;
12506
- const DRAG_ICON_SIZE = 24;
12507
- const DRAG_ICON_OFFSET = 5;
12508
- const DRAG_SNAPSHOT_OFFSET = 15; // 拖拽内容距离鼠标偏移量
12509
- class TheDndComponent {
12510
- constructor(renderer, elementRef, ngZone, cdr) {
12511
- this.renderer = renderer;
12512
- this.elementRef = elementRef;
12513
- this.ngZone = ngZone;
12514
- this.cdr = cdr;
12515
- this.isDraging = false;
12516
- this.destroy$ = new Subject();
12517
- this.dragChange = new EventEmitter();
12518
- this.dropThumbLine = document.createElement('div');
12519
- this.dropThumbLine.className = DROP_THUMB_LINE;
12520
- }
12521
- get nativeElement() {
12522
- return this.elementRef.nativeElement;
12523
- }
12524
- get editableElement() {
12525
- return this.editor && EDITOR_TO_ELEMENT.get(this.editor);
12526
- }
12527
- ngAfterViewInit() {
12528
- const contextService = this.editor.injector.get(TheContextService);
12529
- this.ngZone.runOutsideAngular(() => {
12530
- merge(fromEvent(this.editableElement, `mousemove`), fromEvent(this.editableElement, `mouseleave`))
12531
- .pipe(takeUntil(this.destroy$), filter(() => {
12532
- return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
12533
- }))
12534
- .subscribe(e => this.setDragIcon(e));
12535
- fromEvent(document, `drop`)
12536
- .pipe(takeUntil(this.destroy$), filter(() => {
12537
- return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
12538
- }))
12539
- .subscribe(e => this.onDrop(e));
12540
- fromEvent(document, `dragover`)
12541
- .pipe(takeUntil(this.destroy$), filter(() => {
12542
- return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
12543
- }))
12544
- .subscribe(e => this.onDragover(e));
12545
- fromEvent(document, `scroll`)
12546
- .pipe(takeUntil(this.destroy$), filter(() => {
12547
- return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
12548
- }))
12549
- .subscribe(e => {
12550
- e.preventDefault();
12551
- let scrollPosition = window.scrollY;
12552
- if (!this.isScrolling && this.isDraging) {
12553
- window.requestAnimationFrame(() => {
12554
- if (this.editableTop) {
12555
- // 滚动过程中,通过设置父级元素来设置snapshot位置
12556
- this.updateDndContainerPosition(null, scrollPosition + this.editableTop + 'px');
12557
- }
12558
- this.isScrolling = false;
12559
- });
12560
- this.isScrolling = true;
12561
- }
12562
- });
12563
- });
12564
- this.setVisibility(false);
12565
- this.valueChangeHandle();
12566
- }
12567
- valueChangeHandle() {
12568
- const { onChange } = this.editor;
12569
- this.editor.onChange = () => {
12570
- const ops = this.editor.operations;
12571
- const skip = ops.length === 1 && Operation.isSelectionOperation(ops[0]);
12572
- if (!skip) {
12573
- this.setVisibility(false);
12574
- }
12575
- onChange();
12576
- };
12577
- }
12578
- updateDndContainerPosition(left, top) {
12579
- const element = this.elementRef.nativeElement;
12580
- const parentElement = element.parentElement;
12581
- top && this.renderer.setStyle(parentElement, 'top', top);
12582
- left && this.renderer.setStyle(parentElement, 'left', left);
12583
- }
12584
- getEditableTop(event) {
12585
- const offsetHeight = document.documentElement.offsetHeight;
12586
- const { height } = this.editableElement.getBoundingClientRect();
12587
- if (event.clientY < this.dragElementHeight) {
12588
- this.editableTop = -this.editableElement.offsetTop;
12589
- return;
12590
- }
12591
- if (height > event.pageY && event.clientY + this.dragElementHeight >= offsetHeight) {
12592
- this.editableTop = event.clientY - this.editableElement.offsetTop;
12593
- return;
12594
- }
12595
- this.editableTop = null;
12596
- }
12597
- onDragStart(event) {
12598
- this.isDraging = true;
12599
- this.dragChange.emit(this.isDraging);
12600
- this.dragSnapshotContent = this.elementRef.nativeElement.nextSibling;
12601
- this.dragSnapshotContent.className = 'the-editor-typo drag-snapshot-container';
12602
- this.dragSnapshotContent.appendChild(this.dragElement.cloneNode(true));
12603
- this.dragElement.style.opacity = '0.3';
12604
- }
12605
- onDragEnd(event) {
12606
- this.dragElement.style.opacity = '';
12607
- this.isDraging = false;
12608
- this.setVisibility(false);
12609
- this.resetDragSnapshotContent();
12610
- this.dragChange.emit(this.isDraging);
12611
- }
12612
- onDrop(event) {
12613
- event.preventDefault();
12614
- if (this.isDraging) {
12615
- moveDragNode(this.editor, this.dragNode, event);
12616
- }
12617
- }
12618
- onDragover(event) {
12619
- event.preventDefault();
12620
- if (this.isDraging && !this.isScrolling) {
12621
- this.getEditableTop(event);
12622
- const offsetWidth = document.documentElement.offsetWidth;
12623
- const { left: editorLeft, top: editorTop, height } = this.editableElement.getBoundingClientRect();
12624
- let top = 0;
12625
- let left = 0;
12626
- if (event.clientX + this.dragElementWidth / 2 > offsetWidth) {
12627
- left = event.pageX - editorLeft - this.nativeElement.offsetWidth;
12628
- }
12629
- else {
12630
- left = Math.max(event.pageX - editorLeft, -editorLeft) + DRAG_SNAPSHOT_OFFSET;
12631
- }
12632
- const scrollTop = document.documentElement.scrollTop;
12633
- const editorMarginTop = editorTop + scrollTop; // 编辑器距离顶部间距
12634
- if (event.clientY + this.dragElementHeight + DRAG_SNAPSHOT_OFFSET > document.documentElement.offsetHeight) {
12635
- top = event.pageY - editorMarginTop - this.nativeElement.offsetHeight + DRAG_SNAPSHOT_OFFSET;
12636
- top = Math.min(top, height - this.editableElement.offsetTop);
12637
- }
12638
- else {
12639
- top = event.pageY - editorMarginTop + this.editableElement.offsetTop + DRAG_SNAPSHOT_OFFSET;
12640
- }
12641
- this.updateDndContainerPosition(left + 'px', top + 'px');
12642
- this.setSnapshotStyle(event);
12643
- this.setDropThumbLine(event);
12644
- }
12645
- }
12646
- setDropThumbLine(event) {
12647
- var _a;
12648
- let element = getCurrentTarget(this.editor, event);
12649
- const direction = getHoverDirection(this.editor, event);
12650
- if (element) {
12651
- if (direction && direction === 'top') {
12652
- element = (_a = element.previousElementSibling) === null || _a === void 0 ? void 0 : _a.querySelector('[data-slate-node="element"]');
12653
- }
12654
- if (element && isValidDrag(this.editor, this.dragNode.node, element)) {
12655
- element.appendChild(this.dropThumbLine);
12656
- }
12657
- }
12658
- }
12659
- setDragIcon(event) {
12660
- if (!this.isDraging) {
12661
- const nodeEntry = findNodeEntryByPoint(this.editor, event.x, event.y, 'highest');
12662
- if (nodeEntry && !Editor.isEmpty(this.editor, nodeEntry[0])) {
12663
- const rootNode = AngularEditor.toDOMNode(this.editor, nodeEntry[0]);
12664
- this.dragNode = {
12665
- node: nodeEntry[0],
12666
- path: nodeEntry[1]
12667
- };
12668
- this.dragElement = rootNode;
12669
- let lineHeight = coercePixelsFromCssValue(window.getComputedStyle(rootNode)['lineHeight']);
12670
- const offsetTop = rootNode.offsetTop + rootNode.offsetParent.offsetTop + (lineHeight - DRAG_ICON_SIZE) / 2;
12671
- const offsetLeft = rootNode.offsetLeft + rootNode.offsetParent.offsetLeft;
12672
- this.updateDndContainerPosition(offsetLeft - DRAG_ICON_SIZE - DRAG_ICON_OFFSET + 'px', offsetTop + 'px');
12673
- this.setVisibility(true);
12674
- }
12675
- else {
12676
- this.setVisibility(false);
12677
- }
12678
- }
12679
- }
12680
- setSnapshotStyle(event) {
12681
- const { width, height } = this.dragElement.getBoundingClientRect();
12682
- this.dragElementHeight = height;
12683
- this.dragElementWidth = width;
12684
- let dragSnapshotContentStyle = `display: block; min-height: 0; width: ${width + SNAPSHOT_PADDING_WIDTH * 2}px;`;
12685
- if (height > SNAPSHOT_LIMI_HEIGHT) {
12686
- dragSnapshotContentStyle = dragSnapshotContentStyle + 'transform: scale(0.45);';
12687
- this.dragElementHeight = this.dragElementHeight * 0.45;
12688
- this.dragElementWidth = this.dragElementWidth * 0.45;
12689
- }
12690
- let snapshotTop = 0;
12691
- let snapshotLeft = 0;
12692
- // 上下移动:超出屏幕高度,重新设置snapshot的位置
12693
- if (event.clientY + this.dragElementHeight + DRAG_SNAPSHOT_OFFSET > document.documentElement.offsetHeight) {
12694
- snapshotTop = this.dragElementHeight;
12695
- }
12696
- else {
12697
- snapshotTop = 0;
12698
- }
12699
- // 左右移动:超出屏幕宽度,重新设置snapshot的位置
12700
- if (event.clientX + this.dragElementWidth / 2 > document.documentElement.offsetWidth) {
12701
- snapshotLeft = this.dragElementWidth;
12702
- }
12703
- else {
12704
- snapshotLeft = 0;
12705
- }
12706
- dragSnapshotContentStyle = dragSnapshotContentStyle + `top: ${-snapshotTop}px; left: ${-snapshotLeft}px;`;
12707
- this.dragSnapshotContent.setAttribute('style', dragSnapshotContentStyle);
12708
- }
12709
- resetDragSnapshotContent() {
12710
- this.dragSnapshotContent.className = 'drag-snapshot-container';
12711
- this.dragSnapshotContent.setAttribute('style', '');
12712
- this.dragSnapshotContent.innerHTML = '';
12713
- }
12714
- setVisibility(visible = true) {
12715
- const dndContainer = this.nativeElement.parentNode;
12716
- dndContainer.style.display = visible ? 'block' : 'none';
12717
- }
12718
- ngOnDestroy() {
12719
- this.destroy$.next();
12720
- this.destroy$.complete();
12721
- }
12722
- }
12723
- TheDndComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheDndComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
12724
- TheDndComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheDndComponent, selector: "[theDnd]", inputs: { editor: "editor" }, outputs: { dragChange: "dragChange" }, host: { classAttribute: "the-drag-drop" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true }], ngImport: i0, template: "<div\n draggable=\"true\"\n class=\"the-drag-drop-icon\"\n [ngStyle]=\"{ opacity: isDraging ? 0 : '' }\"\n (dragstart)=\"onDragStart($event)\"\n (dragend)=\"onDragEnd($event)\"\n>\n <thy-icon thyIconName=\"drag\"> </thy-icon>\n</div>\n", components: [{ type: i4.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }], directives: [{ type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
12725
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheDndComponent, decorators: [{
12726
- type: Component,
12727
- args: [{
12728
- selector: '[theDnd]',
12729
- templateUrl: './dnd.component.html',
12730
- host: {
12731
- class: 'the-drag-drop'
12732
- }
12733
- }]
12734
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { editor: [{
12735
- type: Input
12736
- }], dragChange: [{
12737
- type: Output
12738
- }], content: [{
12739
- type: ViewChild,
12740
- args: ['content', { static: false }]
12741
- }] } });
12742
-
12743
12417
  class ElementStylePipe {
12744
12418
  transform(element, align) {
12745
12419
  const style = {};
@@ -12944,16 +12618,10 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
12944
12618
  this.onSlaDragStart = (event) => { };
12945
12619
  this.onSlaDragOver = (event) => { };
12946
12620
  this.onDrop = (event) => {
12947
- if (this.isDraging) {
12948
- event.preventDefault();
12949
- }
12950
12621
  this.theOnDOMEvent.emit({
12951
12622
  nativeEvent: event
12952
12623
  });
12953
12624
  };
12954
- this.onDragChange = isDraging => {
12955
- this.isDraging = isDraging;
12956
- };
12957
12625
  }
12958
12626
  get theGlobalToolbarInstance() {
12959
12627
  return this.theGlobalToolbar ? this.theGlobalToolbar : this.globalToolbarInstance;
@@ -13127,8 +12795,17 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
13127
12795
  if (event.target === editableElement) {
13128
12796
  const rectEditable = editableElement.getBoundingClientRect();
13129
12797
  const centerX = rectEditable.x + rectEditable.width / 2;
13130
- const relativeElement = document.elementFromPoint(centerX, event.y);
13131
- const relativeBlockCardElement = relativeElement.closest('.slate-block-card');
12798
+ let { paddingLeft, paddingRight } = window.getComputedStyle(editableElement, null);
12799
+ const paddingLeftPixels = coercePixelsFromCssValue(paddingLeft);
12800
+ const paddingRightPixels = coercePixelsFromCssValue(paddingRight);
12801
+ const fakeLeftX = rectEditable.x + paddingLeftPixels + 50;
12802
+ const fakeRightX = rectEditable.right - paddingRightPixels - 50;
12803
+ let relativeElement = document.elementFromPoint(fakeLeftX, event.y);
12804
+ let relativeBlockCardElement = relativeElement.closest('.slate-block-card');
12805
+ if (!relativeBlockCardElement) {
12806
+ relativeElement = document.elementFromPoint(fakeRightX, event.y);
12807
+ relativeBlockCardElement = relativeElement.closest('.slate-block-card');
12808
+ }
13132
12809
  if (relativeBlockCardElement) {
13133
12810
  const blockCardEntry = AngularEditor.toSlateCardEntry(this.editor, relativeBlockCardElement.firstElementChild);
13134
12811
  if (blockCardEntry && blockCardEntry[1]) {
@@ -13195,7 +12872,7 @@ TheEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", ver
13195
12872
  useExisting: forwardRef(() => TheEditorComponent),
13196
12873
  multi: true
13197
12874
  }
13198
- ], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<the-toolbar\n *ngIf=\"!theOptions?.readonly && !theGlobalToolbar\"\n [ngClass]=\"{\n 'the-toolbar-disabled': theOptions?.disabled\n }\"\n #globalToolbar\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.global\"\n [containerClass]=\"globalToolbarClass\"\n [align]=\"theOptions?.toolbar?.align\"\n></the-toolbar>\n\n<div\n class=\"the-editable-container\"\n [ngClass]=\"{\n 'the-editor-disabled': theOptions?.disabled,\n 'max-height': maxHeight\n }\"\n [ngStyle]=\"{ 'max-height': maxHeight }\"\n>\n <slate-editable\n class=\"the-editor-typo\"\n [editor]=\"editor\"\n [ngModel]=\"editorValue\"\n (ngModelChange)=\"valueChange($event)\"\n [decorate]=\"decorate\"\n [placeholder]=\"theOptions?.placeholder\"\n [placeholderDecorate]=\"theOptions?.placeholderDecorate ? theOptions?.placeholderDecorate : null\"\n [renderElement]=\"renderElement\"\n [renderText]=\"renderText\"\n [renderLeaf]=\"renderLeaf\"\n [readonly]=\"theOptions?.readonly || theOptions?.disabled\"\n [keydown]=\"onKeyDown\"\n [click]=\"onClick\"\n [paste]=\"onSlaPaste\"\n [beforeInput]=\"onSlaBeforeInput\"\n [blur]=\"onSlaBlur\"\n [focus]=\"onSlaFocus\"\n [copy]=\"onSlaCopy\"\n [cut]=\"onSlaCut\"\n [isStrictDecorate]=\"false\"\n [compositionStart]=\"onSlaCompositionStart\"\n [compositionEnd]=\"onSlaCompositionEnd\"\n [dragStart]=\"onSlaDragStart\"\n [dragOver]=\"onSlaDragOver\"\n [drop]=\"onDrop\"\n (mousedown)=\"mousedown($event)\"\n ></slate-editable>\n <the-inline-toolbar\n *ngIf=\"!theOptions?.readonly && theOptions?.inlineToobarVisible\"\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.inline\"\n ></the-inline-toolbar>\n <div\n #quickInsert\n theQuickInsert\n [editor]=\"editor\"\n [quickToolbarItems]=\"quickToolbarItems\"\n [isVisible]=\"theOptions?.quickInsertVisible\"\n ></div>\n <div class=\"drag-container\">\n <div #drag theDnd [editor]=\"editor\" (dragChange)=\"onDragChange($event)\"></div>\n <div class=\"drag-snapshot-container\"></div>\n </div>\n <the-template #templateInstance></the-template>\n</div>\n", components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }, { type: i1.SlateEditableComponent, selector: "slate-editable", inputs: ["editor", "renderElement", "renderLeaf", "renderText", "decorate", "placeholderDecorate", "isStrictDecorate", "trackBy", "readonly", "placeholder", "beforeInput", "blur", "click", "compositionEnd", "compositionStart", "copy", "cut", "dragOver", "dragStart", "dragEnd", "drop", "focus", "keydown", "paste", "spellCheck", "autoCorrect", "autoCapitalize"] }, { type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: ["editor", "toolbarItems"] }, { type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: ["editor", "quickToolbarItems", "isVisible"] }, { type: TheDndComponent, selector: "[theDnd]", inputs: ["editor"], outputs: ["dragChange"] }, { type: TheTemplateComponent, selector: "the-template,[theTemplate]" }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
12875
+ ], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<the-toolbar\n *ngIf=\"!theOptions?.readonly && !theGlobalToolbar\"\n [ngClass]=\"{\n 'the-toolbar-disabled': theOptions?.disabled\n }\"\n #globalToolbar\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.global\"\n [containerClass]=\"globalToolbarClass\"\n [align]=\"theOptions?.toolbar?.align\"\n></the-toolbar>\n\n<div\n class=\"the-editable-container\"\n [ngClass]=\"{\n 'the-editor-disabled': theOptions?.disabled,\n 'max-height': maxHeight\n }\"\n [ngStyle]=\"{ 'max-height': maxHeight }\"\n>\n <slate-editable\n class=\"the-editor-typo\"\n [editor]=\"editor\"\n [ngModel]=\"editorValue\"\n (ngModelChange)=\"valueChange($event)\"\n [decorate]=\"decorate\"\n [placeholder]=\"theOptions?.placeholder\"\n [placeholderDecorate]=\"theOptions?.placeholderDecorate ? theOptions?.placeholderDecorate : null\"\n [renderElement]=\"renderElement\"\n [renderText]=\"renderText\"\n [renderLeaf]=\"renderLeaf\"\n [readonly]=\"theOptions?.readonly || theOptions?.disabled\"\n [keydown]=\"onKeyDown\"\n [click]=\"onClick\"\n [paste]=\"onSlaPaste\"\n [beforeInput]=\"onSlaBeforeInput\"\n [blur]=\"onSlaBlur\"\n [focus]=\"onSlaFocus\"\n [copy]=\"onSlaCopy\"\n [cut]=\"onSlaCut\"\n [isStrictDecorate]=\"false\"\n [compositionStart]=\"onSlaCompositionStart\"\n [compositionEnd]=\"onSlaCompositionEnd\"\n [dragStart]=\"onSlaDragStart\"\n [dragOver]=\"onSlaDragOver\"\n [drop]=\"onDrop\"\n (mousedown)=\"mousedown($event)\"\n ></slate-editable>\n <the-inline-toolbar\n *ngIf=\"!theOptions?.readonly && theOptions?.inlineToobarVisible\"\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.inline\"\n ></the-inline-toolbar>\n <div\n #quickInsert\n theQuickInsert\n [editor]=\"editor\"\n [quickToolbarItems]=\"quickToolbarItems\"\n [isVisible]=\"theOptions?.quickInsertVisible\"\n ></div>\n <the-template #templateInstance></the-template>\n</div>\n", components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }, { type: i1.SlateEditableComponent, selector: "slate-editable", inputs: ["editor", "renderElement", "renderLeaf", "renderText", "decorate", "placeholderDecorate", "isStrictDecorate", "trackBy", "readonly", "placeholder", "beforeInput", "blur", "click", "compositionEnd", "compositionStart", "copy", "cut", "dragOver", "dragStart", "dragEnd", "drop", "focus", "keydown", "paste", "spellCheck", "autoCorrect", "autoCapitalize"] }, { type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: ["editor", "toolbarItems"] }, { type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: ["editor", "quickToolbarItems", "isVisible"] }, { type: TheTemplateComponent, selector: "the-template,[theTemplate]" }], directives: [{ type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
13199
12876
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheEditorComponent, decorators: [{
13200
12877
  type: Component,
13201
12878
  args: [{
@@ -13440,8 +13117,7 @@ const PLUGIN_COMPONENTS = [
13440
13117
  TheTableComponent,
13441
13118
  TheTableRowComponent,
13442
13119
  TheTdComponent,
13443
- TheInlineCodeComponent,
13444
- TheDndComponent
13120
+ TheInlineCodeComponent
13445
13121
  ];
13446
13122
  const PIPES = [ElementStylePipe, ElementClassPipe];
13447
13123
  class TheEditorModule {
@@ -13482,8 +13158,7 @@ TheEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version
13482
13158
  TheTableComponent,
13483
13159
  TheTableRowComponent,
13484
13160
  TheTdComponent,
13485
- TheInlineCodeComponent,
13486
- TheDndComponent], imports: [CommonModule, SlateModule, FormsModule, ThyIconModule,
13161
+ TheInlineCodeComponent], imports: [CommonModule, SlateModule, FormsModule, ThyIconModule,
13487
13162
  ThyAvatarModule,
13488
13163
  ThyNavModule,
13489
13164
  ThyFormModule,
@@ -13532,5 +13207,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
13532
13207
  * Generated bundle index. Do not edit.
13533
13208
  */
13534
13209
 
13535
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DROP_THUMB_LINE, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, Indents, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, isCleanEmptyParagraph, plainToTheia, toolbarCompose, withTheEditor };
13210
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, Indents, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, coercePixelsFromCssValue, createEmptyParagraph, dataDeserialize, dataSerializing, findNodeEntryByPoint, findRelativeElementByPoint, getColsTotalWidth, getElementClassByPrefix, getElementHeight, getElementWidth, getRowsTotalHeight, getToolbarClass, htmlToTheia, inValidTypes, isCleanEmptyParagraph, mergeElementOptions, plainToTheia, toolbarCompose, useElementStyle, withTheEditor };
13536
13211
  //# sourceMappingURL=worktile-theia.js.map