@worktile/theia 2.0.1 → 2.1.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.
Files changed (57) hide show
  1. package/bundles/worktile-theia.umd.js +366 -172
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/components/toolbar/toolbar.component.d.ts +4 -1
  4. package/components/toolbar/toolbar.component.scss +2 -0
  5. package/components/toolbar-dropdown/toolbar-dropdown.component.d.ts +7 -5
  6. package/components/toolbar-dropdown/toolbar-dropdown.component.scss +2 -0
  7. package/components/toolbar-item/toolbar-item.component.d.ts +3 -0
  8. package/constants/code.d.ts +3 -3
  9. package/constants/default.d.ts +0 -1
  10. package/constants/node-types.d.ts +17 -1
  11. package/custom-types.d.ts +3 -1
  12. package/editor.module.d.ts +5 -3
  13. package/esm2015/components/inline-toolbar/inline-toolbar.component.js +1 -1
  14. package/esm2015/components/text/text.component.js +7 -2
  15. package/esm2015/components/toolbar/toolbar.component.js +18 -6
  16. package/esm2015/components/toolbar-dropdown/toolbar-dropdown.component.js +14 -5
  17. package/esm2015/components/toolbar-group/toolbar-group.component.js +1 -1
  18. package/esm2015/components/toolbar-item/toolbar-item.component.js +20 -6
  19. package/esm2015/constants/code.js +2 -2
  20. package/esm2015/constants/default.js +1 -2
  21. package/esm2015/constants/node-types.js +32 -2
  22. package/esm2015/constants/toolbar.js +2 -1
  23. package/esm2015/custom-types.js +1 -1
  24. package/esm2015/editor.component.js +7 -6
  25. package/esm2015/editor.module.js +9 -3
  26. package/esm2015/interfaces/editor.js +1 -1
  27. package/esm2015/interfaces/toolbar.js +1 -1
  28. package/esm2015/plugins/align/options.js +2 -1
  29. package/esm2015/plugins/code/code.component.js +69 -32
  30. package/esm2015/plugins/code/code.editor.js +3 -9
  31. package/esm2015/plugins/deserializers/deserialize-md.plugin.js +2 -2
  32. package/esm2015/plugins/font-size/font-size.editor.js +47 -0
  33. package/esm2015/plugins/font-size/options.js +25 -0
  34. package/esm2015/plugins/heading/heading.editor.js +13 -2
  35. package/esm2015/plugins/heading/options.js +2 -1
  36. package/esm2015/plugins/index.js +3 -1
  37. package/esm2015/plugins/mark/mark.plugin.js +15 -10
  38. package/esm2015/plugins/table/table.editor.js +1 -1
  39. package/esm2015/services/toolbar.service.js +2 -2
  40. package/fesm2015/worktile-theia.js +316 -127
  41. package/fesm2015/worktile-theia.js.map +1 -1
  42. package/interfaces/editor.d.ts +3 -1
  43. package/interfaces/toolbar.d.ts +2 -1
  44. package/package.json +1 -1
  45. package/plugins/code/code.component.d.ts +15 -4
  46. package/plugins/code/code.component.scss +46 -7
  47. package/plugins/code/code.editor.d.ts +3 -2
  48. package/plugins/font-size/font-size.editor.d.ts +8 -0
  49. package/plugins/font-size/options.d.ts +2 -0
  50. package/plugins/font-size/toolbar-item.component.scss +14 -0
  51. package/plugins/heading/heading.editor.d.ts +1 -1
  52. package/plugins/table/table.editor.d.ts +1 -1
  53. package/queries/get-selection-marks.d.ts +1 -0
  54. package/styles/editor.scss +20 -1
  55. package/styles/index.scss +1 -0
  56. package/styles/typo.scss +2 -1
  57. package/transforms/set-marks.d.ts +1 -0
@@ -1,9 +1,10 @@
1
- import { ElementOptionsInfo } from './valid-children-types';
2
1
  import { Ancestor, Range, Path, Point, Node, Span, NodeEntry, Editor, Element, Text } from 'slate';
3
2
  import { AngularEditor, ViewType } from 'slate-angular';
4
3
  import { HistoryEditor } from 'slate-history';
4
+ import { ElementOptionsInfo } from './valid-children-types';
5
5
  import { Predicate } from '../utils/match';
6
6
  import { ToolbarOption } from './toolbar';
