@worktile/theia 2.2.10 → 2.3.0-next.2
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 +464 -229
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/constants/default.d.ts +2 -0
- package/constants/node-types.d.ts +4 -0
- package/custom-types.d.ts +3 -1
- package/editor.component.d.ts +1 -1
- package/esm2015/constants/default.js +1 -1
- package/esm2015/constants/node-types.js +6 -1
- package/esm2015/custom-types.js +1 -1
- package/esm2015/editor.component.js +1 -2
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/interfaces/image.js +1 -1
- package/esm2015/interfaces/valid-children-types.js +2 -1
- package/esm2015/plugins/align/align.editor.js +14 -2
- package/esm2015/plugins/align/options.js +3 -2
- package/esm2015/plugins/common/auto-insert-data..js +2 -18
- package/esm2015/plugins/image/image.component.js +168 -14
- package/esm2015/plugins/image/image.editor.js +4 -1
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +13 -2
- package/esm2015/services/context.service.js +5 -1
- package/esm2015/utils/dom.js +40 -2
- package/esm2015/utils/index.js +3 -1
- package/esm2015/utils/merge-element-options.js +20 -0
- package/fesm2015/worktile-theia.js +417 -197
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/editor.d.ts +4 -1
- package/interfaces/image.d.ts +7 -1
- package/interfaces/valid-children-types.d.ts +1 -0
- package/package.json +1 -1
- package/plugins/align/align.editor.d.ts +1 -0
- package/plugins/image/image.component.d.ts +27 -3
- package/plugins/image/image.component.scss +12 -2
- package/plugins/image/image.editor.d.ts +6 -1
- package/plugins/quick-insert/components/quick-insert.component.d.ts +1 -0
- package/plugins/table/components/table.component.scss +3 -2
- package/services/context.service.d.ts +1 -0
- package/styles/editor.scss +11 -0
- package/styles/index.scss +1 -1
- package/styles/typo.scss +56 -1
- package/utils/dom.d.ts +5 -1
- package/utils/index.d.ts +2 -0
- package/utils/merge-element-options.d.ts +2 -0
package/interfaces/editor.d.ts
CHANGED
|
@@ -30,9 +30,11 @@ export declare const TheEditor: {
|
|
|
30
30
|
editable?: boolean;
|
|
31
31
|
}): boolean;
|
|
32
32
|
insertData(editor: AngularEditor, data: DataTransfer): void;
|
|
33
|
+
insertFragmentData(editor: AngularEditor, data: DataTransfer): boolean;
|
|
34
|
+
insertTextData(editor: AngularEditor, data: DataTransfer): boolean;
|
|
33
35
|
onKeydown(editor: AngularEditor, data: KeyboardEvent): void;
|
|
34
36
|
onClick(editor: AngularEditor, data: MouseEvent): void;
|
|
35
|
-
setFragmentData(editor: AngularEditor, data: DataTransfer): void;
|
|
37
|
+
setFragmentData(editor: AngularEditor, data: DataTransfer, originEvent?: "copy" | "drag" | "cut"): void;
|
|
36
38
|
deleteCutData(editor: AngularEditor): void;
|
|
37
39
|
toDOMNode(editor: AngularEditor, node: Node): HTMLElement;
|
|
38
40
|
toDOMPoint(editor: AngularEditor, point: import("slate").BasePoint): import("slate-angular").DOMPoint;
|
|
@@ -75,6 +77,7 @@ export interface TheOptions {
|
|
|
75
77
|
scrollContainer?: string;
|
|
76
78
|
maxHeight?: number;
|
|
77
79
|
fontSize?: FontSizes;
|
|
80
|
+
richMedia?: boolean;
|
|
78
81
|
toolbar?: ToolbarOption;
|
|
79
82
|
disablePlugins?: string[];
|
|
80
83
|
extraElementOptions?: ElementOptionsInfo[];
|
package/interfaces/image.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { UploadFileEntity, FileUploadingItem } from './upload';
|
|
3
3
|
import { InjectionToken } from '@angular/core';
|
|
4
4
|
import { SafeUrl } from '@angular/platform-browser';
|
|
5
|
-
import { Alignment } from '../constants';
|
|
5
|
+
import { Alignment, LayoutTypes } from '../constants';
|
|
6
|
+
import { ToolbarItem } from './toolbar';
|
|
6
7
|
export interface ImageEntry {
|
|
7
8
|
file?: File;
|
|
8
9
|
name?: string;
|
|
@@ -11,6 +12,11 @@ export interface ImageEntry {
|
|
|
11
12
|
thumbUrl?: SafeUrl | string;
|
|
12
13
|
originUrl?: SafeUrl | string;
|
|
13
14
|
align?: Alignment;
|
|
15
|
+
layout?: LayoutTypes;
|
|
16
|
+
reSized?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface LayoutOption extends ToolbarItem {
|
|
19
|
+
handle?: (e: MouseEvent, key: Alignment | LayoutTypes) => void;
|
|
14
20
|
}
|
|
15
21
|
export interface TheImageUploaderService {
|
|
16
22
|
uploadFileHandle: (files: any) => Observable<UploadFileEntity[]>;
|
|
@@ -3,6 +3,7 @@ export interface ElementOptionsInfo {
|
|
|
3
3
|
type: CustomElementKinds;
|
|
4
4
|
inValidChildrenTypes: CustomElementKinds[];
|
|
5
5
|
isIndivisible?: boolean;
|
|
6
|
+
isSecondaryContainer?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const inValidTypes: CustomElementKinds[];
|
|
8
9
|
export declare const DefaultElementOptions: ElementOptionsInfo[];
|
package/package.json
CHANGED
|
@@ -2,5 +2,6 @@ import { Editor } from 'slate';
|
|
|
2
2
|
import { Alignment } from '../../constants/node-types';
|
|
3
3
|
export declare const AlignEditor: {
|
|
4
4
|
isActive(editor: Editor, alignment: Alignment): boolean;
|
|
5
|
+
isDisabled(editor: Editor): boolean;
|
|
5
6
|
setAlign(editor: Editor, alignment: Alignment): void;
|
|
6
7
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { OnInit, ElementRef, OnDestroy, AfterViewInit, ChangeDetectorRef } from '@angular/core';
|
|
1
|
+
import { OnInit, ElementRef, OnDestroy, AfterViewInit, ChangeDetectorRef, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
2
|
import { BeforeContextChange, SlateElementContext } from 'slate-angular';
|
|
3
3
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
-
import { ImageEntry, TheImageUploaderService } from '../../interfaces/image';
|
|
4
|
+
import { ImageEntry, TheImageUploaderService, LayoutOption } from '../../interfaces/image';
|
|
5
|
+
import { Alignment, LayoutTypes } from '../../constants/node-types';
|
|
5
6
|
import { Editor } from 'slate';
|
|
7
|
+
import { ThyPopover } from 'ngx-tethys/popover';
|
|
8
|
+
import { Overlay } from '@angular/cdk/overlay';
|
|
6
9
|
import { TheContextService } from '../../services/context.service';
|
|
7
10
|
import { TheBaseElementComponent } from '../../interfaces';
|
|
8
11
|
import { ImageElement } from '../../custom-types';
|
|
@@ -13,19 +16,28 @@ export declare class TheImageComponent extends TheBaseElementComponent<ImageElem
|
|
|
13
16
|
private imageUploaderService;
|
|
14
17
|
cdr: ChangeDetectorRef;
|
|
15
18
|
private theContextService;
|
|
19
|
+
private thyPopover;
|
|
20
|
+
private overlay;
|
|
21
|
+
private viewContainerRef;
|
|
16
22
|
imageEntry: ImageEntry;
|
|
17
23
|
uploading: boolean;
|
|
18
24
|
percentage: number;
|
|
19
25
|
file: File;
|
|
26
|
+
layoutDefaultWidth: number;
|
|
27
|
+
layoutOptions: LayoutOption[];
|
|
20
28
|
private uploadingSubscription;
|
|
21
29
|
private mouseMoveSubscription;
|
|
22
30
|
private mouseUpSubscription;
|
|
23
31
|
private dragable;
|
|
32
|
+
private layoutToolbarRef;
|
|
33
|
+
get isOpen(): boolean;
|
|
24
34
|
imageContent: ElementRef;
|
|
25
35
|
img: ElementRef;
|
|
26
|
-
|
|
36
|
+
layoutToolbar: TemplateRef<any>;
|
|
37
|
+
constructor(elementRef: ElementRef, sanitizer: DomSanitizer, imageUploaderService: TheImageUploaderService, cdr: ChangeDetectorRef, theContextService: TheContextService, thyPopover: ThyPopover, overlay: Overlay, viewContainerRef: ViewContainerRef);
|
|
27
38
|
beforeContextChange: (value: SlateElementContext<ImageElement>) => void;
|
|
28
39
|
ngOnInit(): void;
|
|
40
|
+
onContextChange(): void;
|
|
29
41
|
ngOnDestroy(): void;
|
|
30
42
|
ngAfterViewInit(): void;
|
|
31
43
|
uploadImage(file: File): Promise<void>;
|
|
@@ -42,6 +54,18 @@ export declare class TheImageComponent extends TheBaseElementComponent<ImageElem
|
|
|
42
54
|
endDrag(event: MouseEvent): void;
|
|
43
55
|
cancelUpload(event: any): void;
|
|
44
56
|
preview($event: Event): void;
|
|
57
|
+
isShouldOpen(): boolean;
|
|
58
|
+
isShouldClose(): boolean;
|
|
59
|
+
openLayoutToolbar(): void;
|
|
60
|
+
closeLayoutToolbar(): void;
|
|
61
|
+
layoutActive(key: Alignment | LayoutTypes): boolean;
|
|
62
|
+
setImageNode(e: MouseEvent, partial: {
|
|
63
|
+
layout?: LayoutTypes;
|
|
64
|
+
align?: Alignment;
|
|
65
|
+
}): void;
|
|
66
|
+
setBlockCardLayoutAttr(): void;
|
|
67
|
+
onDelete(event: MouseEvent): void;
|
|
68
|
+
createPositionStrategy(): import("@angular/cdk/overlay").FlexibleConnectedPositionStrategy;
|
|
45
69
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheImageComponent, never>;
|
|
46
70
|
static ɵcmp: i0.ɵɵComponentDeclaration<TheImageComponent, "the-image, [theImage]", never, {}, {}, never, never>;
|
|
47
71
|
}
|
|
@@ -186,9 +186,19 @@
|
|
|
186
186
|
|
|
187
187
|
.image-container:hover .layer {
|
|
188
188
|
display: block;
|
|
189
|
+
|
|
190
|
+
&.readonly {
|
|
191
|
+
cursor: zoom-in;
|
|
192
|
+
}
|
|
189
193
|
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.the-image-toolbar {
|
|
197
|
+
.thy-icon-nav .thy-icon-nav-link {
|
|
198
|
+
margin-right: $thy-icon-nav-link-margin-right;
|
|
190
199
|
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
&.remove-link:hover {
|
|
201
|
+
@include remove-link-hover();
|
|
202
|
+
}
|
|
193
203
|
}
|
|
194
204
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { Editor } from 'slate';
|
|
1
|
+
import { Editor, Path } from 'slate';
|
|
2
|
+
import { Alignment, LayoutTypes } from '../../constants';
|
|
2
3
|
export declare const ImageEditor: {
|
|
3
4
|
openUpload(editor: Editor): void;
|
|
4
5
|
insertImages(editor: Editor, imageFiles: FileList | File[]): void;
|
|
5
6
|
verifyImage(editor: Editor, image: File): boolean;
|
|
6
7
|
isImageActive(editor: Editor): boolean;
|
|
8
|
+
setImageNode(editor: Editor, path: Path, partial: {
|
|
9
|
+
layout?: LayoutTypes;
|
|
10
|
+
align?: Alignment;
|
|
11
|
+
}): void;
|
|
7
12
|
};
|
|
@@ -17,6 +17,7 @@ export declare class TheQuickInsertComponent {
|
|
|
17
17
|
handleMousedownNativeElement(event: any): void;
|
|
18
18
|
constructor(renderer: Renderer2, elementRef: ElementRef, cdr: ChangeDetectorRef);
|
|
19
19
|
checkStatus(): void;
|
|
20
|
+
private isRichMediaScope;
|
|
20
21
|
private hasExcludeAttribute;
|
|
21
22
|
private updatePosition;
|
|
22
23
|
mouseEnter(event: MouseEvent): void;
|
|
@@ -12,6 +12,7 @@ $control-width: 11px;
|
|
|
12
12
|
$control-corner-width: 12px;
|
|
13
13
|
|
|
14
14
|
.slate-element-table {
|
|
15
|
+
display: block;
|
|
15
16
|
.the-table {
|
|
16
17
|
border-spacing: 0;
|
|
17
18
|
word-wrap: break-word;
|
|
@@ -339,11 +340,11 @@ $control-corner-width: 12px;
|
|
|
339
340
|
display: block;
|
|
340
341
|
|
|
341
342
|
.danger.thy-icon-nav-link:hover {
|
|
342
|
-
|
|
343
|
+
@include remove-link-hover();
|
|
343
344
|
}
|
|
344
345
|
|
|
345
346
|
.thy-icon-nav .thy-icon-nav-link {
|
|
346
|
-
margin-right:
|
|
347
|
+
margin-right: $thy-icon-nav-link-margin-right;
|
|
347
348
|
|
|
348
349
|
&:last-child {
|
|
349
350
|
margin-right: 0;
|
package/styles/editor.scss
CHANGED
|
@@ -129,6 +129,10 @@ $thy-icon-nav-link-margin-right: 5px;
|
|
|
129
129
|
|
|
130
130
|
.leaf-with-placeholder {
|
|
131
131
|
background-color: $white;
|
|
132
|
+
|
|
133
|
+
&[data-slate-leaf=true] {
|
|
134
|
+
width: 12em;;
|
|
135
|
+
}
|
|
132
136
|
}
|
|
133
137
|
[data-slate-placeholder] {
|
|
134
138
|
color: initial;
|
|
@@ -277,6 +281,13 @@ $thy-icon-nav-link-margin-right: 5px;
|
|
|
277
281
|
}
|
|
278
282
|
}
|
|
279
283
|
|
|
284
|
+
.the-block-toolbar-popover {
|
|
285
|
+
display: flex;
|
|
286
|
+
padding: 5px 10px;
|
|
287
|
+
background: $white;
|
|
288
|
+
box-shadow: $box-shadow;
|
|
289
|
+
}
|
|
290
|
+
|
|
280
291
|
@mixin the-toolbar-active {
|
|
281
292
|
.thy-icon-nav-link.thy-popover-origin-active,
|
|
282
293
|
.the-toolbar-dropdown-container.thy-popover-origin-active .thy-icon-nav-link {
|
package/styles/index.scss
CHANGED
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
@import '../plugins/quick-insert/components/quick-insert.component.scss';
|
|
19
19
|
@import '../plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.scss';
|
|
20
20
|
@import '../plugins/font-size/toolbar-item.component.scss';
|
|
21
|
-
@import '../plugins/inline-code/inline-code.component.scss';
|
|
21
|
+
@import '../plugins/inline-code/inline-code.component.scss';
|
package/styles/typo.scss
CHANGED
|
@@ -19,7 +19,13 @@ $nav-item-margin: 5px;
|
|
|
19
19
|
$selection-background: rgba($color: $primary, $alpha: 0.3);
|
|
20
20
|
$font-size-line-height: 1.5;
|
|
21
21
|
|
|
22
|
+
@mixin remove-link-hover {
|
|
23
|
+
color: $danger;
|
|
24
|
+
background: hsla(0,100%,73%,.1);
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
.the-editor-typo {
|
|
28
|
+
display: flow-root;
|
|
23
29
|
font-size: $the-font-size-base;
|
|
24
30
|
min-height: 250px;
|
|
25
31
|
padding: 28px 30px;
|
|
@@ -112,6 +118,9 @@ $font-size-line-height: 1.5;
|
|
|
112
118
|
text-indent: 0;
|
|
113
119
|
color: $gray-700;
|
|
114
120
|
}
|
|
121
|
+
.slate-element-hr{
|
|
122
|
+
display: block;
|
|
123
|
+
}
|
|
115
124
|
.slate-element-hr,
|
|
116
125
|
.slate-element-code,
|
|
117
126
|
.slate-element-image,
|
|
@@ -168,6 +177,52 @@ $font-size-line-height: 1.5;
|
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
.remove-link.thy-icon-nav-link:hover {
|
|
171
|
-
|
|
180
|
+
@include remove-link-hover();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 处理 block-card 图文混排
|
|
184
|
+
.slate-block,
|
|
185
|
+
.slate-block-card {
|
|
186
|
+
clear: both;
|
|
187
|
+
|
|
188
|
+
&.slate-element-paragraph,
|
|
189
|
+
&[class^="slate-element-heading"] {
|
|
190
|
+
clear: none;
|
|
191
|
+
}
|
|
192
|
+
&.slate-element-numbered-list,
|
|
193
|
+
&.slate-element-bulleted-list,
|
|
194
|
+
&.slate-element-block-quote {
|
|
195
|
+
clear: none;
|
|
196
|
+
display: flow-root;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.slate-block-card {
|
|
201
|
+
&[layout^="wrap-"] {
|
|
202
|
+
max-width: 100%;
|
|
203
|
+
clear: inherit;
|
|
204
|
+
}
|
|
205
|
+
&[layout="wrap-left"] {
|
|
206
|
+
float: left;
|
|
207
|
+
z-index: 1;
|
|
208
|
+
|
|
209
|
+
.image-content {
|
|
210
|
+
margin: 0 12px 0 auto;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
&[layout="wrap-right"] {
|
|
214
|
+
float: right;
|
|
215
|
+
z-index: 1;
|
|
216
|
+
|
|
217
|
+
.image-content {
|
|
218
|
+
margin: 0 auto 0 12px;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
// 处理相邻图文混排时的布局
|
|
225
|
+
[layout^="wrap-"] + [layout^="wrap-"] + .slate-block {
|
|
226
|
+
clear: both !important;
|
|
172
227
|
}
|
|
173
228
|
}
|
package/utils/dom.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Element } from 'slate';
|
|
1
|
+
import { Element, NodeEntry } from 'slate';
|
|
2
2
|
import { DOMElement } from 'slate-angular';
|
|
3
|
+
import { TheEditor } from '../interfaces/editor';
|
|
4
|
+
import { NodeLevel } from '../constants';
|
|
3
5
|
/** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
|
|
4
6
|
export declare function coercePixelsFromCssValue(cssValue: string): number;
|
|
5
7
|
export declare function getElementWidth(element: HTMLElement): number;
|
|
@@ -8,3 +10,5 @@ export declare function getColsTotalWidth(cols: HTMLTableColElement[]): number;
|
|
|
8
10
|
export declare function getRowsTotalHeight(rows: HTMLTableRowElement[]): number;
|
|
9
11
|
export declare function useElementStyle(el: HTMLElement, element: Element): void;
|
|
10
12
|
export declare function getElementClassByPrefix(el: DOMElement, prefix: string): any;
|
|
13
|
+
export declare function findRelativeElementByPoint(editor: TheEditor, x: number, y: number, mode?: NodeLevel): DOMElement;
|
|
14
|
+
export declare function findNodeEntryByPoint(editor: TheEditor, x: number, y: number, mode?: NodeLevel): NodeEntry<Element> | null;
|
package/utils/index.d.ts
CHANGED