@worktile/theia 2.1.2 → 2.1.6
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 +426 -221
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/components/toolbar/toolbar.component.d.ts +1 -3
- package/constants/default.d.ts +1 -1
- package/constants/node-types.d.ts +4 -3
- package/custom-types.d.ts +4 -1
- package/editor.component.d.ts +0 -2
- package/editor.module.d.ts +4 -5
- package/esm2015/components/inline-toolbar/inline-toolbar.component.js +1 -1
- package/esm2015/components/toolbar/toolbar.component.js +9 -8
- package/esm2015/components/toolbar-group/toolbar-group.component.js +1 -1
- package/esm2015/constants/auto-format-rules.js +8 -3
- package/esm2015/constants/default.js +2 -2
- package/esm2015/constants/node-types.js +5 -4
- package/esm2015/constants/toolbar.js +5 -5
- package/esm2015/custom-types.js +1 -1
- package/esm2015/editor.component.js +24 -22
- package/esm2015/editor.module.js +4 -4
- package/esm2015/interfaces/auto-format.js +1 -1
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/interfaces/element.js +1 -1
- package/esm2015/plugins/autoformat/autoformat.plugin.js +2 -1
- package/esm2015/plugins/autoformat/transforms/auto-format-inline.js +27 -14
- package/esm2015/plugins/code/code.component.js +26 -10
- package/esm2015/plugins/deserializers/deserialize-md.plugin.js +2 -2
- package/esm2015/plugins/font-size/font-size.editor.js +35 -1
- package/esm2015/plugins/heading/heading.editor.js +3 -1
- package/esm2015/plugins/index.js +7 -3
- package/esm2015/plugins/inline-code/inline-code.component.js +27 -0
- package/esm2015/plugins/inline-code/inline-code.editor.js +45 -0
- package/esm2015/plugins/inline-code/inline-code.plugin.js +46 -0
- package/esm2015/plugins/inline-code/options.js +14 -0
- package/esm2015/plugins/link/link.component.js +4 -2
- package/esm2015/plugins/list/components/list-item.component.js +69 -1
- package/esm2015/plugins/list/transforms/insert-list-item.js +11 -7
- package/esm2015/plugins/mark/mark.plugin.js +15 -10
- package/esm2015/plugins/mark/options.js +1 -9
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +10 -9
- package/esm2015/services/context.service.js +9 -1
- package/esm2015/shortcuts/mark.js +10 -4
- package/esm2015/transforms/handle-continual-insert-break.js +1 -4
- package/esm2015/utils/index.js +2 -1
- package/fesm2015/worktile-theia.js +395 -204
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/auto-format.d.ts +1 -1
- package/interfaces/editor.d.ts +3 -3
- package/interfaces/element.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/autoformat/transforms/auto-format-inline.d.ts +3 -1
- package/plugins/code/code.component.d.ts +6 -3
- package/plugins/code/code.component.scss +17 -0
- package/plugins/font-size/font-size.editor.d.ts +2 -0
- package/plugins/inline-code/inline-code.component.d.ts +14 -0
- package/plugins/inline-code/inline-code.component.scss +13 -0
- package/plugins/inline-code/inline-code.editor.d.ts +7 -0
- package/plugins/inline-code/inline-code.plugin.d.ts +2 -0
- package/plugins/inline-code/options.d.ts +2 -0
- package/plugins/list/components/list-item.component.d.ts +7 -0
- package/plugins/quick-insert/components/quick-insert.component.d.ts +2 -1
- package/queries/get-container-blocks.d.ts +1 -1
- package/queries/get-selection-marks.d.ts +1 -1
- package/services/context.service.d.ts +5 -1
- package/styles/editor.scss +20 -1
- package/styles/index.scss +1 -1
- package/transforms/set-marks.d.ts +1 -1
- package/utils/index.d.ts +1 -0
- package/esm2015/plugins/placeholder/placeholder.component.js +0 -83
- package/plugins/placeholder/placeholder.component.d.ts +0 -21
- package/plugins/placeholder/placeholder.component.scss +0 -10
|
@@ -25,7 +25,7 @@ export interface AutoFormatRule {
|
|
|
25
25
|
/**
|
|
26
26
|
* Custom formatting function.
|
|
27
27
|
*/
|
|
28
|
-
format?: (editor: Editor,
|
|
28
|
+
format?: (editor: Editor, markup: string | string[]) => void;
|
|
29
29
|
/**
|
|
30
30
|
* - block (default) – set/insert block. Should be used with `markup`.
|
|
31
31
|
* - inline – insert mark between markups. Should be used with `between`.
|
package/interfaces/editor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ancestor, Range, Path, Point, Node, Span, NodeEntry, Editor, Element, Text } from 'slate';
|
|
2
|
-
import { AngularEditor, ViewType } from 'slate-angular';
|
|
2
|
+
import { AngularEditor, SlatePlaceholder, ViewType } from 'slate-angular';
|
|
3
3
|
import { HistoryEditor } from 'slate-history';
|
|
4
4
|
import { ElementOptionsInfo } from './valid-children-types';
|
|
5
5
|
import { Predicate } from '../utils/match';
|
|
@@ -69,8 +69,8 @@ export interface TheOptions {
|
|
|
69
69
|
disabled?: boolean;
|
|
70
70
|
autoFocus?: boolean;
|
|
71
71
|
placeholder?: string;
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
placeholderDecorate?: (editor: Editor) => SlatePlaceholder[];
|
|
73
|
+
quickInsertVisible?: boolean;
|
|
74
74
|
scrollContainer?: string;
|
|
75
75
|
maxHeight?: number;
|
|
76
76
|
fontSize?: FontSizes;
|
package/interfaces/element.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Alignment, ElementKinds } from '../constants';
|
|
2
2
|
export declare type HeadingElementKinds = ElementKinds.heading_1 | ElementKinds.heading_2 | ElementKinds.heading_3 | ElementKinds.heading_4 | ElementKinds.heading_5 | ElementKinds.heading_6;
|
|
3
|
-
export declare type BlockElementKinds = ElementKinds.image | ElementKinds.paragraph | ElementKinds.numberedList | ElementKinds.bulletedList | ElementKinds.listItem | ElementKinds.checkItem | ElementKinds.table | ElementKinds.tableRow | ElementKinds.tableCell | ElementKinds.tableContent | ElementKinds.code | ElementKinds.blockquote | ElementKinds.hr | ElementKinds.link | HeadingElementKinds;
|
|
3
|
+
export declare type BlockElementKinds = ElementKinds.image | ElementKinds.paragraph | ElementKinds.numberedList | ElementKinds.bulletedList | ElementKinds.listItem | ElementKinds.checkItem | ElementKinds.table | ElementKinds.tableRow | ElementKinds.tableCell | ElementKinds.tableContent | ElementKinds.code | ElementKinds.blockquote | ElementKinds.hr | ElementKinds.link | ElementKinds.inlineCode | HeadingElementKinds;
|
|
4
4
|
export declare type InlineElementKinds = ElementKinds.link;
|
|
5
5
|
export interface TheBlockElement {
|
|
6
6
|
align?: Alignment;
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
1
2
|
import { MarkEditor } from '../../../plugins/mark/mark.editor';
|
|
2
|
-
export declare const autoFormatInline: (editor: MarkEditor, { type, between, markup, ignoreTrim }: {
|
|
3
|
+
export declare const autoFormatInline: (editor: MarkEditor, { type, between, markup, ignoreTrim, format }: {
|
|
3
4
|
type: string;
|
|
4
5
|
between?: string[];
|
|
5
6
|
markup?: string;
|
|
6
7
|
ignoreTrim?: boolean;
|
|
8
|
+
format?: (editor: Editor, markup?: string) => void;
|
|
7
9
|
}) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementRef, ChangeDetectorRef, OnInit, AfterViewInit, NgZone } from '@angular/core';
|
|
1
|
+
import { ElementRef, ChangeDetectorRef, OnInit, AfterViewInit, NgZone, OnDestroy } from '@angular/core';
|
|
2
2
|
import { ThyNotifyService } from 'ngx-tethys/notify';
|
|
3
3
|
import { Editor } from 'slate';
|
|
4
4
|
import { CodeMirrorComponent } from 'ng-codemirror';
|
|
@@ -7,8 +7,9 @@ import { DefaultToolbarItem, TheBaseElementComponent } from '../../interfaces';
|
|
|
7
7
|
import { CodeElement } from '../../custom-types';
|
|
8
8
|
import { ThyResizeEvent } from 'ngx-tethys/resizable';
|
|
9
9
|
import { TheContextService } from '../../services/context.service';
|
|
10
|
+
import { Subject } from 'rxjs';
|
|
10
11
|
import * as i0 from "@angular/core";
|
|
11
|
-
export declare class TheCodeComponent extends TheBaseElementComponent<CodeElement, Editor> implements OnInit, AfterViewInit {
|
|
12
|
+
export declare class TheCodeComponent extends TheBaseElementComponent<CodeElement, Editor> implements OnInit, AfterViewInit, OnDestroy {
|
|
12
13
|
elementRef: ElementRef;
|
|
13
14
|
cdr: ChangeDetectorRef;
|
|
14
15
|
private thyNotifyService;
|
|
@@ -22,8 +23,9 @@ export declare class TheCodeComponent extends TheBaseElementComponent<CodeElemen
|
|
|
22
23
|
key: string;
|
|
23
24
|
name: string;
|
|
24
25
|
}[];
|
|
26
|
+
destroy$: Subject<void>;
|
|
25
27
|
ToolbarItemMode: typeof ToolbarItemMode;
|
|
26
|
-
|
|
28
|
+
isHightLight: boolean;
|
|
27
29
|
resizeHeight: number;
|
|
28
30
|
options: {
|
|
29
31
|
mode: string;
|
|
@@ -56,6 +58,7 @@ export declare class TheCodeComponent extends TheBaseElementComponent<CodeElemen
|
|
|
56
58
|
onResize({ height }: ThyResizeEvent): void;
|
|
57
59
|
onEndResize(): void;
|
|
58
60
|
onChangeWrap(value: boolean): void;
|
|
61
|
+
ngOnDestroy(): void;
|
|
59
62
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheCodeComponent, never>;
|
|
60
63
|
static ɵcmp: i0.ɵɵComponentDeclaration<TheCodeComponent, "div[theCode]", never, {}, {}, never, never>;
|
|
61
64
|
}
|
|
@@ -10,6 +10,22 @@
|
|
|
10
10
|
border-radius: 2px;
|
|
11
11
|
color: $gray-600;
|
|
12
12
|
background: rgba(243, 243, 243, 0.8);
|
|
13
|
+
&:hover{
|
|
14
|
+
border-color: $primary;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.resize-code-container.readonly, .resize-code-container.focus{
|
|
18
|
+
border-color: $gray-300;
|
|
19
|
+
&:hover{
|
|
20
|
+
border-color: $gray-300;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.resize-code-container.active {
|
|
25
|
+
border-color: $primary;
|
|
26
|
+
&:hover{
|
|
27
|
+
border-color: $primary;
|
|
28
|
+
}
|
|
13
29
|
}
|
|
14
30
|
.CodeMirror {
|
|
15
31
|
height: 100% !important;
|
|
@@ -35,6 +51,7 @@
|
|
|
35
51
|
.ng-codemirror-wrapper {
|
|
36
52
|
display: block;
|
|
37
53
|
position: relative;
|
|
54
|
+
overflow-y: auto;
|
|
38
55
|
height: 100%;
|
|
39
56
|
}
|
|
40
57
|
|
|
@@ -3,6 +3,8 @@ import { TheEditor } from '../../interfaces/editor';
|
|
|
3
3
|
import { FontSizes } from '../../constants/node-types';
|
|
4
4
|
export declare const FontSizeEditor: {
|
|
5
5
|
setFontSize(editor: TheEditor, size: FontSizes): void;
|
|
6
|
+
setFontSizeMark(editor: Editor, size: FontSizes): void;
|
|
7
|
+
unsetFontSize(editor: Editor, size: FontSizes, fontSizeMark: number, isDefaultFontSize: boolean): boolean;
|
|
6
8
|
isFontSizeActive(editor: Editor, size: FontSizes): boolean;
|
|
7
9
|
isDisabled(editor: TheEditor): boolean;
|
|
8
10
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChangeDetectorRef, ElementRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { Editor } from 'slate';
|
|
3
|
+
import { InlineCodeElement } from '../../custom-types';
|
|
4
|
+
import { TheBaseElementComponent } from '../../interfaces';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class TheInlineCodeComponent extends TheBaseElementComponent<InlineCodeElement, Editor> implements OnInit, OnDestroy {
|
|
7
|
+
elementRef: ElementRef;
|
|
8
|
+
cdr: ChangeDetectorRef;
|
|
9
|
+
constructor(elementRef: ElementRef, cdr: ChangeDetectorRef);
|
|
10
|
+
ngOnInit(): void;
|
|
11
|
+
ngOnDestroy(): void;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TheInlineCodeComponent, never>;
|
|
13
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TheInlineCodeComponent, "span[theInlineCode]", never, {}, {}, never, never>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.slate-element-inline-code{
|
|
2
|
+
margin: 0 4px;
|
|
3
|
+
padding: 2px 3px;
|
|
4
|
+
border: 1px solid $gray-300;
|
|
5
|
+
border-radius: 2px;
|
|
6
|
+
font-family: monospace;
|
|
7
|
+
font-size: inherit;
|
|
8
|
+
background-color: rgba(243, 243, 243, 0.8);
|
|
9
|
+
line-height: inherit;
|
|
10
|
+
word-wrap: break-word;
|
|
11
|
+
text-indent: 0;
|
|
12
|
+
color: $gray-700;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Editor } from 'slate';
|
|
2
|
+
export declare const InlineCodeEditor: {
|
|
3
|
+
toggleInlineCode(editor: any, text?: string): void;
|
|
4
|
+
wrapInlineCode(editor: Editor, text?: string): void;
|
|
5
|
+
unwrapInlineCode(editor: Editor): void;
|
|
6
|
+
isInlineCodeActive(editor: Editor): boolean;
|
|
7
|
+
};
|
|
@@ -5,9 +5,16 @@ import * as i0 from "@angular/core";
|
|
|
5
5
|
export declare class TheListItemComponent extends TheBaseElementComponent<Element, Editor> implements OnInit, OnDestroy {
|
|
6
6
|
elementRef: ElementRef;
|
|
7
7
|
cdr: ChangeDetectorRef;
|
|
8
|
+
fontSizeClass: string;
|
|
8
9
|
constructor(elementRef: ElementRef, cdr: ChangeDetectorRef);
|
|
9
10
|
ngOnInit(): void;
|
|
11
|
+
onContextChange(): void;
|
|
10
12
|
ngOnDestroy(): void;
|
|
13
|
+
addFontSize(): void;
|
|
14
|
+
clearFontSize(): void;
|
|
15
|
+
getStart(): number;
|
|
16
|
+
getLiIndex(): number;
|
|
17
|
+
addMultiDigit(): void;
|
|
11
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheListItemComponent, never>;
|
|
12
19
|
static ɵcmp: i0.ɵɵComponentDeclaration<TheListItemComponent, "li[theLi]", never, {}, {}, never, never>;
|
|
13
20
|
}
|
|
@@ -8,6 +8,7 @@ export declare class TheQuickInsertComponent {
|
|
|
8
8
|
private cdr;
|
|
9
9
|
editor: Editor;
|
|
10
10
|
quickToolbarItems: ToolbarItem[];
|
|
11
|
+
isVisible: boolean;
|
|
11
12
|
isHide: boolean;
|
|
12
13
|
defaultIconName: string;
|
|
13
14
|
iconNameFill: string;
|
|
@@ -21,5 +22,5 @@ export declare class TheQuickInsertComponent {
|
|
|
21
22
|
mouseLeave(event: MouseEvent): void;
|
|
22
23
|
handleClick(event: MouseEvent): void;
|
|
23
24
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheQuickInsertComponent, never>;
|
|
24
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<TheQuickInsertComponent, "[theQuickInsert]", never, { "editor": "editor"; "quickToolbarItems": "quickToolbarItems"; }, {}, never, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TheQuickInsertComponent, "[theQuickInsert]", never, { "editor": "editor"; "quickToolbarItems": "quickToolbarItems"; "isVisible": "isVisible"; }, {}, never, never>;
|
|
25
26
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Editor } from 'slate';
|
|
2
|
-
export declare const getContainerBlocks: (editor: Editor) => (import("../constants/node-types").ElementKinds.image | import("../constants/node-types").ElementKinds.paragraph | import("../constants/node-types").ElementKinds.heading_1 | import("../constants/node-types").ElementKinds.heading_2 | import("../constants/node-types").ElementKinds.heading_3 | import("../constants/node-types").ElementKinds.heading_4 | import("../constants/node-types").ElementKinds.heading_5 | import("../constants/node-types").ElementKinds.heading_6 | import("../constants/node-types").ElementKinds.numberedList | import("../constants/node-types").ElementKinds.bulletedList | import("../constants/node-types").ElementKinds.listItem | import("../constants/node-types").ElementKinds.checkItem | import("../constants/node-types").ElementKinds.table | import("../constants/node-types").ElementKinds.tableRow | import("../constants/node-types").ElementKinds.tableCell | import("../constants/node-types").ElementKinds.code | import("../constants/node-types").ElementKinds.blockquote | import("../constants/node-types").ElementKinds.hr | import("../constants/node-types").ElementKinds.link)[];
|
|
2
|
+
export declare const getContainerBlocks: (editor: Editor) => (import("../constants/node-types").ElementKinds.image | import("../constants/node-types").ElementKinds.paragraph | import("../constants/node-types").ElementKinds.heading_1 | import("../constants/node-types").ElementKinds.heading_2 | import("../constants/node-types").ElementKinds.heading_3 | import("../constants/node-types").ElementKinds.heading_4 | import("../constants/node-types").ElementKinds.heading_5 | import("../constants/node-types").ElementKinds.heading_6 | import("../constants/node-types").ElementKinds.numberedList | import("../constants/node-types").ElementKinds.bulletedList | import("../constants/node-types").ElementKinds.listItem | import("../constants/node-types").ElementKinds.checkItem | import("../constants/node-types").ElementKinds.table | import("../constants/node-types").ElementKinds.tableRow | import("../constants/node-types").ElementKinds.tableCell | import("../constants/node-types").ElementKinds.code | import("../constants/node-types").ElementKinds.blockquote | import("../constants/node-types").ElementKinds.hr | import("../constants/node-types").ElementKinds.link | import("../constants/node-types").ElementKinds.inlineCode)[];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { NgZone, ViewContainerRef } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import {
|
|
3
|
+
import { TheOptions } from '../interfaces/editor';
|
|
4
|
+
import { FontSizes, MarkTypes } from '../constants/node-types';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export interface TheContextOptions {
|
|
7
|
+
theOptions: TheOptions;
|
|
6
8
|
width?: number;
|
|
7
9
|
nativeElement: HTMLElement;
|
|
8
10
|
viewContainerRef: ViewContainerRef;
|
|
@@ -27,6 +29,8 @@ export declare class TheContextService {
|
|
|
27
29
|
constructor(ngZone: NgZone);
|
|
28
30
|
initialize(options: TheContextOptions): void;
|
|
29
31
|
getOptions(): TheContextOptions;
|
|
32
|
+
getTheOptions(): TheOptions;
|
|
33
|
+
getDefaultFontSize(): FontSizes;
|
|
30
34
|
getEditableElement(): Element;
|
|
31
35
|
getFirstElementChild(): HTMLElement;
|
|
32
36
|
setUploadFileList(file: {
|
package/styles/editor.scss
CHANGED
|
@@ -127,11 +127,30 @@ $thy-icon-nav-link-margin-right: 5px;
|
|
|
127
127
|
color: $gray-700;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
// list: fontSize, li marginLeft, multiDigit li marginLeft
|
|
131
|
+
@each $size, $liMl, $liMultiDigitMl in (12, 13, 14, 15, 16, 18, 20, (24 null 35px), (28 null 42px), (32 33px 50px), (40 40px 62px), (48 50px 78px)) {
|
|
131
132
|
[the-font-size="#{$size}"] {
|
|
132
133
|
font-size: #{$size}px;
|
|
133
134
|
line-height: $font-size-line-height;
|
|
134
135
|
}
|
|
136
|
+
.slate-element-list-item {
|
|
137
|
+
&.font-size-#{$size} {
|
|
138
|
+
&::marker {
|
|
139
|
+
font-size: #{$size}px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
.slate-element-numbered-list {
|
|
144
|
+
.slate-element-list-item {
|
|
145
|
+
&.font-size-#{$size} {
|
|
146
|
+
margin-left: $liMl;
|
|
147
|
+
|
|
148
|
+
&[data-multi-digit] {
|
|
149
|
+
margin-left: $liMultiDigitMl;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
|
package/styles/index.scss
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
@import '../components/inline-toolbar/inline-toolbar.component.scss';
|
|
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
|
-
@import '../plugins/placeholder/placeholder.component.scss';
|
|
21
20
|
@import '../plugins/font-size/toolbar-item.component.scss';
|
|
21
|
+
@import '../plugins/inline-code/inline-code.component.scss';
|
package/utils/index.d.ts
CHANGED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Component, Input, HostListener } from '@angular/core';
|
|
2
|
-
import { Node } from 'slate';
|
|
3
|
-
import { AngularEditor } from 'slate-angular';
|
|
4
|
-
import { isCleanEmptyParagraph } from '../../utils/is-clean-empty-paragraph';
|
|
5
|
-
import * as TheQueries from '../../queries';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
import * as i1 from "../../services/context.service";
|
|
8
|
-
export class ThePlaceholderComponent {
|
|
9
|
-
constructor(renderer, elementRef, contextService) {
|
|
10
|
-
this.renderer = renderer;
|
|
11
|
-
this.elementRef = elementRef;
|
|
12
|
-
this.contextService = contextService;
|
|
13
|
-
this.isHide = true;
|
|
14
|
-
}
|
|
15
|
-
handleCompositionStart() {
|
|
16
|
-
var _a;
|
|
17
|
-
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.selection) {
|
|
18
|
-
this.hide();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
handleCompositionEnd(event) {
|
|
22
|
-
if (!event.data) {
|
|
23
|
-
this.checkStatus();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
checkStatus() {
|
|
27
|
-
var _a, _b, _c;
|
|
28
|
-
const { editor } = this;
|
|
29
|
-
const isEmptyShow = typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isEmptyShowPlaceholder) === 'undefined' ? true : this.options.isEmptyShowPlaceholder;
|
|
30
|
-
const isMustShow = (_b = this.options) === null || _b === void 0 ? void 0 : _b.isMustShowPlaceholder;
|
|
31
|
-
const isReadonly = (_c = this.options) === null || _c === void 0 ? void 0 : _c.readonly;
|
|
32
|
-
// empty content and no selection processing
|
|
33
|
-
if (!isReadonly && isEmptyShow && TheQueries.isEmptyContent(editor.children)) {
|
|
34
|
-
const firstElementChild = this.contextService.getFirstElementChild();
|
|
35
|
-
const offsetTop = firstElementChild.offsetTop;
|
|
36
|
-
const offsetLeft = firstElementChild.offsetLeft;
|
|
37
|
-
this.updatePosition(offsetLeft, offsetTop);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (isMustShow && isCleanEmptyParagraph(editor)) {
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
var _a;
|
|
43
|
-
const block = Node.ancestor(editor, [(_a = editor === null || editor === void 0 ? void 0 : editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path[0]]);
|
|
44
|
-
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
45
|
-
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.isHide = true;
|
|
50
|
-
}
|
|
51
|
-
updatePosition(left, top) {
|
|
52
|
-
this.isHide = false;
|
|
53
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'top', `${top}px`);
|
|
54
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'left', `${left}px`);
|
|
55
|
-
}
|
|
56
|
-
hide() {
|
|
57
|
-
this.isHide = true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
ThePlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.TheContextService }], target: i0.ɵɵFactoryTarget.Component });
|
|
61
|
-
ThePlaceholderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: ThePlaceholderComponent, selector: "div[thePlaceholder]", inputs: { editor: "editor", options: "options" }, host: { listeners: { "document:compositionstart": "handleCompositionStart()", "document:compositionend": "handleCompositionEnd($event)" }, properties: { "class.hide": "isHide" }, classAttribute: "the-placeholder" }, ngImport: i0, template: `{{ options?.placeholder }}`, isInline: true });
|
|
62
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, decorators: [{
|
|
63
|
-
type: Component,
|
|
64
|
-
args: [{
|
|
65
|
-
selector: 'div[thePlaceholder]',
|
|
66
|
-
template: `{{ options?.placeholder }}`,
|
|
67
|
-
host: {
|
|
68
|
-
class: 'the-placeholder',
|
|
69
|
-
'[class.hide]': 'isHide'
|
|
70
|
-
}
|
|
71
|
-
}]
|
|
72
|
-
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.TheContextService }]; }, propDecorators: { editor: [{
|
|
73
|
-
type: Input
|
|
74
|
-
}], options: [{
|
|
75
|
-
type: Input
|
|
76
|
-
}], handleCompositionStart: [{
|
|
77
|
-
type: HostListener,
|
|
78
|
-
args: ['document:compositionstart']
|
|
79
|
-
}], handleCompositionEnd: [{
|
|
80
|
-
type: HostListener,
|
|
81
|
-
args: ['document:compositionend', ['$event']]
|
|
82
|
-
}] } });
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhY2Vob2xkZXIuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvc3JjL3BsdWdpbnMvcGxhY2Vob2xkZXIvcGxhY2Vob2xkZXIuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQWMsS0FBSyxFQUFFLFlBQVksRUFBYSxNQUFNLGVBQWUsQ0FBQztBQUN0RixPQUFPLEVBQVUsSUFBSSxFQUFFLE1BQU0sT0FBTyxDQUFDO0FBQ3JDLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDOUMsT0FBTyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sc0NBQXNDLENBQUM7QUFFN0UsT0FBTyxLQUFLLFVBQVUsTUFBTSxlQUFlLENBQUM7OztBQVc1QyxNQUFNLE9BQU8sdUJBQXVCO0lBb0JoQyxZQUFvQixRQUFtQixFQUFVLFVBQXNCLEVBQVUsY0FBaUM7UUFBOUYsYUFBUSxHQUFSLFFBQVEsQ0FBVztRQUFVLGVBQVUsR0FBVixVQUFVLENBQVk7UUFBVSxtQkFBYyxHQUFkLGNBQWMsQ0FBbUI7UUFoQmxILFdBQU0sR0FBRyxJ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1xuICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc3QgYmxvY2sgPSBOb2RlLmFuY2VzdG9yKGVkaXRvciwgW2VkaXRvcj8uc2VsZWN0aW9uPy5hbmNob3IucGF0aFswXV0pO1xuICAgICAgICAgICAgICAgIGNvbnN0IHJvb3ROb2RlOiBIVE1MRWxlbWVudCA9IEFuZ3VsYXJFZGl0b3IudG9ET01Ob2RlKGVkaXRvciwgYmxvY2spO1xuICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlUG9zaXRpb24ocm9vdE5vZGUub2Zmc2V0TGVmdCwgcm9vdE5vZGUub2Zmc2V0VG9wKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuaXNIaWRlID0gdHJ1ZTtcbiAgICB9XG5cbiAgICBwcml2YXRlIHVwZGF0ZVBvc2l0aW9uKGxlZnQ6IG51bWJlciwgdG9wPzogbnVtYmVyKSB7XG4gICAgICAgIHRoaXMuaXNIaWRlID0gZmFsc2U7XG4gICAgICAgIHRoaXMucmVuZGVyZXIuc2V0U3R5bGUodGhpcy5lbGVtZW50UmVmLm5hdGl2ZUVsZW1lbnQsICd0b3AnLCBgJHt0b3B9cHhgKTtcbiAgICAgICAgdGhpcy5yZW5kZXJlci5zZXRTdHlsZSh0aGlzLmVsZW1lbnRSZWYubmF0aXZlRWxlbWVudCwgJ2xlZnQnLCBgJHtsZWZ0fXB4YCk7XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBoaWRlKCkge1xuICAgICAgICB0aGlzLmlzSGlkZSA9IHRydWU7XG4gICAgfVxufVxuIl19
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ElementRef, Renderer2 } from '@angular/core';
|
|
2
|
-
import { Editor } from 'slate';
|
|
3
|
-
import { TheContextService } from '../../services/context.service';
|
|
4
|
-
import { TheOptions } from '../../interfaces/editor';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export declare class ThePlaceholderComponent {
|
|
7
|
-
private renderer;
|
|
8
|
-
private elementRef;
|
|
9
|
-
private contextService;
|
|
10
|
-
editor: Editor;
|
|
11
|
-
options: TheOptions;
|
|
12
|
-
isHide: boolean;
|
|
13
|
-
handleCompositionStart(): void;
|
|
14
|
-
handleCompositionEnd(event: any): void;
|
|
15
|
-
constructor(renderer: Renderer2, elementRef: ElementRef, contextService: TheContextService);
|
|
16
|
-
checkStatus(): void;
|
|
17
|
-
private updatePosition;
|
|
18
|
-
private hide;
|
|
19
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ThePlaceholderComponent, never>;
|
|
20
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ThePlaceholderComponent, "div[thePlaceholder]", never, { "editor": "editor"; "options": "options"; }, {}, never, never>;
|
|
21
|
-
}
|