@worktile/theia 14.2.28 → 14.2.30

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.
@@ -6,7 +6,7 @@ import * as i2$2 from '@angular/forms';
6
6
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
7
7
  import * as i1 from 'slate-angular';
8
8
  import { BaseElementComponent, BaseTextComponent, NODE_TO_PARENT, NODE_TO_INDEX, AngularEditor, hotkeys, ELEMENT_TO_COMPONENT, IS_SAFARI, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, getPlainText as getPlainText$1, EDITOR_TO_ELEMENT, withAngular, SlateModule } from 'slate-angular';
9
- import { Element as Element$1, Editor, Range, Node, Span, Path, Text, Point, Transforms, Operation, createEditor } from 'slate';
9
+ import { Range, Element as Element$1, Editor, Node, Span, Path, Text, Point, Transforms, Operation, createEditor } from 'slate';
10
10
  import { map, cloneDeep, assign, defaults, groupBy, uniq, debounce } from 'lodash';
11
11
  import { isObject, isArray, isString } from 'ngx-tethys/util';
12
12
  import { TheiaConverter } from '@atinc/selene';
@@ -69,7 +69,27 @@ import { ThyNavModule } from 'ngx-tethys/nav';
69
69
  import { ThySelectModule } from 'ngx-tethys/select';
70
70
  import { ThyMenuModule } from 'ngx-tethys/menu';
71
71
 
72
+ const isGlobalCollapsed = (editor) => {
73
+ return editor && editor.selection && Range.isCollapsed(editor.selection);
74
+ };
75
+
72
76
  class TheBaseElementComponent extends BaseElementComponent {
77
+ onContextChange() {
78
+ super.onContextChange();
79
+ if (this.selection) {
80
+ this.nativeElement.classList.add(`slate-selected-element`);
81
+ if (this.isCollapsed && isGlobalCollapsed(this.editor)) {
82
+ this.nativeElement.classList.add(`slate-focus-element`);
83
+ }
84
+ else {
85
+ this.nativeElement.classList.remove(`slate-focus-element`);
86
+ }
87
+ }
88
+ else {
89
+ this.nativeElement.classList.remove(`slate-selected-element`);
90
+ this.nativeElement.classList.remove(`slate-focus-element`);
91
+ }
92
+ }
73
93
  ngOnInit() {
74
94
  this.context.attributes['data-slate-key'] = this.context.element.key;
75
95
  super.ngOnInit();
@@ -898,6 +918,11 @@ const getAnchorBlockEntry = (editor, at) => {
898
918
  });
899
919
  };
900
920
 
921
+ /**
922
+ * Is an ancestor empty (empty text and no inline children).
923
+ */
924
+ const isAncestorEmpty = (editor, node) => !Node.string(node) && !node.children.some(n => Editor.isInline(editor, n));
925
+
901
926
  const isEmptyParagraph = (editor, at) => {
902
927
  const entry = getAnchorBlockEntry(editor, at);
903
928
  if (!entry) {
@@ -906,6 +931,15 @@ const isEmptyParagraph = (editor, at) => {
906
931
  const [block] = entry;
907
932
  return Editor.isEmpty(editor, block) && block.type === ElementKinds.paragraph;
908
933
  };
934
+ const isEmptyParagraphElement = (editor, element) => {
935
+ const isParagraph = element.type === ElementKinds.paragraph;
936
+ const isEmpty = isAncestorEmpty(editor, element);
937
+ return isParagraph && isEmpty;
938
+ };
939
+ const isStrictEmptyParagraphElement = (editor, element) => {
940
+ const text = Node.string(element).replace(/(\s|\n)*$/g, '');
941
+ return isEmptyParagraphElement(editor, element) && text.length === 0;
942
+ };
909
943
 
910
944
  const isParagraph = (editor) => {
911
945
  const [match] = Editor.nodes(editor, {
@@ -1005,11 +1039,6 @@ const getBlockAbove = (editor, options = {}) => Editor.above(editor, {
1005
1039
  ...options
1006
1040
  }) || [editor, []];
1007
1041
 
1008
- /**
1009
- * Is an ancestor empty (empty text and no inline children).
1010
- */
1011
- const isAncestorEmpty = (editor, node) => !Node.string(node) && !node.children.some(n => Editor.isInline(editor, n));
1012
-
1013
1042
  /**
1014
1043
  * Is the block above the selection empty.
1015
1044
  */
@@ -2374,10 +2403,6 @@ const isEmptyContent = (children) => {
2374
2403
  return false;
2375
2404
  };
2376
2405
 
2377
- const isGlobalCollapsed = (editor) => {
2378
- return editor && editor.selection && Range.isCollapsed(editor.selection);
2379
- };
2380
-
2381
2406
  const isEmptyContentByFilter = (editor, rules) => {
2382
2407
  const { children } = editor;
2383
2408
  if (children.length < 1) {
@@ -2429,6 +2454,8 @@ var index$1 = /*#__PURE__*/Object.freeze({
2429
2454
  isAncestor: isAncestor,
2430
2455
  isCollapsed: isCollapsed,
2431
2456
  isEmptyParagraph: isEmptyParagraph,
2457
+ isEmptyParagraphElement: isEmptyParagraphElement,
2458
+ isStrictEmptyParagraphElement: isStrictEmptyParagraphElement,
2432
2459
  isParagraph: isParagraph,
2433
2460
  isBlockActive: isBlockActive,
2434
2461
  isIncludeTypes: isIncludeTypes,