@worktile/theia 3.0.0-next.6 → 3.0.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.
- package/bundles/worktile-theia.umd.js +54 -76
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/esm2015/core/with-theia.js +2 -2
- package/esm2015/plugins/table/components/table.component.js +5 -4
- package/esm2015/plugins/todo-item/todo-item.component.js +8 -2
- package/esm2015/queries/get-insert-elements-path.js +23 -52
- package/esm2015/transforms/insert-elements.js +2 -2
- package/fesm2015/worktile-theia.js +37 -57
- package/fesm2015/worktile-theia.js.map +1 -1
- package/package.json +1 -1
- package/plugins/table/components/table.component.d.ts +2 -2
- package/plugins/todo-item/todo-item.component.d.ts +1 -0
- package/queries/get-insert-elements-path.d.ts +5 -2
- package/styles/editor.scss +5 -0
|
@@ -19,11 +19,13 @@ import * as i5 from 'ngx-tethys/input';
|
|
|
19
19
|
import { ThyInputModule } from 'ngx-tethys/input';
|
|
20
20
|
import { TheiaConverter } from '@atinc/selene';
|
|
21
21
|
import * as _lodash from 'lodash';
|
|
22
|
-
import { isObject
|
|
22
|
+
import { isObject } from 'ngx-tethys/util';
|
|
23
23
|
import * as i2 from '@angular/cdk/overlay';
|
|
24
24
|
import { Overlay, OverlayModule } from '@angular/cdk/overlay';
|
|
25
25
|
import marked from 'marked';
|
|
26
26
|
import { __rest, __awaiter } from 'tslib';
|
|
27
|
+
import * as i1$6 from 'ngx-tethys';
|
|
28
|
+
import { isArray } from 'ngx-tethys';
|
|
27
29
|
import * as i1$2 from 'ngx-tethys/alert';
|
|
28
30
|
import { ThyAlertModule } from 'ngx-tethys/alert';
|
|
29
31
|
import { map, takeUntil, take, delay, startWith, distinctUntilChanged, skip, share, filter, mapTo, debounceTime, pairwise } from 'rxjs/operators';
|
|
@@ -52,7 +54,6 @@ import * as i2$2 from 'ngx-tethys/form';
|
|
|
52
54
|
import { ThyFormModule } from 'ngx-tethys/form';
|
|
53
55
|
import * as i5$3 from 'ngx-tethys/shared';
|
|
54
56
|
import { ThySharedModule } from 'ngx-tethys/shared';
|
|
55
|
-
import * as i1$6 from 'ngx-tethys';
|
|
56
57
|
import { coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
57
58
|
import { PortalInjector, ComponentPortal } from '@angular/cdk/portal';
|
|
58
59
|
import * as i1$7 from 'ngx-tethys/list';
|
|
@@ -1169,7 +1170,7 @@ const withTheia = (editor, plugins = []) => {
|
|
|
1169
1170
|
// withOverridesByKey
|
|
1170
1171
|
flattenDeepPlugins(e, plugins);
|
|
1171
1172
|
// mount pluginsByKey
|
|
1172
|
-
pluginsByKey(e, plugins);
|
|
1173
|
+
pluginsByKey(e, e.plugins);
|
|
1173
1174
|
// mount nestedStructureByKey
|
|
1174
1175
|
nestedStructureByKey(e, e.plugins);
|
|
1175
1176
|
// merge plugin to pluginByKey
|
|
@@ -1960,64 +1961,36 @@ const getInsertElementsPath = (editor, allowParentTypes) => {
|
|
|
1960
1961
|
return false;
|
|
1961
1962
|
const [, anchorBlockPath] = anchorBlockEntry(editor);
|
|
1962
1963
|
let currentNodePath = anchorBlockPath.slice(0, parentEntry[1].length + 1);
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
mode: 'lowest',
|
|
1969
|
-
at: parentEntry[1],
|
|
1970
|
-
match: (n) => n.type && !allowParentTypes.includes(n.type)
|
|
1971
|
-
});
|
|
1972
|
-
if (_illegalParentEntry) {
|
|
1973
|
-
const childType = editor.nestedStructureByKey[_illegalParentEntry[0].type];
|
|
1974
|
-
if (!childType) {
|
|
1975
|
-
illegalParentEntry = _illegalParentEntry;
|
|
1976
|
-
}
|
|
1977
|
-
if (allowParentTypes.includes(childType)) {
|
|
1978
|
-
const rootKey = findNestedStructureRootType(editor, _illegalParentEntry[0].type, '');
|
|
1979
|
-
parentEntry =
|
|
1980
|
-
parentEntry &&
|
|
1981
|
-
Editor.above(editor, {
|
|
1982
|
-
mode: 'lowest',
|
|
1983
|
-
at: parentEntry[1],
|
|
1984
|
-
match: (n) => n.type && n.type === rootKey
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
else {
|
|
1988
|
-
parentEntry = _illegalParentEntry;
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
else {
|
|
1992
|
-
break;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1964
|
+
const illegalParentEntry = Editor.above(editor, {
|
|
1965
|
+
mode: 'highest',
|
|
1966
|
+
at: parentEntry[1],
|
|
1967
|
+
match: (n) => n.type && !isAllowParentTypes(editor, n.type, allowParentTypes)
|
|
1968
|
+
});
|
|
1995
1969
|
// 获取不可插入节点的根层节点
|
|
1996
1970
|
if (illegalParentEntry) {
|
|
1997
|
-
const rootKey = findNestedStructureRootType(editor, illegalParentEntry[0].type, '');
|
|
1998
|
-
if (rootKey && illegalParentEntry[0].type !== rootKey) {
|
|
1999
|
-
illegalParentEntry = Editor.above(editor, {
|
|
2000
|
-
mode: 'lowest',
|
|
2001
|
-
at: parentEntry[1],
|
|
2002
|
-
match: (n) => n.type && n.type === rootKey
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
1971
|
currentNodePath = illegalParentEntry && illegalParentEntry[1];
|
|
2006
1972
|
}
|
|
2007
1973
|
return currentNodePath && Path.next(currentNodePath);
|
|
2008
1974
|
};
|
|
2009
|
-
|
|
2010
|
-
const
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
1975
|
+
const isAllowParentTypes = (editor, targetType, allowParentTypes) => {
|
|
1976
|
+
const existChildType = isNestedStructureParentType(editor, targetType);
|
|
1977
|
+
const leafType = existChildType && findNestedStructureLeafType(editor, targetType);
|
|
1978
|
+
return allowParentTypes.includes(targetType) || allowParentTypes.includes(leafType);
|
|
1979
|
+
};
|
|
1980
|
+
const isNestedStructureParentType = (editor, type) => {
|
|
1981
|
+
for (const key in editor.nestedStructureByKey) {
|
|
1982
|
+
if (key === type) {
|
|
1983
|
+
return true;
|
|
1984
|
+
}
|
|
2017
1985
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
1986
|
+
return false;
|
|
1987
|
+
};
|
|
1988
|
+
const findNestedStructureLeafType = (editor, target) => {
|
|
1989
|
+
let leafType = editor.nestedStructureByKey[target];
|
|
1990
|
+
while (leafType && editor.nestedStructureByKey[leafType]) {
|
|
1991
|
+
leafType = editor.nestedStructureByKey[leafType];
|
|
2020
1992
|
}
|
|
1993
|
+
return leafType;
|
|
2021
1994
|
};
|
|
2022
1995
|
|
|
2023
1996
|
const isContainNestedType = (editor, types) => {
|
|
@@ -4249,6 +4222,9 @@ class TheTodoItemComponent extends TheBaseElementComponent {
|
|
|
4249
4222
|
// 类名 the-temp-*: 临时解决因受portal影响样式问题,后期改回the-
|
|
4250
4223
|
this.checkItemClass = true;
|
|
4251
4224
|
}
|
|
4225
|
+
get checkItemSelectable() {
|
|
4226
|
+
return this.editableWithReadonly && this.readonly;
|
|
4227
|
+
}
|
|
4252
4228
|
get level() {
|
|
4253
4229
|
var _a;
|
|
4254
4230
|
return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
|
|
@@ -4268,7 +4244,7 @@ class TheTodoItemComponent extends TheBaseElementComponent {
|
|
|
4268
4244
|
}
|
|
4269
4245
|
}
|
|
4270
4246
|
TheTodoItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheTodoItemComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: TheContextService }], target: i0.ɵɵFactoryTarget.Component });
|
|
4271
|
-
TheTodoItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheTodoItemComponent, selector: "div[theTodoItem]", host: { properties: { "class.the-temp-check-item": "this.checkItemClass", "attr.the-level": "this.level" } }, usesInheritance: true, ngImport: i0, template: `
|
|
4247
|
+
TheTodoItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheTodoItemComponent, selector: "div[theTodoItem]", host: { properties: { "class.the-temp-check-item": "this.checkItemClass", "class.the-todo-item-selectable": "this.checkItemSelectable", "attr.the-level": "this.level" } }, usesInheritance: true, ngImport: i0, template: `
|
|
4272
4248
|
<span contenteditable="false" class="todo-item-status">
|
|
4273
4249
|
<input #checkbox type="checkbox" [checked]="element.checked" (click)="onCheck(checkbox.checked)" />
|
|
4274
4250
|
</span>
|
|
@@ -4288,6 +4264,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
4288
4264
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: TheContextService }]; }, propDecorators: { checkItemClass: [{
|
|
4289
4265
|
type: HostBinding,
|
|
4290
4266
|
args: ['class.the-temp-check-item']
|
|
4267
|
+
}], checkItemSelectable: [{
|
|
4268
|
+
type: HostBinding,
|
|
4269
|
+
args: ['class.the-todo-item-selectable']
|
|
4291
4270
|
}], level: [{
|
|
4292
4271
|
type: HostBinding,
|
|
4293
4272
|
args: ['attr.the-level']
|
|
@@ -9447,6 +9426,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
9447
9426
|
if (this.readonly)
|
|
9448
9427
|
return;
|
|
9449
9428
|
event.stopPropagation();
|
|
9429
|
+
event.preventDefault();
|
|
9450
9430
|
if (!this.isInTable) {
|
|
9451
9431
|
const path = TheEditor.findPath(this.editor, this.element);
|
|
9452
9432
|
Transforms.select(this.editor, path);
|
|
@@ -9506,10 +9486,10 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
9506
9486
|
});
|
|
9507
9487
|
});
|
|
9508
9488
|
}
|
|
9509
|
-
|
|
9489
|
+
trackByFnRowControls(index) {
|
|
9510
9490
|
return index;
|
|
9511
9491
|
}
|
|
9512
|
-
|
|
9492
|
+
trackByFnColControls(index) {
|
|
9513
9493
|
return index;
|
|
9514
9494
|
}
|
|
9515
9495
|
ngOnDestroy() {
|
|
@@ -9529,7 +9509,7 @@ TheTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
|
|
|
9529
9509
|
provide: TheTableToken,
|
|
9530
9510
|
useExisting: TheTableComponent
|
|
9531
9511
|
}
|
|
9532
|
-
], viewQueries: [{ propertyName: "tableWrapper", first: true, predicate: ["tableWrapper"], descendants: true, read: ElementRef, static: true }, { propertyName: "theTableElement", first: true, predicate: ["theTable"], descendants: true, read: ElementRef, static: true }, { propertyName: "tbodyElement", first: true, predicate: ["tbody"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<!-- \u7C7B\u540D the-temp-*: \u4E34\u65F6\u89E3\u51B3\u56E0\u53D7portal\u5F71\u54CD\u8868\u683C\u6837\u5F0F\u95EE\u9898\uFF0C\u540E\u671F\u6539\u56DEthe-* -->\n<div\n class=\"the-temp-table-container\"\n theColumnResize\n [ngClass]=\"{\n 'the-temp-table-with-controls': isInTable,\n 'the-temp-numbered-column-container': element?.options?.numberedColumn,\n 'the-temp-table-selection-hide': tableStore.isCellSelecting || tableStore.isRightClicking\n }\"\n>\n <div\n class=\"the-temp-table-row-controls-wrapper\"\n [ngClass]=\"{\n 'the-temp-table-focus': isInTable\n }\"\n >\n <div\n class=\"the-temp-table-corner-controls\"\n [ngClass]=\"{\n visible: !readonly && isInTable,\n active: isSelectedAllCell,\n dangerous: tableStore.isSelectedTable && tableStore.dangerousCells.length > 0\n }\"\n >\n <div class=\"the-temp-table-corner-button\" (mousedown)=\"onSelectTable($event)\"></div>\n <div class=\"the-temp-table-corner-controls-insert-row-marker\">\n <the-table-insert-mark type=\"row\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n <div class=\"the-temp-table-corner-controls-insert-column-marker\">\n <the-table-insert-mark type=\"column\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n </div>\n <div class=\"the-temp-table-row-controls\">\n <div class=\"the-temp-table-row-controls-inner\">\n <div\n class=\"the-temp-table-row-controls-button-wrap\"\n *ngFor=\"let control of rowControls; let i = index; trackBy:
|
|
9512
|
+
], viewQueries: [{ propertyName: "tableWrapper", first: true, predicate: ["tableWrapper"], descendants: true, read: ElementRef, static: true }, { propertyName: "theTableElement", first: true, predicate: ["theTable"], descendants: true, read: ElementRef, static: true }, { propertyName: "tbodyElement", first: true, predicate: ["tbody"], descendants: true, read: ElementRef, static: true }], usesInheritance: true, ngImport: i0, template: "<!-- \u7C7B\u540D the-temp-*: \u4E34\u65F6\u89E3\u51B3\u56E0\u53D7portal\u5F71\u54CD\u8868\u683C\u6837\u5F0F\u95EE\u9898\uFF0C\u540E\u671F\u6539\u56DEthe-* -->\n<div\n class=\"the-temp-table-container\"\n theColumnResize\n [ngClass]=\"{\n 'the-temp-table-with-controls': isInTable,\n 'the-temp-numbered-column-container': element?.options?.numberedColumn,\n 'the-temp-table-selection-hide': tableStore.isCellSelecting || tableStore.isRightClicking\n }\"\n>\n <div\n class=\"the-temp-table-row-controls-wrapper\"\n [ngClass]=\"{\n 'the-temp-table-focus': isInTable\n }\"\n >\n <div\n class=\"the-temp-table-corner-controls\"\n [ngClass]=\"{\n visible: !readonly && isInTable,\n active: isSelectedAllCell,\n dangerous: tableStore.isSelectedTable && tableStore.dangerousCells.length > 0\n }\"\n >\n <div class=\"the-temp-table-corner-button\" (mousedown)=\"onSelectTable($event)\"></div>\n <div class=\"the-temp-table-corner-controls-insert-row-marker\">\n <the-table-insert-mark type=\"row\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n <div class=\"the-temp-table-corner-controls-insert-column-marker\">\n <the-table-insert-mark type=\"column\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n </div>\n <div class=\"the-temp-table-row-controls\">\n <div class=\"the-temp-table-row-controls-inner\">\n <div\n class=\"the-temp-table-row-controls-button-wrap\"\n *ngFor=\"let control of rowControls; let i = index; trackBy: trackByFnRowControls\"\n [ngClass]=\"{\n active: tableStore.selectedRowsIndex.includes(control.rowIndex),\n dangerous: tableStore.dangerousRowsIndex.includes(control.rowIndex) && tableStore.dangerousCells.length > 0\n }\"\n >\n <ng-container *ngIf=\"!readonly && isInTable && !element?.options?.numberedColumn\">\n <button\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n type=\"button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n class=\"the-temp-table-row-controls-button the-temp-table-controls-button\"\n ></button>\n </ng-container>\n <ng-container *ngIf=\"element?.options?.numberedColumn\">\n <div\n [contentEditable]=\"false\"\n contenteditable=\"false\"\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n class=\"the-temp-table-numbered-controls-button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n >\n <p class=\"row-number d-flex align-items-center\">{{ i + 1 }}</p>\n </div>\n </ng-container>\n <the-table-insert-mark type=\"row\" [at]=\"control.rowIndex + 1\" [tableStore]=\"tableStore\"> </the-table-insert-mark>\n </div>\n </div>\n </div>\n </div>\n <div class=\"the-temp-table-wrapper\" #tableWrapper [ngClass]=\"{ 'the-temp-table-numbered': element?.options?.numberedColumn }\">\n <table class=\"the-temp-table\" #theTable [ngClass]=\"{ 'the-temp-table-with-controls': isInTable }\">\n <colgroup *ngIf=\"columns\">\n <col *ngFor=\"let col of columns\" [ngStyle]=\"{ width: col.width + 'px' }\" />\n </colgroup>\n <thead>\n <tr class=\"the-temp-table-col-controls-wrapper\">\n <th\n class=\"the-temp-table-col-controls\"\n [ngClass]=\"{\n active: tableStore.selectedColumnsIndex.includes(i),\n dangerous: tableStore.dangerousColumnsIndex.includes(i) && tableStore.dangerousCells.length > 0\n }\"\n (mousedown)=\"onColMouseDown($event, i)\"\n *ngFor=\"let control of colControls; let i = index; trackBy: trackByFnColControls\"\n >\n <the-table-insert-mark *ngIf=\"isInTable\" type=\"column\" [at]=\"i + 1\" [tableStore]=\"tableStore\">\n </the-table-insert-mark>\n </th>\n </tr>\n </thead>\n <tbody #tbody>\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"> </slate-children>\n </tbody>\n </table>\n </div>\n</div>\n", components: [{ type: TheInsertMarkComponent, selector: "the-table-insert-mark", inputs: ["type", "at", "tableStore"] }, { type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], directives: [{ type: TheColumnResizeDirective, selector: "div[theColumnResize]" }, { type: i10.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
|
|
9533
9513
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheTableComponent, decorators: [{
|
|
9534
9514
|
type: Component,
|
|
9535
9515
|
args: [{
|