7
+ import { FontSizes } from '../constants/node-types';
7
8
  export interface TheEditor extends AngularEditor, HistoryEditor {
8
9
  renderElement: (element: Element) => ViewType;
9
10
  renderLeaf: (text: Text) => ViewType;
@@ -72,6 +73,7 @@ export interface TheOptions {
72
73
  isMustShowPlaceholder?: boolean;
73
74
  scrollContainer?: string;
74
75
  maxHeight?: number;
76
+ fontSize?: FontSizes;
75
77
  toolbar?: ToolbarOption;
76
78
  disablePlugins?: string[];
77
79
  extraElementOptions?: ElementOptionsInfo[];
@@ -20,7 +20,7 @@ interface ToolbarItemBase {
20
20
  key: ToolbarKey;
21
21
  execute?: (editor: Editor) => void;
22
22
  active?: (editor: Editor) => boolean | string;
23
- disable?: (editor: Editor) => boolean | string;
23
+ disable?: (editor: Editor) => boolean;
24
24
  transformToolbar?: (editor: Editor) => ToolbarDefinition | void;
25
25
  styles?: {
26
26
  [key: string]: string;
@@ -32,6 +32,7 @@ export interface CustomizeToolbarItem extends ToolbarItemBase {
32
32
  quickItemComponent?: ComponentType<any>;
33
33
  type?: ToolbarItemType;
34
34
  dropdownMode?: DropdownMode;
35
+ dropdownItemKey?: ToolbarKey;
35
36
  }
36
37
  export interface DefaultToolbarItem extends ToolbarItemBase {
37
38
  icon?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worktile/theia",
3
- "version": "2.0.1",
3
+ "version": "2.1.3",
4
4
  "description": "theia editor",
5
5
  "author": "YanDong <nanianqiumo@foxmail.com>",
6
6
  "homepage": "https://github.com/atinc/theia#readme",
@@ -2,24 +2,29 @@ import { ElementRef, ChangeDetectorRef, OnInit, AfterViewInit, NgZone } from '@a
2
2
  import { ThyNotifyService } from 'ngx-tethys/notify';
3
3
  import { Editor } from 'slate';
4
4
  import { CodeMirrorComponent } from 'ng-codemirror';
5
- import { DropdownMode, TheCodeMode } from '../../constants';
5
+ import { DropdownMode, TheCodeConfig, ToolbarItemMode } from '../../constants';
6
6
  import { DefaultToolbarItem, TheBaseElementComponent } from '../../interfaces';
7
7
  import { CodeElement } from '../../custom-types';
8
+ import { ThyResizeEvent } from 'ngx-tethys/resizable';
9
+ import { TheContextService } from '../../services/context.service';
8
10
  import * as i0 from "@angular/core";
9
11
  export declare class TheCodeComponent extends TheBaseElementComponent<CodeElement, Editor> implements OnInit, AfterViewInit {
10
12
  elementRef: ElementRef;
11
13
  cdr: ChangeDetectorRef;
12
14
  private thyNotifyService;
15
+ private contextService;
13
16
  private ngZone;
14
17
  private config;
15
18
  startRenderCodemirror: boolean;
16
19
  dropdownMode: typeof DropdownMode;
17
20
  maxHeight: number;
18
- codeMirrorFocused: boolean;
19
21
  menus: {
20
22
  key: string;
21
23
  name: string;
22
24
  }[];
25
+ ToolbarItemMode: typeof ToolbarItemMode;
26
+ isFocusCode: boolean;
27
+ resizeHeight: number;
23
28
  options: {
24
29
  mode: string;
25
30
  lineNumbers: boolean;
@@ -30,21 +35,27 @@ export declare class TheCodeComponent extends TheBaseElementComponent<CodeElemen
30
35
  cursorBlinkRate: number;
31
36
  };
32
37
  actives: DefaultToolbarItem;
38
+ resizeBounds: any;
33
39
  get code(): string;
34
40
  codemirror: CodeMirrorComponent;
35
41
  onContextChange(): void;
36
- constructor(elementRef: ElementRef, cdr: ChangeDetectorRef, thyNotifyService: ThyNotifyService, ngZone: NgZone, config: TheCodeMode);
42
+ constructor(elementRef: ElementRef, cdr: ChangeDetectorRef, thyNotifyService: ThyNotifyService, contextService: TheContextService, ngZone: NgZone, config: TheCodeConfig);
37
43
  ngOnInit(): void;
38
44
  ngAfterViewInit(): void;
39
45
  renderCodemirror(): void;
40
46
  initializeCodemirrorFocus(): void;
41
47
  codeChange($event: any): void;
42
- focusChange(codeMirrorFocused: boolean): void;
43
48
  onDelete(event: MouseEvent): void;
44
49
  onCopy(event: MouseEvent): void;
50
+ focusChange(codeMirrorFocused: boolean): void;
45
51
  onChangeLangulage: (item: any) => void;
46
52
  useMode(): void;
53
+ useAutoWrap(): void;
54
+ useHeight(): void;
47
55
  useReadonly(): void;
56
+ onResize({ height }: ThyResizeEvent): void;
57
+ onEndResize(): void;
58
+ onChangeWrap(value: boolean): void;
48
59
  static ɵfac: i0.ɵɵFactoryDeclaration<TheCodeComponent, never>;
49
60
  static ɵcmp: i0.ɵɵComponentDeclaration<TheCodeComponent, "div[theCode]", never, {}, {}, never, never>;
50
61
  }
@@ -1,18 +1,22 @@
1
1
  @import '~ng-codemirror/index.scss';
2
2
 
3
3
  .the-code-container {
4
- display: block;
5
- font-size: 14px;
6
- position: relative;
7
-
8
- .CodeMirror {
9
- height: auto;
4
+ .resize-code-container{
5
+ display: block;
6
+ font-size: 14px;
7
+ position: relative;
10
8
  counter-reset: codeblock-lm;
11
9
  border: 1px solid $gray-300;
12
10
  border-radius: 2px;
13
11
  color: $gray-600;
14
12
  background: rgba(243, 243, 243, 0.8);
13
+ }
14
+ .CodeMirror {
15
+ height: 100% !important;
15
16
  z-index: 0;
17
+ color: $gray-600;
18
+ background: transparent;
19
+ border: none;
16
20
 
17
21
  .CodeMirror-gutters {
18
22
  border-right: none;
@@ -30,7 +34,34 @@
30
34
  }
31
35
  .ng-codemirror-wrapper {
32
36
  display: block;
33
- overflow: hidden;
37
+ position: relative;
38
+ overflow-y: scroll;
39
+ height: 100%;
40
+ }
41
+
42
+ .code-resize-icon.thy-resizable-handle-bottom{
43
+ cursor: row-resize;
44
+ height: 8px;
45
+ width: 45px;
46
+ left: 50%;
47
+ transform: translateX(-50%);
48
+ background: $gray-300;
49
+ bottom: -5px;
50
+ border-radius: 5px;
51
+ position: absolute;
52
+ &::before, &:after{
53
+ content: '';
54
+ position: absolute;
55
+ width: 34px;
56
+ height: 1px;
57
+ background: $white;
58
+ left: 50%;
59
+ transform: translateX(-50%);
60
+ top: 2px;
61
+ }
62
+ &:after{
63
+ top: 5px;
64
+ }
34
65
  }
35
66
 
36
67
  @include the-toolbar-active();
@@ -39,5 +70,13 @@
39
70
  padding: 0;
40
71
  width: 100px;
41
72
  }
73
+
74
+ .auto-wrap{
75
+ padding-left: 8px;
76
+ .auto-wrap-btn{
77
+ margin-left: 5px;
78
+ transform: scale(0.8);
79
+ }
80
+ }
42
81
  }
43
82
 
@@ -1,7 +1,8 @@
1
1
  import { Editor } from 'slate';
2
2
  import { CodeElement } from '../../custom-types';
3
3
  export declare const CodeEditor: {
4
- setLanguage(editor: Editor, language: string, element: CodeElement): void;
5
- setCodeContent(editor: Editor, content: string, element: CodeElement): void;
4
+ setCodeAttribute(editor: Editor, element: CodeElement, value: {
5
+ [key: string]: unknown;
6
+ }): void;
6
7
  insertCode(editor: Editor): void;
7
8
  };
@@ -0,0 +1,8 @@
1
+ import { Editor } from 'slate';
2
+ import { TheEditor } from '../../interfaces/editor';
3
+ import { FontSizes } from '../../constants/node-types';
4
+ export declare const FontSizeEditor: {
5
+ setFontSize(editor: TheEditor, size: FontSizes): void;
6
+ isFontSizeActive(editor: Editor, size: FontSizes): boolean;
7
+ isDisabled(editor: TheEditor): boolean;
8
+ };
@@ -0,0 +1,2 @@
1
+ import { ToolbarItem } from '../../interfaces/toolbar';
2
+ export declare const FontSizeOptions: ToolbarItem[];
@@ -0,0 +1,14 @@
1
+ .the-toolbar-dropdown-container.font-size {
2
+ width: 45px;
3
+ }
4
+ .the-toolbar-dropdown-popover.font-size {
5
+ .thy-popover-container {
6
+ min-width: 90px;
7
+ }
8
+ .dropdown {
9
+ width: 90px;
10
+ }
11
+ .action-menu-item {
12
+ text-align: center;
13
+ }
14
+ }
@@ -1,5 +1,5 @@
1
1
  import { Editor } from 'slate';
2
- import { HeadingElementKinds } from '../../public-api';
2
+ import { HeadingElementKinds } from '../../interfaces/element';
3
3
  export declare const HeadingEditor: {
4
4
  setHeading(editor: Editor, heading: HeadingElementKinds): void;
5
5
  isHeadingActive(editor: Editor, heading: HeadingElementKinds): boolean;
@@ -17,7 +17,7 @@ export declare const TableEditor: {
17
17
  setAlign(editor: Editor, alignment: Alignment): boolean;
18
18
  setVerticalAlign(editor: TheEditor, alignment: VerticalAlignment): boolean;
19
19
  isVerticalAlignActive(editor: TheEditor, alignment: VerticalAlignment): boolean;
20
- toggleMark(editor: TheEditor, isActive: boolean, format: string | string[], value?: string | boolean): boolean;
20
+ toggleMark(editor: TheEditor, isActive: boolean, format: string | string[], value?: string | number | boolean): boolean;
21
21
  clearMark(editor: TheEditor): boolean;
22
22
  handleSelectedCells(editor: TheEditor, handle: (cellPath: Path, cellRange: Range) => void): boolean;
23
23
  isActiveHeader(editor: TheEditor): boolean;
@@ -8,4 +8,5 @@ export declare const getSelectionMarks: (editor: Editor) => {
8
8
  color?: any;
9
9
  "background-color"?: any;
10
10
  "code-line"?: any;
11
+ "font-size"?: any;
11
12
  };
@@ -126,6 +126,13 @@ $thy-icon-nav-link-margin-right: 5px;
126
126
  text-indent: 0;
127
127
  color: $gray-700;
128
128
  }
129
+
130
+ @each $size in 12, 13, 14, 15, 16, 18, 20, 24, 28, 32, 40, 48 {
131
+ [the-font-size="#{$size}"] {
132
+ font-size: #{$size}px;
133
+ line-height: $font-size-line-height;
134
+ }
135
+ }
129
136
  }
130
137
 
131
138
  .the-nav-split-line {
@@ -176,6 +183,17 @@ $thy-icon-nav-link-margin-right: 5px;
176
183
  }
177
184
  }
178
185
 
186
+ @mixin the-toolbar-disabled {
187
+ &.disabled {
188
+ cursor: not-allowed;
189
+ opacity: 0.25;
190
+
191
+ .thy-icon-nav-link {
192
+ pointer-events: none;
193
+ }
194
+ }
195
+ }
196
+
179
197
  @mixin the-toolbar-layout {
180
198
  position: absolute;
181
199
  padding: 5px 10px;
@@ -183,13 +201,14 @@ $thy-icon-nav-link-margin-right: 5px;
183
201
  box-shadow: $box-shadow;
184
202
  }
185
203
 
186
- .the-block-operation {
204
+ .the-code-block-operation {
187
205
  @include the-toolbar-layout();
188
206
  display: flex;
189
207
  transform: translateY(-100%);
190
208
  left: 0;
191
209
  top: -10px;
192
210
  z-index: 10;
211
+ min-width: 306px;
193
212
  .thy-select-custom {
194
213
  width: 115px;
195
214
  .form-control {
package/styles/index.scss CHANGED
@@ -18,3 +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/placeholder/placeholder.component.scss';
21
+ @import '../plugins/font-size/toolbar-item.component.scss';
package/styles/typo.scss CHANGED
@@ -16,6 +16,7 @@ $block-mb: 8px;
16
16
  $block-line-heith: 24px;
17
17
  $nav-item-margin: 5px;
18
18
  $selection-background: rgba($color: $primary, $alpha: 0.3);
19
+ $font-size-line-height: 1.5;
19
20
  .the-editor-typo {
20
21
  font-size: $the-font-size-base;
21
22
  min-height: 140px;
@@ -171,4 +172,4 @@ $selection-background: rgba($color: $primary, $alpha: 0.3);
171
172
  margin-left: 2em * $i;
172
173
  }
173
174
  }
174
- }
175
+ }
@@ -8,4 +8,5 @@ export declare const setMarks: (editor: Editor, marks: {
8
8
  color?: any;
9
9
  "background-color"?: any;
10
10
  "code-line"?: any;
11
+ "font-size"?: any;
11
12
  }, at?: Path | Point | Range) => void;