@worktile/theia 2.3.0-next.0 → 2.3.0-next.3
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/bundles/worktile-theia.umd.js +142 -477
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/constants/default.d.ts +0 -2
- package/editor.component.d.ts +0 -2
- package/editor.module.d.ts +24 -26
- package/esm2015/constants/default.js +1 -2
- package/esm2015/editor.component.js +17 -14
- package/esm2015/editor.module.js +3 -6
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/plugins/align/align.editor.js +6 -2
- package/esm2015/plugins/image/image.component.js +13 -8
- package/esm2015/utils/dom.js +2 -2
- package/esm2015/utils/index.js +3 -1
- package/fesm2015/worktile-theia.js +135 -468
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/editor.d.ts +1 -6
- package/package.json +1 -1
- package/plugins/image/image.component.scss +0 -7
- package/plugins/table/components/table.component.scss +2 -2
- package/styles/editor.scss +160 -133
- package/styles/index.scss +1 -2
- package/styles/typo.scss +12 -1
- package/utils/index.d.ts +2 -0
- package/esm2015/plugins/dnd/component/dnd.component.js +0 -260
- package/esm2015/plugins/dnd/utils/get-current-target.js +0 -19
- package/esm2015/plugins/dnd/utils/get-hover-direction.js +0 -13
- package/esm2015/plugins/dnd/utils/is-valid-drag.js +0 -38
- package/esm2015/plugins/dnd/utils/move-drag-node.js +0 -30
- package/esm2015/plugins/dnd/utils/remove-drop-thumb-line.js +0 -10
- package/plugins/dnd/component/dnd.component.d.ts +0 -42
- package/plugins/dnd/component/dnd.component.scss +0 -61
- package/plugins/dnd/utils/get-current-target.d.ts +0 -2
- package/plugins/dnd/utils/get-hover-direction.d.ts +0 -3
- package/plugins/dnd/utils/is-valid-drag.d.ts +0 -3
- package/plugins/dnd/utils/move-drag-node.d.ts +0 -2
- package/plugins/dnd/utils/remove-drop-thumb-line.d.ts +0 -2
|
@@ -379,7 +379,6 @@
|
|
|
379
379
|
var DEFAULT_SCROLL_CONTAINER = '.the-editable-container';
|
|
380
380
|
var ELEMENT_UNIQUE_ID = 'key';
|
|
381
381
|
var ZERO_WIDTH_CHAR = '\u200B';
|
|
382
|
-
var DROP_THUMB_LINE = 'drop-thumb-line';
|
|
383
382
|
exports.TheMode = void 0;
|
|
384
383
|
(function (TheMode) {
|
|
385
384
|
TheMode["fullMode"] = "full";
|
|
@@ -2577,6 +2576,108 @@
|
|
|
2577
2576
|
return false;
|
|
2578
2577
|
};
|
|
2579
2578
|
|
|
2579
|
+
var mergeElementOptions = function (elementOptions) {
|
|
2580
|
+
elementOptions = elementOptions.filter(function (item) { return item.inValidChildrenTypes.length > 0; });
|
|
2581
|
+
var combinationData = __spreadArray(__spreadArray([], __read(DefaultElementOptions)), __read(elementOptions));
|
|
2582
|
+
var dataInfo = {};
|
|
2583
|
+
combinationData.forEach(function (item) {
|
|
2584
|
+
var type = item.type, inValidChildrenTypes = item.inValidChildrenTypes, isIndivisible = item.isIndivisible, isSecondaryContainer = item.isSecondaryContainer;
|
|
2585
|
+
if (!dataInfo[type]) {
|
|
2586
|
+
dataInfo[type] = {
|
|
2587
|
+
type: type,
|
|
2588
|
+
inValidChildrenTypes: inValidChildrenTypes,
|
|
2589
|
+
isIndivisible: isIndivisible,
|
|
2590
|
+
isSecondaryContainer: isSecondaryContainer
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
dataInfo[type].inValidChildrenTypes = Array.from(new Set(__spreadArray(__spreadArray([], __read(inValidChildrenTypes)), __read(dataInfo[type].inValidChildrenTypes))));
|
|
2594
|
+
});
|
|
2595
|
+
return dataInfo;
|
|
2596
|
+
};
|
|
2597
|
+
|
|
2598
|
+
/** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
|
|
2599
|
+
function coercePixelsFromCssValue(cssValue) {
|
|
2600
|
+
var match = cssValue.match(/(\d+(\.\d+)?)px/);
|
|
2601
|
+
if (match) {
|
|
2602
|
+
return Number(match[1]);
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
function getElementWidth(element) {
|
|
2606
|
+
// Optimization: Check style.width first as we probably set it already before reading
|
|
2607
|
+
// offsetWidth which triggers layout.
|
|
2608
|
+
return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
|
|
2609
|
+
}
|
|
2610
|
+
function getElementHeight(element) {
|
|
2611
|
+
return Math.round(element.getBoundingClientRect().height);
|
|
2612
|
+
}
|
|
2613
|
+
function getColsTotalWidth(cols) {
|
|
2614
|
+
return cols.reduce(function (total, col) {
|
|
2615
|
+
return total + getElementWidth(col);
|
|
2616
|
+
}, 0);
|
|
2617
|
+
}
|
|
2618
|
+
function getRowsTotalHeight(rows) {
|
|
2619
|
+
return rows.reduce(function (total, row) {
|
|
2620
|
+
return total + getElementHeight(row);
|
|
2621
|
+
}, 0);
|
|
2622
|
+
}
|
|
2623
|
+
function useElementStyle(el, element) {
|
|
2624
|
+
if (element.align) {
|
|
2625
|
+
el.style.textAlign = element.align || exports.Alignment.left;
|
|
2626
|
+
}
|
|
2627
|
+
if (element.textIndent) {
|
|
2628
|
+
el.style.textIndent = element.textIndent + 'em';
|
|
2629
|
+
}
|
|
2630
|
+
if (element.verticalAlign) {
|
|
2631
|
+
el.style.verticalAlign = element.verticalAlign;
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
function getElementClassByPrefix(el, prefix) {
|
|
2635
|
+
var matchClass = null;
|
|
2636
|
+
el.classList.forEach(function (value, key) {
|
|
2637
|
+
if (value.includes(prefix)) {
|
|
2638
|
+
matchClass = value;
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
return matchClass;
|
|
2642
|
+
}
|
|
2643
|
+
function findRelativeElementByPoint(editor, x, y, mode) {
|
|
2644
|
+
var editableElement = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
2645
|
+
var rectEditable = editableElement.getBoundingClientRect();
|
|
2646
|
+
if (x > rectEditable.x && x < rectEditable.x + rectEditable.width) {
|
|
2647
|
+
var centerX = rectEditable.x + rectEditable.width / 2;
|
|
2648
|
+
var relativeElement = document.elementFromPoint(mode === 'highest' ? centerX : x, y);
|
|
2649
|
+
return relativeElement;
|
|
2650
|
+
}
|
|
2651
|
+
return null;
|
|
2652
|
+
}
|
|
2653
|
+
function findNodeEntryByPoint(editor, x, y, mode) {
|
|
2654
|
+
var editableElement = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
2655
|
+
var rootElement = null;
|
|
2656
|
+
var relativeElement = findRelativeElementByPoint(editor, x, y, mode);
|
|
2657
|
+
// 获取最顶层的DOM
|
|
2658
|
+
if (mode === 'highest') {
|
|
2659
|
+
while (relativeElement && editableElement.contains(relativeElement)) {
|
|
2660
|
+
relativeElement = relativeElement.closest('[data-slate-node="element"]');
|
|
2661
|
+
if (relativeElement) {
|
|
2662
|
+
rootElement = relativeElement;
|
|
2663
|
+
relativeElement = relativeElement.parentElement;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
if (!mode) {
|
|
2668
|
+
if (relativeElement && editableElement.contains(relativeElement)) {
|
|
2669
|
+
relativeElement = relativeElement.closest('[data-slate-node="element"]');
|
|
2670
|
+
rootElement = relativeElement;
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
if (rootElement) {
|
|
2674
|
+
var node = i1.AngularEditor.toSlateNode(editor, rootElement);
|
|
2675
|
+
var path = i1.AngularEditor.findPath(editor, node);
|
|
2676
|
+
return [node, path];
|
|
2677
|
+
}
|
|
2678
|
+
return null;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2580
2681
|
var withDeserializeMd = function (options) { return function (editor) {
|
|
2581
2682
|
var insertData = editor.insertData, onKeydown = editor.onKeydown;
|
|
2582
2683
|
editor.onKeydown = function (event) {
|
|
@@ -2681,25 +2782,6 @@
|
|
|
2681
2782
|
return regexps.some(function (regexp) { return regexp.test(content); });
|
|
2682
2783
|
};
|
|
2683
2784
|
|
|
2684
|
-
var mergeElementOptions = function (elementOptions) {
|
|
2685
|
-
elementOptions = elementOptions.filter(function (item) { return item.inValidChildrenTypes.length > 0; });
|
|
2686
|
-
var combinationData = __spreadArray(__spreadArray([], __read(DefaultElementOptions)), __read(elementOptions));
|
|
2687
|
-
var dataInfo = {};
|
|
2688
|
-
combinationData.forEach(function (item) {
|
|
2689
|
-
var type = item.type, inValidChildrenTypes = item.inValidChildrenTypes, isIndivisible = item.isIndivisible, isSecondaryContainer = item.isSecondaryContainer;
|
|
2690
|
-
if (!dataInfo[type]) {
|
|
2691
|
-
dataInfo[type] = {
|
|
2692
|
-
type: type,
|
|
2693
|
-
inValidChildrenTypes: inValidChildrenTypes,
|
|
2694
|
-
isIndivisible: isIndivisible,
|
|
2695
|
-
isSecondaryContainer: isSecondaryContainer
|
|
2696
|
-
};
|
|
2697
|
-
}
|
|
2698
|
-
dataInfo[type].inValidChildrenTypes = Array.from(new Set(__spreadArray(__spreadArray([], __read(inValidChildrenTypes)), __read(dataInfo[type].inValidChildrenTypes))));
|
|
2699
|
-
});
|
|
2700
|
-
return dataInfo;
|
|
2701
|
-
};
|
|
2702
|
-
|
|
2703
2785
|
var withAutoInsertData = function (validChildren) { return function (editor) {
|
|
2704
2786
|
var insertData = editor.insertData;
|
|
2705
2787
|
var allElementOptions = DefaultElementOptions;
|
|
@@ -3054,13 +3136,13 @@
|
|
|
3054
3136
|
{
|
|
3055
3137
|
key: exports.LayoutTypes.wrapLeft,
|
|
3056
3138
|
icon: 'wrap-left',
|
|
3057
|
-
name: '
|
|
3139
|
+
name: '图片居左',
|
|
3058
3140
|
handle: function (e, key) { return _this.setImageNode(e, { layout: key }); }
|
|
3059
3141
|
},
|
|
3060
3142
|
{
|
|
3061
3143
|
key: exports.LayoutTypes.wrapRight,
|
|
3062
3144
|
icon: 'wrap-right',
|
|
3063
|
-
name: '
|
|
3145
|
+
name: '图片居右',
|
|
3064
3146
|
handle: function (e, key) { return _this.setImageNode(e, { layout: key }); }
|
|
3065
3147
|
},
|
|
3066
3148
|
{
|
|
@@ -3275,25 +3357,31 @@
|
|
|
3275
3357
|
$event.stopPropagation();
|
|
3276
3358
|
};
|
|
3277
3359
|
TheImageComponent.prototype.isShouldOpen = function () {
|
|
3278
|
-
|
|
3360
|
+
var richMedia = this.theContextService.getOptions().theOptions.richMedia;
|
|
3361
|
+
return !(this === null || this === void 0 ? void 0 : this.readonly) && richMedia && (this === null || this === void 0 ? void 0 : this.isCollapsed) && !this.uploading && !this.isOpen;
|
|
3279
3362
|
};
|
|
3280
3363
|
TheImageComponent.prototype.isShouldClose = function () {
|
|
3281
3364
|
return this.isOpen && ((this === null || this === void 0 ? void 0 : this.readonly) || !(this === null || this === void 0 ? void 0 : this.isCollapsed) || this.uploading);
|
|
3282
3365
|
};
|
|
3283
3366
|
TheImageComponent.prototype.openLayoutToolbar = function () {
|
|
3367
|
+
var _this = this;
|
|
3284
3368
|
var _a;
|
|
3285
3369
|
this.layoutToolbarRef = this.thyPopover.open(this.layoutToolbar, {
|
|
3286
3370
|
origin: this.imageContent,
|
|
3287
|
-
panelClass: ['the-
|
|
3371
|
+
panelClass: ['the-block-toolbar'],
|
|
3288
3372
|
placement: 'bottom',
|
|
3289
3373
|
insideClosable: false,
|
|
3290
3374
|
backdropClosable: true,
|
|
3291
3375
|
hasBackdrop: false,
|
|
3292
|
-
offset:
|
|
3376
|
+
offset: 10,
|
|
3293
3377
|
viewContainerRef: this.viewContainerRef,
|
|
3294
3378
|
scrollStrategy: this.overlay.scrollStrategies.reposition()
|
|
3295
3379
|
});
|
|
3296
3380
|
(_a = this.layoutToolbarRef) === null || _a === void 0 ? void 0 : _a.getOverlayRef().updatePositionStrategy(this.createPositionStrategy());
|
|
3381
|
+
setTimeout(function () {
|
|
3382
|
+
var _a;
|
|
3383
|
+
(_a = _this.layoutToolbarRef) === null || _a === void 0 ? void 0 : _a.getOverlayRef().updatePosition();
|
|
3384
|
+
}, 150);
|
|
3297
3385
|
};
|
|
3298
3386
|
TheImageComponent.prototype.closeLayoutToolbar = function () {
|
|
3299
3387
|
var _a;
|
|
@@ -3335,7 +3423,7 @@
|
|
|
3335
3423
|
overlayX: 'center',
|
|
3336
3424
|
overlayY: 'top',
|
|
3337
3425
|
offsetX: 0,
|
|
3338
|
-
offsetY:
|
|
3426
|
+
offsetY: 10
|
|
3339
3427
|
};
|
|
3340
3428
|
return this.overlay
|
|
3341
3429
|
.position()
|
|
@@ -3348,7 +3436,7 @@
|
|
|
3348
3436
|
return TheImageComponent;
|
|
3349
3437
|
}(TheBaseElementComponent));
|
|
3350
3438
|
TheImageComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheImageComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i1__namespace$2.DomSanitizer }, { token: THE_UPLOAD_SERVICE_TOKEN }, { token: i0__namespace.ChangeDetectorRef }, { token: TheContextService }, { token: i1__namespace$3.ThyPopover }, { token: i2__namespace.Overlay }, { token: i0__namespace.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
3351
|
-
TheImageComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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-
|
|
3439
|
+
TheImageComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { type: i6__namespace.ThyProgressComponent, selector: "thy-progress", inputs: ["thyType", "thySize", "thyValue", "thyMax", "thyTips"] }, { type: i4__namespace.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { type: i3__namespace.ThyIconNavComponent, selector: "thy-icon-nav", inputs: ["thyType"] }, { type: i3__namespace.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i10__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5__namespace.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }] });
|
|
3352
3440
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheImageComponent, decorators: [{
|
|
3353
3441
|
type: i0.Component,
|
|
3354
3442
|
args: [{
|
|
@@ -6447,7 +6535,10 @@
|
|
|
6447
6535
|
return false;
|
|
6448
6536
|
},
|
|
6449
6537
|
isDisabled: function (editor) {
|
|
6450
|
-
|
|
6538
|
+
var _a;
|
|
6539
|
+
var contextService = (_a = editor === null || editor === void 0 ? void 0 : editor.injector) === null || _a === void 0 ? void 0 : _a.get(TheContextService);
|
|
6540
|
+
var richMedia = contextService.getOptions().theOptions.richMedia;
|
|
6541
|
+
if (richMedia && editor.selection) {
|
|
6451
6542
|
var disableGroup = [exports.ElementKinds.image];
|
|
6452
6543
|
var anchorBlock$1 = anchorBlock(editor);
|
|
6453
6544
|
return anchorBlock$1 && disableGroup.includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
|
|
@@ -8763,89 +8854,6 @@
|
|
|
8763
8854
|
type: i0.Injectable
|
|
8764
8855
|
}], ctorParameters: function () { return []; } });
|
|
8765
8856
|
|
|
8766
|
-
/** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
|
|
8767
|
-
function coercePixelsFromCssValue(cssValue) {
|
|
8768
|
-
var match = cssValue.match(/(\d+)px/);
|
|
8769
|
-
if (match) {
|
|
8770
|
-
return Number(match[1]);
|
|
8771
|
-
}
|
|
8772
|
-
}
|
|
8773
|
-
function getElementWidth(element) {
|
|
8774
|
-
// Optimization: Check style.width first as we probably set it already before reading
|
|
8775
|
-
// offsetWidth which triggers layout.
|
|
8776
|
-
return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
|
|
8777
|
-
}
|
|
8778
|
-
function getElementHeight(element) {
|
|
8779
|
-
return Math.round(element.getBoundingClientRect().height);
|
|
8780
|
-
}
|
|
8781
|
-
function getColsTotalWidth(cols) {
|
|
8782
|
-
return cols.reduce(function (total, col) {
|
|
8783
|
-
return total + getElementWidth(col);
|
|
8784
|
-
}, 0);
|
|
8785
|
-
}
|
|
8786
|
-
function getRowsTotalHeight(rows) {
|
|
8787
|
-
return rows.reduce(function (total, row) {
|
|
8788
|
-
return total + getElementHeight(row);
|
|
8789
|
-
}, 0);
|
|
8790
|
-
}
|
|
8791
|
-
function useElementStyle(el, element) {
|
|
8792
|
-
if (element.align) {
|
|
8793
|
-
el.style.textAlign = element.align || exports.Alignment.left;
|
|
8794
|
-
}
|
|
8795
|
-
if (element.textIndent) {
|
|
8796
|
-
el.style.textIndent = element.textIndent + 'em';
|
|
8797
|
-
}
|
|
8798
|
-
if (element.verticalAlign) {
|
|
8799
|
-
el.style.verticalAlign = element.verticalAlign;
|
|
8800
|
-
}
|
|
8801
|
-
}
|
|
8802
|
-
function getElementClassByPrefix(el, prefix) {
|
|
8803
|
-
var matchClass = null;
|
|
8804
|
-
el.classList.forEach(function (value, key) {
|
|
8805
|
-
if (value.includes(prefix)) {
|
|
8806
|
-
matchClass = value;
|
|
8807
|
-
}
|
|
8808
|
-
});
|
|
8809
|
-
return matchClass;
|
|
8810
|
-
}
|
|
8811
|
-
function findRelativeElementByPoint(editor, x, y, mode) {
|
|
8812
|
-
var editableElement = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
8813
|
-
var rectEditable = editableElement.getBoundingClientRect();
|
|
8814
|
-
if (x > rectEditable.x && x < rectEditable.x + rectEditable.width) {
|
|
8815
|
-
var centerX = rectEditable.x + rectEditable.width / 2;
|
|
8816
|
-
var relativeElement = document.elementFromPoint(mode === 'highest' ? centerX : x, y);
|
|
8817
|
-
return relativeElement;
|
|
8818
|
-
}
|
|
8819
|
-
return null;
|
|
8820
|
-
}
|
|
8821
|
-
function findNodeEntryByPoint(editor, x, y, mode) {
|
|
8822
|
-
var editableElement = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
8823
|
-
var rootElement = null;
|
|
8824
|
-
var relativeElement = findRelativeElementByPoint(editor, x, y, mode);
|
|
8825
|
-
// 获取最顶层的DOM
|
|
8826
|
-
if (mode === 'highest') {
|
|
8827
|
-
while (relativeElement && editableElement.contains(relativeElement)) {
|
|
8828
|
-
relativeElement = relativeElement.closest('[data-slate-node="element"]');
|
|
8829
|
-
if (relativeElement) {
|
|
8830
|
-
rootElement = relativeElement;
|
|
8831
|
-
relativeElement = relativeElement.parentElement;
|
|
8832
|
-
}
|
|
8833
|
-
}
|
|
8834
|
-
}
|
|
8835
|
-
if (!mode) {
|
|
8836
|
-
if (relativeElement && editableElement.contains(relativeElement)) {
|
|
8837
|
-
relativeElement = relativeElement.closest('[data-slate-node="element"]');
|
|
8838
|
-
rootElement = relativeElement;
|
|
8839
|
-
}
|
|
8840
|
-
}
|
|
8841
|
-
if (rootElement) {
|
|
8842
|
-
var node = i1.AngularEditor.toSlateNode(editor, rootElement);
|
|
8843
|
-
var path = i1.AngularEditor.findPath(editor, node);
|
|
8844
|
-
return [node, path];
|
|
8845
|
-
}
|
|
8846
|
-
return null;
|
|
8847
|
-
}
|
|
8848
|
-
|
|
8849
8857
|
function splitCell(editor) {
|
|
8850
8858
|
var opts = new TableOptions$1();
|
|
8851
8859
|
var anchor = editor.selection.anchor;
|
|
@@ -13342,359 +13350,6 @@
|
|
|
13342
13350
|
args: ['mousedown', ['$event']]
|
|
13343
13351
|
}] } });
|
|
13344
13352
|
|
|
13345
|
-
var getCurrentTarget = function (editor, event) {
|
|
13346
|
-
var editorElement = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
13347
|
-
var _a = editorElement.getBoundingClientRect(), left = _a.left, right = _a.right;
|
|
13348
|
-
var _b = window.getComputedStyle(editorElement, null), paddingLeft = _b.paddingLeft, paddingRight = _b.paddingRight;
|
|
13349
|
-
var paddingLeftPixels = coercePixelsFromCssValue(paddingLeft);
|
|
13350
|
-
var paddingRightPixels = coercePixelsFromCssValue(paddingRight);
|
|
13351
|
-
var x = event.x;
|
|
13352
|
-
if (event.x <= left + paddingLeftPixels || event.x >= right - paddingRightPixels) {
|
|
13353
|
-
x = left + paddingLeftPixels;
|
|
13354
|
-
}
|
|
13355
|
-
var nodeEntry = findNodeEntryByPoint(editor, x, event.y);
|
|
13356
|
-
if (nodeEntry) {
|
|
13357
|
-
return TheEditor.toDOMNode(editor, nodeEntry[0]);
|
|
13358
|
-
}
|
|
13359
|
-
};
|
|
13360
|
-
|
|
13361
|
-
var getHoverDirection = function (editor, event) {
|
|
13362
|
-
var rootNode = getCurrentTarget(editor, event);
|
|
13363
|
-
if (rootNode) {
|
|
13364
|
-
var _a = rootNode.getBoundingClientRect(), top = _a.top, bottom = _a.bottom;
|
|
13365
|
-
var middleHeight = (bottom - top) / 2;
|
|
13366
|
-
if (top + middleHeight > event.clientY) {
|
|
13367
|
-
return 'top';
|
|
13368
|
-
}
|
|
13369
|
-
return 'bottom';
|
|
13370
|
-
}
|
|
13371
|
-
};
|
|
13372
|
-
|
|
13373
|
-
var removeDropThumbLine = function (editor) {
|
|
13374
|
-
var element = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
13375
|
-
var dropThumbLine = element.querySelector('.' + DROP_THUMB_LINE);
|
|
13376
|
-
if (dropThumbLine) {
|
|
13377
|
-
dropThumbLine.remove();
|
|
13378
|
-
}
|
|
13379
|
-
};
|
|
13380
|
-
|
|
13381
|
-
var moveDragNode = function (editor, dragNode, event) {
|
|
13382
|
-
event.stopPropagation();
|
|
13383
|
-
var element = i1.EDITOR_TO_ELEMENT.get(editor);
|
|
13384
|
-
var dropThumbLine = element.querySelector('.' + DROP_THUMB_LINE);
|
|
13385
|
-
var parentElement = dropThumbLine && dropThumbLine.parentNode;
|
|
13386
|
-
if (parentElement) {
|
|
13387
|
-
var node = TheEditor.toSlateNode(editor, parentElement);
|
|
13388
|
-
var dropPath_1 = node && TheEditor.findPath(editor, node);
|
|
13389
|
-
if (dropPath_1.length) {
|
|
13390
|
-
var dragPath_1 = dragNode.path;
|
|
13391
|
-
var before = slate.Path.isBefore(dragPath_1, dropPath_1) && slate.Path.isSibling(dragPath_1, dropPath_1);
|
|
13392
|
-
dropPath_1 = before ? dropPath_1 : slate.Path.next(dropPath_1);
|
|
13393
|
-
if (dropPath_1.length) {
|
|
13394
|
-
slate.Editor.withoutNormalizing(editor, function () {
|
|
13395
|
-
slate.Transforms.moveNodes(editor, {
|
|
13396
|
-
at: dragPath_1,
|
|
13397
|
-
to: dropPath_1
|
|
13398
|
-
});
|
|
13399
|
-
});
|
|
13400
|
-
}
|
|
13401
|
-
}
|
|
13402
|
-
}
|
|
13403
|
-
removeDropThumbLine(editor);
|
|
13404
|
-
};
|
|
13405
|
-
|
|
13406
|
-
var isValidDrag = function (editor, dragNode, currentTarget) {
|
|
13407
|
-
var _a;
|
|
13408
|
-
var node = TheEditor.toSlateNode(editor, currentTarget);
|
|
13409
|
-
var dropPath = TheEditor.findPath(editor, node);
|
|
13410
|
-
var dragPath = TheEditor.findPath(editor, dragNode);
|
|
13411
|
-
if (dragPath[0] === dropPath[0] && dropPath.length > 1) {
|
|
13412
|
-
// 阻止list元素拖入自身
|
|
13413
|
-
return false;
|
|
13414
|
-
}
|
|
13415
|
-
var allElementOptions = DefaultElementOptions;
|
|
13416
|
-
if ((_a = editor.extraElementOptions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
13417
|
-
var extraInfo = mergeElementOptions(editor.extraElementOptions);
|
|
13418
|
-
allElementOptions = Object.values(extraInfo);
|
|
13419
|
-
}
|
|
13420
|
-
var types = allElementOptions.map(function (item) { return item.type; });
|
|
13421
|
-
if (types.indexOf(node.type) > -1 && allElementOptions[types.indexOf(node.type)].isSecondaryContainer) {
|
|
13422
|
-
// 阻止向table-celld等二级容器中拖入
|
|
13423
|
-
return false;
|
|
13424
|
-
}
|
|
13425
|
-
var containerParent = slate.Editor.above(editor, {
|
|
13426
|
-
at: dropPath,
|
|
13427
|
-
mode: 'lowest',
|
|
13428
|
-
match: function (node) {
|
|
13429
|
-
return node && node.type && types.includes(node.type);
|
|
13430
|
-
}
|
|
13431
|
-
});
|
|
13432
|
-
if (containerParent) {
|
|
13433
|
-
var inValidChildrenTypes = allElementOptions.find(function (item) { return item.type === containerParent[0].type; }).inValidChildrenTypes;
|
|
13434
|
-
if (inValidChildrenTypes.includes(dragNode.type)) {
|
|
13435
|
-
return false;
|
|
13436
|
-
}
|
|
13437
|
-
}
|
|
13438
|
-
return true;
|
|
13439
|
-
};
|
|
13440
|
-
|
|
13441
|
-
var SNAPSHOT_PADDING_WIDTH = 5;
|
|
13442
|
-
var SNAPSHOT_LIMI_HEIGHT = 70;
|
|
13443
|
-
var DRAG_ICON_SIZE = 24;
|
|
13444
|
-
var DRAG_ICON_OFFSET = 5;
|
|
13445
|
-
var TheDndComponent = /** @class */ (function () {
|
|
13446
|
-
function TheDndComponent(renderer, elementRef, ngZone, cdr) {
|
|
13447
|
-
this.renderer = renderer;
|
|
13448
|
-
this.elementRef = elementRef;
|
|
13449
|
-
this.ngZone = ngZone;
|
|
13450
|
-
this.cdr = cdr;
|
|
13451
|
-
this.isDraging = false;
|
|
13452
|
-
this.destroy$ = new rxjs.Subject();
|
|
13453
|
-
this.dragChange = new i0.EventEmitter();
|
|
13454
|
-
this.dropThumbLine = document.createElement('div');
|
|
13455
|
-
this.dropThumbLine.className = DROP_THUMB_LINE;
|
|
13456
|
-
}
|
|
13457
|
-
Object.defineProperty(TheDndComponent.prototype, "nativeElement", {
|
|
13458
|
-
get: function () {
|
|
13459
|
-
return this.elementRef.nativeElement;
|
|
13460
|
-
},
|
|
13461
|
-
enumerable: false,
|
|
13462
|
-
configurable: true
|
|
13463
|
-
});
|
|
13464
|
-
Object.defineProperty(TheDndComponent.prototype, "editableElement", {
|
|
13465
|
-
get: function () {
|
|
13466
|
-
return this.editor && i1.EDITOR_TO_ELEMENT.get(this.editor);
|
|
13467
|
-
},
|
|
13468
|
-
enumerable: false,
|
|
13469
|
-
configurable: true
|
|
13470
|
-
});
|
|
13471
|
-
TheDndComponent.prototype.ngAfterViewInit = function () {
|
|
13472
|
-
var _this = this;
|
|
13473
|
-
var contextService = this.editor.injector.get(TheContextService);
|
|
13474
|
-
this.ngZone.runOutsideAngular(function () {
|
|
13475
|
-
rxjs.merge(rxjs.fromEvent(_this.editableElement, "mousemove"), rxjs.fromEvent(_this.editableElement, "mouseleave"))
|
|
13476
|
-
.pipe(operators.takeUntil(_this.destroy$), operators.filter(function () {
|
|
13477
|
-
return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
|
|
13478
|
-
}))
|
|
13479
|
-
.subscribe(function (e) { return _this.setDragIcon(e); });
|
|
13480
|
-
rxjs.fromEvent(document, "drop")
|
|
13481
|
-
.pipe(operators.takeUntil(_this.destroy$), operators.filter(function () {
|
|
13482
|
-
return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
|
|
13483
|
-
}))
|
|
13484
|
-
.subscribe(function (e) { return _this.onDrop(e); });
|
|
13485
|
-
rxjs.fromEvent(document, "dragover")
|
|
13486
|
-
.pipe(operators.takeUntil(_this.destroy$), operators.filter(function () {
|
|
13487
|
-
return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
|
|
13488
|
-
}))
|
|
13489
|
-
.subscribe(function (e) { return _this.onDragover(e); });
|
|
13490
|
-
rxjs.fromEvent(document, "scroll")
|
|
13491
|
-
.pipe(operators.takeUntil(_this.destroy$), operators.filter(function () {
|
|
13492
|
-
return !contextService.getOptions().theOptions.readonly && contextService.getOptions().theOptions.dragAndDrop;
|
|
13493
|
-
}))
|
|
13494
|
-
.subscribe(function (e) {
|
|
13495
|
-
e.preventDefault();
|
|
13496
|
-
var scrollPosition = window.scrollY;
|
|
13497
|
-
if (!_this.isScrolling && _this.isDraging) {
|
|
13498
|
-
window.requestAnimationFrame(function () {
|
|
13499
|
-
if (_this.editableTop) {
|
|
13500
|
-
// 滚动过程中,通过设置父级元素来设置snapshot位置
|
|
13501
|
-
_this.updateDndContainerPosition(null, scrollPosition + _this.editableTop + 'px');
|
|
13502
|
-
}
|
|
13503
|
-
_this.isScrolling = false;
|
|
13504
|
-
});
|
|
13505
|
-
_this.isScrolling = true;
|
|
13506
|
-
}
|
|
13507
|
-
});
|
|
13508
|
-
});
|
|
13509
|
-
this.setVisibility(false);
|
|
13510
|
-
this.valueChangeHandle();
|
|
13511
|
-
};
|
|
13512
|
-
TheDndComponent.prototype.valueChangeHandle = function () {
|
|
13513
|
-
var _this = this;
|
|
13514
|
-
var onChange = this.editor.onChange;
|
|
13515
|
-
this.editor.onChange = function () {
|
|
13516
|
-
var ops = _this.editor.operations;
|
|
13517
|
-
var skip = ops.length === 1 && slate.Operation.isSelectionOperation(ops[0]);
|
|
13518
|
-
if (!skip) {
|
|
13519
|
-
_this.setVisibility(false);
|
|
13520
|
-
}
|
|
13521
|
-
onChange();
|
|
13522
|
-
};
|
|
13523
|
-
};
|
|
13524
|
-
TheDndComponent.prototype.updateDndContainerPosition = function (left, top) {
|
|
13525
|
-
var element = this.elementRef.nativeElement;
|
|
13526
|
-
var parentElement = element.parentElement;
|
|
13527
|
-
top && this.renderer.setStyle(parentElement, 'top', top);
|
|
13528
|
-
left && this.renderer.setStyle(parentElement, 'left', left);
|
|
13529
|
-
};
|
|
13530
|
-
TheDndComponent.prototype.getEditableTop = function (event) {
|
|
13531
|
-
var offsetHeight = document.documentElement.offsetHeight;
|
|
13532
|
-
var height = this.editableElement.getBoundingClientRect().height;
|
|
13533
|
-
if (event.clientY < this.dragElementHeight) {
|
|
13534
|
-
this.editableTop = -this.editableElement.offsetTop;
|
|
13535
|
-
return;
|
|
13536
|
-
}
|
|
13537
|
-
if (height > event.pageY && event.clientY + this.dragElementHeight >= offsetHeight) {
|
|
13538
|
-
this.editableTop = event.clientY - this.editableElement.offsetTop;
|
|
13539
|
-
return;
|
|
13540
|
-
}
|
|
13541
|
-
this.editableTop = null;
|
|
13542
|
-
};
|
|
13543
|
-
TheDndComponent.prototype.onDragStart = function (event) {
|
|
13544
|
-
this.isDraging = true;
|
|
13545
|
-
this.dragChange.emit(this.isDraging);
|
|
13546
|
-
this.dragSnapshotContent = document.querySelector('.drag-snapshot-container');
|
|
13547
|
-
this.dragSnapshotContent.className = 'the-editor-typo drag-snapshot-container';
|
|
13548
|
-
this.dragSnapshotContent.appendChild(this.dragElement.cloneNode(true));
|
|
13549
|
-
this.dragElement.style.opacity = '0.3';
|
|
13550
|
-
};
|
|
13551
|
-
TheDndComponent.prototype.onDragEnd = function (event) {
|
|
13552
|
-
this.dragElement.style.opacity = '';
|
|
13553
|
-
this.isDraging = false;
|
|
13554
|
-
this.setVisibility(false);
|
|
13555
|
-
this.resetDragSnapshotContent();
|
|
13556
|
-
this.dragChange.emit(this.isDraging);
|
|
13557
|
-
};
|
|
13558
|
-
TheDndComponent.prototype.onDrop = function (event) {
|
|
13559
|
-
event.preventDefault();
|
|
13560
|
-
if (this.isDraging) {
|
|
13561
|
-
moveDragNode(this.editor, this.dragNode, event);
|
|
13562
|
-
}
|
|
13563
|
-
};
|
|
13564
|
-
TheDndComponent.prototype.onDragover = function (event) {
|
|
13565
|
-
event.preventDefault();
|
|
13566
|
-
if (this.isDraging && !this.isScrolling) {
|
|
13567
|
-
this.getEditableTop(event);
|
|
13568
|
-
var offsetWidth = document.documentElement.offsetWidth;
|
|
13569
|
-
var _b = this.editableElement.getBoundingClientRect(), editorLeft = _b.left, editorTop = _b.top, height = _b.height;
|
|
13570
|
-
var top = 0;
|
|
13571
|
-
var left = 0;
|
|
13572
|
-
if (editorLeft > 0) {
|
|
13573
|
-
if (event.clientX + this.dragElementWidth / 2 > offsetWidth) {
|
|
13574
|
-
left = event.pageX - editorLeft - this.elementRef.nativeElement.offsetWidth;
|
|
13575
|
-
}
|
|
13576
|
-
else {
|
|
13577
|
-
left = Math.max(event.pageX - editorLeft, -editorLeft) + 10;
|
|
13578
|
-
}
|
|
13579
|
-
}
|
|
13580
|
-
var paddingTop = 0; // paddingTop: 编辑器距离顶部的距离
|
|
13581
|
-
if (editorTop >= 0) {
|
|
13582
|
-
// 无滚动情况下
|
|
13583
|
-
top = event.clientY - this.editableElement.offsetTop;
|
|
13584
|
-
paddingTop = editorTop - this.editableElement.offsetTop;
|
|
13585
|
-
}
|
|
13586
|
-
else {
|
|
13587
|
-
// 有滚动距离
|
|
13588
|
-
top = Math.abs(editorTop) + event.clientY; // 滚动距离 + 鼠标clientY
|
|
13589
|
-
paddingTop = event.pageY - this.editableElement.offsetTop - top;
|
|
13590
|
-
// 防止底部出现滚动条
|
|
13591
|
-
if (paddingTop < height - top) {
|
|
13592
|
-
top = top + paddingTop;
|
|
13593
|
-
}
|
|
13594
|
-
}
|
|
13595
|
-
this.updateDndContainerPosition(left + 'px', top + 'px');
|
|
13596
|
-
this.setSnapshotStyle(event);
|
|
13597
|
-
this.setDropThumbLine(event);
|
|
13598
|
-
}
|
|
13599
|
-
};
|
|
13600
|
-
TheDndComponent.prototype.setDropThumbLine = function (event) {
|
|
13601
|
-
var _a;
|
|
13602
|
-
var element = getCurrentTarget(this.editor, event);
|
|
13603
|
-
var direction = getHoverDirection(this.editor, event);
|
|
13604
|
-
if (element) {
|
|
13605
|
-
if (direction && direction === 'top') {
|
|
13606
|
-
element = (_a = element.previousElementSibling) === null || _a === void 0 ? void 0 : _a.querySelector('[data-slate-node="element"]');
|
|
13607
|
-
}
|
|
13608
|
-
if (element && isValidDrag(this.editor, this.dragNode.node, element)) {
|
|
13609
|
-
element.appendChild(this.dropThumbLine);
|
|
13610
|
-
}
|
|
13611
|
-
}
|
|
13612
|
-
};
|
|
13613
|
-
TheDndComponent.prototype.setDragIcon = function (event) {
|
|
13614
|
-
if (!this.isDraging) {
|
|
13615
|
-
var nodeEntry = findNodeEntryByPoint(this.editor, event.x, event.y, 'highest');
|
|
13616
|
-
if (nodeEntry && !slate.Editor.isEmpty(this.editor, nodeEntry[0])) {
|
|
13617
|
-
var rootNode = i1.AngularEditor.toDOMNode(this.editor, nodeEntry[0]);
|
|
13618
|
-
this.dragNode = {
|
|
13619
|
-
node: nodeEntry[0],
|
|
13620
|
-
path: nodeEntry[1]
|
|
13621
|
-
};
|
|
13622
|
-
this.dragElement = rootNode;
|
|
13623
|
-
var lineHeight = coercePixelsFromCssValue(window.getComputedStyle(rootNode)['lineHeight']);
|
|
13624
|
-
var offsetTop = rootNode.offsetTop + rootNode.offsetParent.offsetTop + (lineHeight - DRAG_ICON_SIZE) / 2;
|
|
13625
|
-
var offsetLeft = rootNode.offsetLeft + rootNode.offsetParent.offsetLeft;
|
|
13626
|
-
this.updateDndContainerPosition(offsetLeft - DRAG_ICON_SIZE - DRAG_ICON_OFFSET + 'px', offsetTop + 'px');
|
|
13627
|
-
this.setVisibility(true);
|
|
13628
|
-
}
|
|
13629
|
-
else {
|
|
13630
|
-
this.setVisibility(false);
|
|
13631
|
-
}
|
|
13632
|
-
}
|
|
13633
|
-
};
|
|
13634
|
-
TheDndComponent.prototype.setSnapshotStyle = function (event) {
|
|
13635
|
-
var _b = this.dragElement.getBoundingClientRect(), width = _b.width, height = _b.height;
|
|
13636
|
-
this.dragElementHeight = height;
|
|
13637
|
-
this.dragElementWidth = width;
|
|
13638
|
-
var dragSnapshotContentStyle = "visibility: visible; width: " + (width + SNAPSHOT_PADDING_WIDTH * 2) + "px;";
|
|
13639
|
-
if (height > SNAPSHOT_LIMI_HEIGHT) {
|
|
13640
|
-
dragSnapshotContentStyle = dragSnapshotContentStyle + 'transform: scale(0.45);';
|
|
13641
|
-
this.dragElementHeight = this.dragElementHeight * 0.45;
|
|
13642
|
-
this.dragElementWidth = this.dragElementWidth * 0.45;
|
|
13643
|
-
}
|
|
13644
|
-
var snapshotTop = 0;
|
|
13645
|
-
var snapshotLeft = 0;
|
|
13646
|
-
// 上下移动:超出屏幕高度,重新设置snapshot的位置
|
|
13647
|
-
if (event.clientY + this.dragElementHeight > document.documentElement.offsetHeight) {
|
|
13648
|
-
snapshotTop = this.dragElementHeight;
|
|
13649
|
-
}
|
|
13650
|
-
else {
|
|
13651
|
-
snapshotTop = 0;
|
|
13652
|
-
}
|
|
13653
|
-
// 左右移动:超出屏幕宽度,重新设置snapshot的位置
|
|
13654
|
-
if (event.clientX + this.dragElementWidth / 2 > document.documentElement.offsetWidth) {
|
|
13655
|
-
snapshotLeft = this.dragElementWidth;
|
|
13656
|
-
}
|
|
13657
|
-
else {
|
|
13658
|
-
snapshotLeft = 0;
|
|
13659
|
-
}
|
|
13660
|
-
dragSnapshotContentStyle = dragSnapshotContentStyle + ("top: " + -snapshotTop + "px; left: " + -snapshotLeft + "px;");
|
|
13661
|
-
this.dragSnapshotContent.setAttribute('style', dragSnapshotContentStyle);
|
|
13662
|
-
};
|
|
13663
|
-
TheDndComponent.prototype.resetDragSnapshotContent = function () {
|
|
13664
|
-
this.dragSnapshotContent.className = 'drag-snapshot-container';
|
|
13665
|
-
this.dragSnapshotContent.setAttribute('style', '');
|
|
13666
|
-
this.dragSnapshotContent.innerHTML = '';
|
|
13667
|
-
};
|
|
13668
|
-
TheDndComponent.prototype.setVisibility = function (visible) {
|
|
13669
|
-
if (visible === void 0) { visible = true; }
|
|
13670
|
-
this.nativeElement.parentNode.style.visibility = visible ? 'visible' : 'hidden';
|
|
13671
|
-
};
|
|
13672
|
-
TheDndComponent.prototype.ngOnDestroy = function () {
|
|
13673
|
-
this.destroy$.next();
|
|
13674
|
-
this.destroy$.complete();
|
|
13675
|
-
};
|
|
13676
|
-
return TheDndComponent;
|
|
13677
|
-
}());
|
|
13678
|
-
TheDndComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheDndComponent, deps: [{ token: i0__namespace.Renderer2 }, { token: i0__namespace.ElementRef }, { token: i0__namespace.NgZone }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
13679
|
-
TheDndComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }], directives: [{ type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
13680
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheDndComponent, decorators: [{
|
|
13681
|
-
type: i0.Component,
|
|
13682
|
-
args: [{
|
|
13683
|
-
selector: '[theDnd]',
|
|
13684
|
-
templateUrl: './dnd.component.html',
|
|
13685
|
-
host: {
|
|
13686
|
-
class: 'the-drag-drop'
|
|
13687
|
-
}
|
|
13688
|
-
}]
|
|
13689
|
-
}], ctorParameters: function () { return [{ type: i0__namespace.Renderer2 }, { type: i0__namespace.ElementRef }, { type: i0__namespace.NgZone }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { editor: [{
|
|
13690
|
-
type: i0.Input
|
|
13691
|
-
}], dragChange: [{
|
|
13692
|
-
type: i0.Output
|
|
13693
|
-
}], content: [{
|
|
13694
|
-
type: i0.ViewChild,
|
|
13695
|
-
args: ['content', { static: false }]
|
|
13696
|
-
}] } });
|
|
13697
|
-
|
|
13698
13353
|
var ElementStylePipe = /** @class */ (function () {
|
|
13699
13354
|
function ElementStylePipe() {
|
|
13700
13355
|
}
|
|
@@ -13908,16 +13563,10 @@
|
|
|
13908
13563
|
_this.onSlaDragStart = function (event) { };
|
|
13909
13564
|
_this.onSlaDragOver = function (event) { };
|
|
13910
13565
|
_this.onDrop = function (event) {
|
|
13911
|
-
if (_this.isDraging) {
|
|
13912
|
-
event.preventDefault();
|
|
13913
|
-
}
|
|
13914
13566
|
_this.theOnDOMEvent.emit({
|
|
13915
13567
|
nativeEvent: event
|
|
13916
13568
|
});
|
|
13917
13569
|
};
|
|
13918
|
-
_this.onDragChange = function (isDraging) {
|
|
13919
|
-
_this.isDraging = isDraging;
|
|
13920
|
-
};
|
|
13921
13570
|
return _this;
|
|
13922
13571
|
}
|
|
13923
13572
|
Object.defineProperty(TheEditorComponent.prototype, "theGlobalToolbarInstance", {
|
|
@@ -14108,8 +13757,17 @@
|
|
|
14108
13757
|
if (event.target === editableElement) {
|
|
14109
13758
|
var rectEditable = editableElement.getBoundingClientRect();
|
|
14110
13759
|
var centerX = rectEditable.x + rectEditable.width / 2;
|
|
14111
|
-
var
|
|
13760
|
+
var _g = window.getComputedStyle(editableElement, null), paddingLeft = _g.paddingLeft, paddingRight = _g.paddingRight;
|
|
13761
|
+
var paddingLeftPixels = coercePixelsFromCssValue(paddingLeft);
|
|
13762
|
+
var paddingRightPixels = coercePixelsFromCssValue(paddingRight);
|
|
13763
|
+
var fakeLeftX = rectEditable.x + paddingLeftPixels + 50;
|
|
13764
|
+
var fakeRightX = rectEditable.right - paddingRightPixels - 50;
|
|
13765
|
+
var relativeElement = document.elementFromPoint(fakeLeftX, event.y);
|
|
14112
13766
|
var relativeBlockCardElement = relativeElement.closest('.slate-block-card');
|
|
13767
|
+
if (!relativeBlockCardElement) {
|
|
13768
|
+
relativeElement = document.elementFromPoint(fakeRightX, event.y);
|
|
13769
|
+
relativeBlockCardElement = relativeElement.closest('.slate-block-card');
|
|
13770
|
+
}
|
|
14113
13771
|
if (relativeBlockCardElement) {
|
|
14114
13772
|
var blockCardEntry = i1.AngularEditor.toSlateCardEntry(this.editor, relativeBlockCardElement.firstElementChild);
|
|
14115
13773
|
if (blockCardEntry && blockCardEntry[1]) {
|
|
@@ -14178,7 +13836,7 @@
|
|
|
14178
13836
|
useExisting: i0.forwardRef(function () { return TheEditorComponent; }),
|
|
14179
13837
|
multi: true
|
|
14180
13838
|
}
|
|
14181
|
-
], 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__namespace, 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 <
|
|
13839
|
+
], 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__namespace, 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__namespace.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__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4__namespace$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4__namespace$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
|
|
14182
13840
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheEditorComponent, decorators: [{
|
|
14183
13841
|
type: i0.Component,
|
|
14184
13842
|
args: [{
|
|
@@ -14440,8 +14098,7 @@
|
|
|
14440
14098
|
TheTableComponent,
|
|
14441
14099
|
TheTableRowComponent,
|
|
14442
14100
|
TheTdComponent,
|
|
14443
|
-
TheInlineCodeComponent
|
|
14444
|
-
TheDndComponent
|
|
14101
|
+
TheInlineCodeComponent
|
|
14445
14102
|
];
|
|
14446
14103
|
var PIPES = [ElementStylePipe, ElementClassPipe];
|
|
14447
14104
|
var TheEditorModule = /** @class */ (function () {
|
|
@@ -14485,8 +14142,7 @@
|
|
|
14485
14142
|
TheTableComponent,
|
|
14486
14143
|
TheTableRowComponent,
|
|
14487
14144
|
TheTdComponent,
|
|
14488
|
-
TheInlineCodeComponent,
|
|
14489
|
-
TheDndComponent], imports: [i10.CommonModule, i1.SlateModule, i4$1.FormsModule, i4.ThyIconModule,
|
|
14145
|
+
TheInlineCodeComponent], imports: [i10.CommonModule, i1.SlateModule, i4$1.FormsModule, i4.ThyIconModule,
|
|
14490
14146
|
avatar.ThyAvatarModule,
|
|
14491
14147
|
i3.ThyNavModule,
|
|
14492
14148
|
i2$1.ThyFormModule,
|
|
@@ -14551,7 +14207,6 @@
|
|
|
14551
14207
|
exports.ColorEditor = ColorEditor;
|
|
14552
14208
|
exports.DEFAULT_LANGUAGE = DEFAULT_LANGUAGE;
|
|
14553
14209
|
exports.DEFAULT_SCROLL_CONTAINER = DEFAULT_SCROLL_CONTAINER;
|
|
14554
|
-
exports.DROP_THUMB_LINE = DROP_THUMB_LINE;
|
|
14555
14210
|
exports.DefaultElementOptions = DefaultElementOptions;
|
|
14556
14211
|
exports.DefaultGlobalToolbarDefinition = DefaultGlobalToolbarDefinition;
|
|
14557
14212
|
exports.DefaultInlineToolbarDefinition = DefaultInlineToolbarDefinition;
|
|
@@ -14606,15 +14261,25 @@
|
|
|
14606
14261
|
exports.VOID_BLOCK_TYPES = VOID_BLOCK_TYPES;
|
|
14607
14262
|
exports.VerticalAlignEditor = VerticalAlignEditor;
|
|
14608
14263
|
exports.ZERO_WIDTH_CHAR = ZERO_WIDTH_CHAR;
|
|
14264
|
+
exports.coercePixelsFromCssValue = coercePixelsFromCssValue;
|
|
14609
14265
|
exports.createEmptyParagraph = createEmptyParagraph;
|
|
14610
14266
|
exports.dataDeserialize = dataDeserialize;
|
|
14611
14267
|
exports.dataSerializing = dataSerializing;
|
|
14268
|
+
exports.findNodeEntryByPoint = findNodeEntryByPoint;
|
|
14269
|
+
exports.findRelativeElementByPoint = findRelativeElementByPoint;
|
|
14270
|
+
exports.getColsTotalWidth = getColsTotalWidth;
|
|
14271
|
+
exports.getElementClassByPrefix = getElementClassByPrefix;
|
|
14272
|
+
exports.getElementHeight = getElementHeight;
|
|
14273
|
+
exports.getElementWidth = getElementWidth;
|
|
14274
|
+
exports.getRowsTotalHeight = getRowsTotalHeight;
|
|
14612
14275
|
exports.getToolbarClass = getToolbarClass;
|
|
14613
14276
|
exports.htmlToTheia = htmlToTheia;
|
|
14614
14277
|
exports.inValidTypes = inValidTypes;
|
|
14615
14278
|
exports.isCleanEmptyParagraph = isCleanEmptyParagraph;
|
|
14279
|
+
exports.mergeElementOptions = mergeElementOptions;
|
|
14616
14280
|
exports.plainToTheia = plainToTheia;
|
|
14617
14281
|
exports.toolbarCompose = toolbarCompose;
|
|
14282
|
+
exports.useElementStyle = useElementStyle;
|
|
14618
14283
|
exports.withTheEditor = withTheEditor;
|
|
14619
14284
|
|
|
14620
14285
|
Object.defineProperty(exports, '__esModule', { value: true });
|