@worktile/theia 1.2.12 → 1.2.16

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 (50) hide show
  1. package/bundles/worktile-theia.umd.js +312 -127
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/components/inline-toolbar/inline-toolbar.component.d.ts +3 -1
  4. package/constants/default.d.ts +0 -1
  5. package/editor.component.d.ts +1 -0
  6. package/esm2015/components/inline-toolbar/inline-toolbar.component.js +10 -7
  7. package/esm2015/components/toolbar-item/toolbar-item.component.js +7 -3
  8. package/esm2015/constants/default.js +1 -2
  9. package/esm2015/editor.component.js +23 -12
  10. package/esm2015/interfaces/editor.js +1 -1
  11. package/esm2015/interfaces/toolbar.js +1 -1
  12. package/esm2015/plugins/code/code.component.js +4 -1
  13. package/esm2015/plugins/common/block-card.plugin.js +51 -5
  14. package/esm2015/plugins/deserializers/deserialize-html.plugin.js +7 -1
  15. package/esm2015/plugins/deserializers/deserialize-md.plugin.js +7 -2
  16. package/esm2015/plugins/index.js +14 -2
  17. package/esm2015/plugins/mark/options.js +6 -1
  18. package/esm2015/plugins/paint-format/options.js +4 -1
  19. package/esm2015/plugins/placeholder/placeholder.component.js +19 -12
  20. package/esm2015/plugins/quick-insert/components/quick-insert.component.js +7 -6
  21. package/esm2015/plugins/soft-break/soft-break.plugin.js +18 -0
  22. package/esm2015/plugins/soft-break/soft-break.types.js +2 -0
  23. package/esm2015/plugins/table/table.editor.js +10 -2
  24. package/esm2015/plugins/table/table.plugin.js +84 -71
  25. package/esm2015/plugins/table/utils/calc-span.js +2 -2
  26. package/esm2015/plugins/table/utils/normalize-table.js +31 -0
  27. package/esm2015/plugins/table/utils/table-position.js +5 -2
  28. package/esm2015/queries/is-empty-paragraph.js +6 -2
  29. package/esm2015/services/context.service.js +10 -2
  30. package/esm2015/utils/auto-focus.js +2 -2
  31. package/esm2015/utils/common.js +3 -0
  32. package/esm2015/utils/fragment.js +5 -2
  33. package/esm2015/utils/index.js +2 -1
  34. package/fesm2015/worktile-theia.js +300 -114
  35. package/fesm2015/worktile-theia.js.map +1 -1
  36. package/interfaces/editor.d.ts +2 -0
  37. package/interfaces/toolbar.d.ts +1 -0
  38. package/package.json +1 -1
  39. package/plugins/image/image.component.scss +172 -168
  40. package/plugins/placeholder/placeholder.component.d.ts +4 -2
  41. package/plugins/soft-break/soft-break.plugin.d.ts +4 -0
  42. package/plugins/soft-break/soft-break.types.d.ts +8 -0
  43. package/plugins/table/table.editor.d.ts +2 -0
  44. package/plugins/table/utils/calc-span.d.ts +1 -1
  45. package/plugins/table/utils/normalize-table.d.ts +2 -0
  46. package/services/context.service.d.ts +2 -0
  47. package/styles/editor.scss +3 -3
  48. package/styles/typo.scss +5 -2
  49. package/utils/common.d.ts +2 -0
  50. package/utils/index.d.ts +1 -0
@@ -8,7 +8,7 @@ import * as i1 from 'slate-angular';
8
8
  import { BaseTextComponent, BaseElementComponent, AngularEditor, NODE_TO_PARENT, NODE_TO_INDEX, IS_SAFARI, hotkeys, getPlainText as getPlainText$1, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, ELEMENT_TO_COMPONENT, EDITOR_TO_ELEMENT, isComponentType, withAngular, SlateModule } from 'slate-angular';
9
9
  import { mixinUnsubscribe, MixinBase } from 'ngx-tethys/core';
10
10
  import isHotkey from 'is-hotkey';
11
- import { Element as Element$1, Editor, Range, Node, Span, Path, Text, Point, Transforms, createEditor } from 'slate';
11
+ import { Element as Element$1, Editor, Range, Node, Span, Path, Text, Point, Transforms, Operation, createEditor } from 'slate';
12
12
  import { HistoryEditor, withHistory } from 'slate-history';
13
13
  import { __rest, __awaiter } from 'tslib';
14
14
  import * as _lodash from 'lodash';
@@ -64,7 +64,6 @@ const TAB_SPACE = ' ';
64
64
  const ZERO_WIDTH_CHAR = '\u200B';
65
65
  const CLIPBOARD_FORMAT_KEY = 'x-theia-fragment';
66
66
  const DEFAULT_SCROLL_CONTAINER = '.the-editable-container';
67
- const BLOCK_INSERT_ORIGIN = 'block-insert';
68
67
  const ELEMENT_UNIQUE_ID = 'key';
69
68
  var TheMode;
70
69
  (function (TheMode) {
@@ -500,7 +499,11 @@ const getAnchorBlockEntry = (editor, at) => {
500
499
  };
501
500
 
502
501
  const isEmptyParagraph = (editor, at) => {
503
- const [block] = getAnchorBlockEntry(editor, at);
502
+ const entry = getAnchorBlockEntry(editor, at);
503
+ if (!entry) {
504
+ return false;
505
+ }
506
+ const [block] = entry;
504
507
  return Editor.isEmpty(editor, block) && block.type === ElementKinds.paragraph;
505
508
  };
506
509
 
@@ -1040,7 +1043,10 @@ const extractFragment = (data, deleteKey = ELEMENT_UNIQUE_ID) => {
1040
1043
  const fragment = data.getData(`application/${CLIPBOARD_FORMAT_KEY}`);
1041
1044
  if (fragment) {
1042
1045
  const decoded = decodeURIComponent(window.atob(fragment));
1043
- const nodes = JSON.parse(decoded);
1046
+ let nodes = JSON.parse(decoded);
1047
+ if (!Array.isArray(nodes)) {
1048
+ nodes = [nodes];
1049
+ }
1044
1050
  // delete key to avoid duplicate keys
1045
1051
  if (deleteKey) {
1046
1052
  deleteElementKey(nodes, deleteKey);
@@ -1954,6 +1960,9 @@ const getToolbarClass = (editor) => {
1954
1960
  return `the-toolbar-${uuid}`;
1955
1961
  };
1956
1962
 
1963
+ const IS_MAC = typeof window != 'undefined' && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
1964
+ const CONTROL_KEY = IS_MAC ? '⌘' : 'Ctrl';
1965
+
1957
1966
  const withDeserializeMd = (options) => (editor) => {
1958
1967
  const { insertData, onKeydown } = editor;
1959
1968
  editor.onKeydown = (event) => {
@@ -1994,8 +2003,13 @@ const withDeserializeMd = (options) => (editor) => {
1994
2003
  });
1995
2004
  return;
1996
2005
  }
2006
+ else {
2007
+ closeConversionHint(editor);
2008
+ }
2009
+ }
2010
+ catch (error) {
2011
+ closeConversionHint(editor);
1997
2012
  }
1998
- catch (error) { }
1999
2013
  }
2000
2014
  },
2001
2015
  origin,
@@ -2230,10 +2244,18 @@ class TheContextService {
2230
2244
  }
2231
2245
  getOptions() {
2232
2246
  if (!this.options.width) {
2233
- this.options.width = this.options.nativeElement.querySelector('.slate-editable-container').firstElementChild.offsetWidth;
2247
+ const firstElementChild = this.getFirstElementChild();
2248
+ this.options.width = firstElementChild.offsetWidth;
2234
2249
  }
2235
2250
  return this.options;
2236
2251
  }
2252
+ getEditableElement() {
2253
+ return this.options.nativeElement.querySelector('.the-editor-typo');
2254
+ }
2255
+ getFirstElementChild() {
2256
+ const editableElement = this.getEditableElement();
2257
+ return editableElement === null || editableElement === void 0 ? void 0 : editableElement.firstElementChild;
2258
+ }
2237
2259
  setUploadFileList(file) {
2238
2260
  this.fileList.push(file);
2239
2261
  }
@@ -4186,20 +4208,66 @@ const withBlockCard = (editor) => {
4186
4208
  // block card cursor
4187
4209
  if (anchorNode && hasBlockCard(domSelection)) {
4188
4210
  const isCardLeftCursor = isCardLeft(anchorNode);
4189
- // + left-block-card 或者 → + right-block-card
4190
- if ((isMoveDown && isCardLeftCursor) || (isMoveForward && !isCardLeftCursor)) {
4211
+ if (isMoveUp) {
4212
+ const [, path] = AngularEditor.toSlateCardEntry(editor, anchorNode);
4213
+ const previousPath = Path.hasPrevious(path) && Path.previous(path);
4214
+ const previousNode = previousPath && getNode(editor, previousPath);
4215
+ if (previousNode && editor.isBlockCard(previousNode)) {
4216
+ AngularEditor.moveBlockCard(editor, previousNode, { direction: isCardLeftCursor ? 'left' : 'right' });
4217
+ }
4218
+ else {
4219
+ const before = Editor.before(editor, path);
4220
+ if (before) {
4221
+ Transforms.select(editor, before);
4222
+ }
4223
+ }
4191
4224
  nativeEvent.preventDefault();
4225
+ return;
4226
+ }
4227
+ if (isMoveDown) {
4192
4228
  const [, path] = AngularEditor.toSlateCardEntry(editor, anchorNode);
4229
+ const nextPath = Path.next(path);
4230
+ const nextNode = getNode(editor, nextPath);
4231
+ if (nextNode && editor.isBlockCard(nextNode)) {
4232
+ AngularEditor.moveBlockCard(editor, nextNode, { direction: isCardLeftCursor ? 'left' : 'right' });
4233
+ }
4234
+ else {
4235
+ const after = Editor.after(editor, path);
4236
+ if (after) {
4237
+ Transforms.select(editor, Editor.after(editor, path));
4238
+ }
4239
+ }
4240
+ nativeEvent.preventDefault();
4241
+ return;
4242
+ }
4243
+ // → + right-block-card
4244
+ if ((isMoveForward && !isCardLeftCursor)) {
4245
+ nativeEvent.preventDefault();
4246
+ const [, path] = AngularEditor.toSlateCardEntry(editor, anchorNode);
4247
+ const nextPath = Path.next(path);
4248
+ const nextNode = getNode(editor, nextPath);
4249
+ if (nextNode && editor.isBlockCard(nextNode)) {
4250
+ event.preventDefault();
4251
+ AngularEditor.moveBlockCard(editor, nextNode, { direction: 'left' });
4252
+ return;
4253
+ }
4193
4254
  const after = Editor.after(editor, path);
4194
4255
  if (after) {
4195
4256
  Transforms.select(editor, Editor.after(editor, path));
4196
4257
  }
4197
4258
  return;
4198
4259
  }
4199
- // ↑ + right-block-card 或者 ← + left-block-card
4200
- if ((isMoveUp && !isCardLeftCursor) || (isMoveBackward && isCardLeftCursor)) {
4260
+ // ← + left-block-card
4261
+ if (isMoveBackward && isCardLeftCursor) {
4201
4262
  nativeEvent.preventDefault();
4202
4263
  const [, path] = AngularEditor.toSlateCardEntry(editor, anchorNode);
4264
+ const previousPath = Path.hasPrevious(path) && Path.previous(path);
4265
+ const previousNode = previousPath && getNode(editor, previousPath);
4266
+ if (previousNode && editor.isBlockCard(previousNode)) {
4267
+ event.preventDefault();
4268
+ AngularEditor.moveBlockCard(editor, previousNode, { direction: 'right' });
4269
+ return;
4270
+ }
4203
4271
  const before = Editor.before(editor, path);
4204
4272
  if (before) {
4205
4273
  Transforms.select(editor, before);
@@ -4581,11 +4649,14 @@ class TablePosition {
4581
4649
  columnIndex++;
4582
4650
  nextCell = this.table.children[rowIndex].children[columnIndex];
4583
4651
  }
4584
- else {
4652
+ else if (rowIndex + 1 < this.getHeight()) {
4585
4653
  columnIndex = 0;
4586
4654
  rowIndex++;
4587
4655
  nextCell = this.table.children[rowIndex].children[columnIndex];
4588
4656
  }
4657
+ else {
4658
+ nextCell = null;
4659
+ }
4589
4660
  }
4590
4661
  return nextCell;
4591
4662
  }
@@ -4736,7 +4807,7 @@ function calcSpanForColumn(table, targetIndex) {
4736
4807
  return rowspans.some(rowspan => isInside(rowspan, rowIndx, targetIndex));
4737
4808
  });
4738
4809
  }
4739
- function calcOriginSpan(table, targetRowIndex, targetColumnIndex) {
4810
+ function getOriginCell(table, targetRowIndex, targetColumnIndex) {
4740
4811
  for (let rowIndex = 0; rowIndex <= targetRowIndex; rowIndex++) {
4741
4812
  const row = table.children[rowIndex];
4742
4813
  const originCell = row.children
@@ -5234,6 +5305,13 @@ const TableEditor = {
5234
5305
  isActiveHeader(editor) {
5235
5306
  const [tableRowEntry] = Editor.nodes(editor, { match: (n) => n.type === ElementKinds.tableRow });
5236
5307
  return tableRowEntry && tableRowEntry[0] && tableRowEntry[0].header;
5308
+ },
5309
+ selectOriginCell(editor, table, rowIndex, columnIndex, isStart) {
5310
+ const origin = getOriginCell(table, rowIndex, columnIndex);
5311
+ if (origin) {
5312
+ const path = AngularEditor.findPath(editor, origin);
5313
+ Transforms.select(editor, isStart ? Editor.start(editor, path) : Editor.end(editor, path));
5314
+ }
5237
5315
  }
5238
5316
  };
5239
5317
 
@@ -5269,6 +5347,7 @@ const MarkOptions = [
5269
5347
  key: MarkTypes.bold,
5270
5348
  icon: 'bold',
5271
5349
  name: '加粗',
5350
+ shortcutKey: `${CONTROL_KEY}+B`,
5272
5351
  execute: editor => MarkEditor.toggleMark(editor, MarkTypes.bold),
5273
5352
  active: editor => MarkEditor.isMarkActive(editor, MarkTypes.bold)
5274
5353
  },
@@ -5276,6 +5355,7 @@ const MarkOptions = [
5276
5355
  key: MarkTypes.italic,
5277
5356
  icon: 'italic',
5278
5357
  name: '斜体',
5358
+ shortcutKey: `${CONTROL_KEY}+I`,
5279
5359
  execute: editor => MarkEditor.toggleMark(editor, MarkTypes.italic),
5280
5360
  active: editor => MarkEditor.isMarkActive(editor, MarkTypes.italic)
5281
5361
  },
@@ -5290,6 +5370,7 @@ const MarkOptions = [
5290
5370
  key: MarkTypes.underline,
5291
5371
  icon: 'underline',
5292
5372
  name: '下划线',
5373
+ shortcutKey: `${CONTROL_KEY}+U`,
5293
5374
  execute: editor => MarkEditor.toggleMark(editor, MarkTypes.underline),
5294
5375
  active: editor => MarkEditor.isMarkActive(editor, MarkTypes.underline)
5295
5376
  },
@@ -5297,6 +5378,7 @@ const MarkOptions = [
5297
5378
  key: MarkTypes.codeLine,
5298
5379
  icon: 'code',
5299
5380
  name: '行内代码',
5381
+ shortcutKey: `${CONTROL_KEY}+E`,
5300
5382
  execute: editor => MarkEditor.toggleMark(editor, MarkTypes.codeLine),
5301
5383
  active: editor => MarkEditor.isMarkActive(editor, MarkTypes.codeLine)
5302
5384
  }
@@ -6264,6 +6346,9 @@ class TheCodeComponent extends TheBaseElementComponent {
6264
6346
  if (this.options.mode !== this.element.language) {
6265
6347
  this.useMode();
6266
6348
  }
6349
+ if (!this.readonly && this.isCollapsed) {
6350
+ this.initializeCodemirrorFocus();
6351
+ }
6267
6352
  }
6268
6353
  }
6269
6354
  ngOnInit() {
@@ -9761,8 +9846,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
9761
9846
  args: ['cellInner', { static: true }]
9762
9847
  }] } });
9763
9848
 
9849
+ const normalizeTable = (table) => {
9850
+ const normalizedNodes = [];
9851
+ const rowHeight = table.children.length;
9852
+ const columnWidth = table.children[0].children.length;
9853
+ table.children.forEach((row, rowIndex) => {
9854
+ row.children.forEach((cell, columnIndex) => {
9855
+ // case 1
9856
+ if (cell.colspan || cell.rowspan) {
9857
+ const rowspan = cell.rowspan || 1;
9858
+ const colspan = cell.colspan || 1;
9859
+ if (rowspan > rowHeight - rowIndex) {
9860
+ cell.rowspan = rowHeight - rowIndex;
9861
+ }
9862
+ if (colspan > columnWidth - columnIndex) {
9863
+ cell.colspan = columnWidth - columnIndex;
9864
+ }
9865
+ return;
9866
+ }
9867
+ // case 2
9868
+ if (cell.hidden && !normalizedNodes.includes(cell)) {
9869
+ const origin = getOriginCell(table, rowIndex, columnIndex);
9870
+ if (!origin) {
9871
+ delete table.children[rowIndex].children[columnIndex].hidden;
9872
+ }
9873
+ }
9874
+ });
9875
+ });
9876
+ return table;
9877
+ };
9878
+
9764
9879
  const withTable = (editor) => {
9765
- const { deleteBackward, deleteForward, onKeydown, setFragmentData, insertData, normalizeNode, isBlockCard, renderElement, deleteCutData, isContainer } = editor;
9880
+ const { deleteBackward, deleteForward, onKeydown, setFragmentData, insertData, normalizeNode, isBlockCard, renderElement, deleteCutData, isContainer, onChange } = editor;
9766
9881
  editor.deleteBackward = unit => {
9767
9882
  const opts = new TableOptions$1();
9768
9883
  if (!isSelectionInTable(opts, editor)) {
@@ -9833,13 +9948,11 @@ const withTable = (editor) => {
9833
9948
  const aboveCell = aboveRow && aboveRow.children[startPosition.getColumnIndex()];
9834
9949
  if (aboveCell) {
9835
9950
  if (aboveCell.hidden) {
9836
- const originSpan = calcOriginSpan(endPosition.table, startPosition.getRowIndex() - 1, startPosition.getColumnIndex());
9837
- if (originSpan) {
9838
- at = Editor.start(editor, TheEditor.findPath(editor, originSpan));
9839
- }
9951
+ TableEditor.selectOriginCell(editor, startPosition.table, startPosition.getRowIndex() - 1, startPosition.getColumnIndex(), false);
9952
+ return;
9840
9953
  }
9841
9954
  else {
9842
- at = Editor.start(editor, TheEditor.findPath(editor, aboveCell));
9955
+ at = Editor.end(editor, TheEditor.findPath(editor, aboveCell));
9843
9956
  }
9844
9957
  }
9845
9958
  else {
@@ -9868,10 +9981,8 @@ const withTable = (editor) => {
9868
9981
  const belowCell = belowRow && belowRow.children[startPosition.getColumnIndex()];
9869
9982
  if (belowCell) {
9870
9983
  if (belowCell.hidden) {
9871
- const originSpan = calcOriginSpan(endPosition.table, belowRowIndex, startPosition.getColumnIndex());
9872
- if (originSpan) {
9873
- at = Editor.start(editor, TheEditor.findPath(editor, originSpan));
9874
- }
9984
+ TableEditor.selectOriginCell(editor, startPosition.table, startPosition.getRowIndex() + 1, startPosition.getColumnIndex(), true);
9985
+ return;
9875
9986
  }
9876
9987
  else {
9877
9988
  at = Editor.start(editor, TheEditor.findPath(editor, belowCell));
@@ -9890,18 +10001,27 @@ const withTable = (editor) => {
9890
10001
  const beforePoint = Editor.before(editor, editor.selection);
9891
10002
  const beforePosition = beforePoint && TablePosition.create(opts, editor, beforePoint.path);
9892
10003
  if (beforePosition && beforePosition.cell && beforePosition.cell.hidden) {
10004
+ event.preventDefault();
9893
10005
  const at = Editor.end(editor, TheEditor.findPath(editor, beforePosition.findPrevious()));
9894
10006
  Transforms.select(editor, at);
9895
- event.preventDefault();
9896
10007
  }
9897
10008
  }
9898
10009
  if (isMoveForward) {
9899
10010
  const afterPoint = Editor.after(editor, editor.selection);
9900
10011
  const afterPosition = afterPoint && TablePosition.create(opts, editor, afterPoint.path);
9901
10012
  if (afterPosition.cell && afterPosition.cell.hidden) {
9902
- const at = Editor.start(editor, TheEditor.findPath(editor, afterPosition.findNext()));
9903
- Transforms.select(editor, at);
9904
10013
  event.preventDefault();
10014
+ const nextCell = afterPosition.findNext();
10015
+ if (nextCell) {
10016
+ const at = Editor.start(editor, TheEditor.findPath(editor, afterPosition.findNext()));
10017
+ Transforms.select(editor, at);
10018
+ event.preventDefault();
10019
+ }
10020
+ else {
10021
+ AngularEditor.moveBlockCard(editor, startPosition.tableEntry[0], { direction: 'right' });
10022
+ event.preventDefault();
10023
+ }
10024
+ return;
9905
10025
  }
9906
10026
  }
9907
10027
  // Prevent deleting cells in the table
@@ -9938,67 +10058,45 @@ const withTable = (editor) => {
9938
10058
  return;
9939
10059
  }
9940
10060
  const { selection } = editor;
9941
- const element = TablePosition.create(opts, editor, selection.anchor.path);
9942
- const tableComponent = ELEMENT_TO_COMPONENT.get(element.table);
10061
+ const tablePosition = TablePosition.create(opts, editor, selection.anchor.path);
10062
+ const tableComponent = ELEMENT_TO_COMPONENT.get(tablePosition.table);
9943
10063
  const cells = tableComponent.tableStore.selectedCells;
9944
- const tableContent = {};
9945
- let contents;
9946
- let cellNode;
9947
- let fragment;
9948
- if (cells.length > 0) {
9949
- const selectNodes = getSelectCellNode(editor, cells);
9950
- const selectedColumnsIndex = tableComponent.tableStore.selectedColumnsIndex || [];
9951
- const selectedRowsIndex = tableComponent.tableStore.selectedRowsIndex || [];
10064
+ let tableFragment = null;
10065
+ if (tableComponent.tableStore.selectedRowsIndex.length > 0) {
10066
+ const rows = tablePosition.table.children.slice(tableComponent.tableStore.selectedRowsIndex[0], tableComponent.tableStore.selectedRowsIndex[tableComponent.tableStore.selectedRowsIndex.length - 1] + 1);
10067
+ tableFragment = Object.assign(Object.assign({}, tablePosition.table), { children: rows });
10068
+ }
10069
+ else if (cells.length > 0) {
10070
+ const tempRows = {};
9952
10071
  for (const cell of cells) {
9953
10072
  const { row, col } = cell;
9954
- const cellPath = [...element.tableEntry[1], row, col];
9955
- cellNode = Node.get(editor, cellPath);
9956
- const cellRange = Editor.range(editor, cellPath);
9957
- const domRange = AngularEditor.toDOMRange(editor, cellRange);
9958
- if (!contents) {
9959
- contents = domRange.cloneContents();
10073
+ const cellPath = [...tablePosition.tableEntry[1], row, col];
10074
+ const cellNode = Node.get(editor, cellPath);
10075
+ if (!tempRows[row]) {
10076
+ tempRows[row] = [];
9960
10077
  }
9961
- else {
9962
- contents.append(domRange.cloneContents());
9963
- }
9964
- if ((selectedColumnsIndex.length === 1 && cellNode.colspan > 1) ||
9965
- (selectedRowsIndex.length === 1 && cellNode.rowspan > 1)) {
9966
- cellNode = Object.assign(Object.assign({}, cellNode), { colspan: selectedColumnsIndex.length === 1 ? null : cellNode.colspan, rowspan: selectedRowsIndex.length === 1 ? null : cellNode.rowspan });
9967
- }
9968
- if (cellNode.hidden) {
9969
- const origin = calcOriginSpan(element.table, row, col);
9970
- const selectedOrigin = origin && selectNodes.filter(item => item.node.key === origin.key);
9971
- if (!selectedOrigin || !selectedOrigin.length) {
9972
- cellNode = Object.assign(Object.assign({}, cellNode), { hidden: null });
9973
- }
9974
- }
9975
- if (!tableContent[row]) {
9976
- tableContent[row] = [];
9977
- }
9978
- tableContent[row].push(cellNode);
10078
+ tempRows[row].push(cellNode);
9979
10079
  }
9980
- const tableFragment = [
10080
+ const rows = Object.values(tempRows).map((item) => {
10081
+ return {
10082
+ type: ElementKinds.tableRow,
10083
+ children: item
10084
+ };
10085
+ });
10086
+ tableFragment =
9981
10087
  {
9982
10088
  type: ElementKinds.table,
9983
- children: Object.values(tableContent).map((item) => {
9984
- return {
9985
- type: ElementKinds.tableRow,
9986
- children: item
9987
- };
9988
- })
9989
- }
9990
- ];
9991
- fragment = tableFragment;
9992
- const stringObj = JSON.stringify(fragment);
10089
+ children: rows
10090
+ };
10091
+ }
10092
+ if (tableFragment) {
10093
+ tableFragment = normalizeTable(_.cloneDeep(tableFragment));
10094
+ const plainText = Node.string(tableFragment);
10095
+ tableFragment = [tableFragment];
10096
+ const stringObj = JSON.stringify(tableFragment);
9993
10097
  const encoded = window.btoa(encodeURIComponent(stringObj));
9994
10098
  unit.setData(`application/${CLIPBOARD_FORMAT_KEY}`, encoded);
9995
- const div = document.createElement('div');
9996
- div.appendChild(contents);
9997
- div.setAttribute('hidden', 'true');
9998
- document.body.appendChild(div);
9999
- unit.setData('text/html', div.innerHTML);
10000
- unit.setData('text/plain', getPlainText$1(div));
10001
- document.body.removeChild(div);
10099
+ unit.setData('text/plain', plainText);
10002
10100
  return;
10003
10101
  }
10004
10102
  setFragmentData(unit);
@@ -10023,7 +10121,7 @@ const withTable = (editor) => {
10023
10121
  for (let j = selectColIndex; j <= lastColIndex; j++) {
10024
10122
  const row = tablePosition.table.children[i];
10025
10123
  if (row && row.children[j]) {
10026
- const originCell = calcOriginSpan(tablePosition.table, i, j);
10124
+ const originCell = getOriginCell(tablePosition.table, i, j);
10027
10125
  if (originCell && (originCell.colspan || originCell.rowspan)) {
10028
10126
  const path = TheEditor.findPath(editor, originCell).slice(-2);
10029
10127
  resetTableCell(editor, tablePosition.table, originCell, path[0], path[1]);
@@ -10081,6 +10179,21 @@ const withTable = (editor) => {
10081
10179
  Transforms.setNodes(editor, { columns }, { at: entry[1] });
10082
10180
  }
10083
10181
  }
10182
+ // adjust selection when selection is in hidden cell
10183
+ if (Element$1.isElement(entry[0]) && entry[0].type === ElementKinds.tableCell && entry[0].hidden) {
10184
+ if (editor.selection && Range.isCollapsed(editor.selection) && Path.isAncestor(entry[1], editor.selection.anchor.path)) {
10185
+ setTimeout(() => {
10186
+ const opts = new TableOptions$1();
10187
+ const tablePosition = TablePosition.create(opts, editor, editor.selection.anchor.path);
10188
+ const origin = getOriginCell(tablePosition.table, tablePosition.getRowIndex(), tablePosition.getColumnIndex());
10189
+ if (origin) {
10190
+ const path = AngularEditor.findPath(editor, origin);
10191
+ Transforms.select(editor, Editor.end(editor, path));
10192
+ }
10193
+ }, 0);
10194
+ return;
10195
+ }
10196
+ }
10084
10197
  normalizeNode(entry);
10085
10198
  };
10086
10199
  editor.isBlockCard = (element) => {
@@ -10128,6 +10241,20 @@ const withTable = (editor) => {
10128
10241
  editor.isContainer = (element) => {
10129
10242
  return element.type === ElementKinds.tableCell ? true : isContainer(element);
10130
10243
  };
10244
+ editor.onChange = () => {
10245
+ onChange();
10246
+ // adujst selection when selection is in hidden cell
10247
+ // just hook set_selection
10248
+ const isCollapsed = editor.selection && Range.isCollapsed(editor.selection);
10249
+ const isSelectionOperation = editor.operations.every(op => Operation.isSelectionOperation(op));
10250
+ if (isCollapsed && isSelectionOperation) {
10251
+ const opts = new TableOptions$1();
10252
+ const tablePosition = TablePosition.create(opts, editor, editor.selection.anchor.path);
10253
+ if (tablePosition.isInTable() && tablePosition.cell.hidden) {
10254
+ TableEditor.selectOriginCell(editor, tablePosition.table, tablePosition.getRowIndex(), tablePosition.getColumnIndex(), false);
10255
+ }
10256
+ }
10257
+ };
10131
10258
  return editor;
10132
10259
  };
10133
10260
 
@@ -10162,6 +10289,12 @@ const withDeserializeHMTL = (editor) => {
10162
10289
  insertData(data);
10163
10290
  return;
10164
10291
  }
10292
+ // 识出纯图片并且粘贴板中存在文件则不进行处理, hook 直接右键复制图片的场景,流转到上传图片流程
10293
+ // 后续需要做识别html图片后自动上传处理
10294
+ if (fragment.length === 1 && fragment[0].type === ElementKinds.image && data.files.length > 0) {
10295
+ insertData(data);
10296
+ return;
10297
+ }
10165
10298
  // 过滤 text 节点的 color/background-color 属性
10166
10299
  fragment.forEach((node) => deleteColorAndBackgroundColorOfText(node));
10167
10300
  Transforms.insertFragment(editor, fragment);
@@ -10377,12 +10510,14 @@ const PaintFormatOptions = [
10377
10510
  key: ToolbarActionTypes.undo,
10378
10511
  icon: 'undo',
10379
10512
  name: '撤销',
10513
+ shortcutKey: `${CONTROL_KEY}+Z`,
10380
10514
  execute: (editor) => editor.undo()
10381
10515
  },
10382
10516
  {
10383
10517
  key: ToolbarActionTypes.redo,
10384
10518
  icon: 'redo',
10385
10519
  name: '重做',
10520
+ shortcutKey: `${CONTROL_KEY}+Shift+Z`,
10386
10521
  execute: (editor) => editor.redo()
10387
10522
  },
10388
10523
  {
@@ -10493,7 +10628,8 @@ TheToolbarItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0"
10493
10628
  <a
10494
10629
  thyIconNavLink
10495
10630
  [thyIconNavLinkIcon]="item.icon"
10496
- [thyTooltip]="item.name"
10631
+ [thyTooltip]="tooltip"
10632
+ [thyTooltipTemplateContext]="{ name: item.name, shortcutKey: item.shortcutKey }"
10497
10633
  thyTooltipPlacement="top"
10498
10634
  [thyIconNavLinkActive]="active"
10499
10635
  (mousedown)="execute($event)"
@@ -10505,6 +10641,7 @@ TheToolbarItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0"
10505
10641
  <span class="quick-toolbar-name">{{ item?.name }}</span>
10506
10642
  </ng-container>
10507
10643
  </ng-template>
10644
+ <ng-template #tooltip let-data> {{ data.name }} {{ data.shortcutKey }} </ng-template>
10508
10645
  <ng-container #toolbarContainer></ng-container>
10509
10646
  `, isInline: true, components: [{ type: i2.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: i4$1.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }] });
10510
10647
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheToolbarItemComponent, decorators: [{
@@ -10516,7 +10653,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
10516
10653
  <a
10517
10654
  thyIconNavLink
10518
10655
  [thyIconNavLinkIcon]="item.icon"
10519
- [thyTooltip]="item.name"
10656
+ [thyTooltip]="tooltip"
10657
+ [thyTooltipTemplateContext]="{ name: item.name, shortcutKey: item.shortcutKey }"
10520
10658
  thyTooltipPlacement="top"
10521
10659
  [thyIconNavLinkActive]="active"
10522
10660
  (mousedown)="execute($event)"
@@ -10528,6 +10666,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
10528
10666
  <span class="quick-toolbar-name">{{ item?.name }}</span>
10529
10667
  </ng-container>
10530
10668
  </ng-template>
10669
+ <ng-template #tooltip let-data> {{ data.name }} {{ data.shortcutKey }} </ng-template>
10531
10670
  <ng-container #toolbarContainer></ng-container>
10532
10671
  `,
10533
10672
  host: {
@@ -10691,6 +10830,22 @@ const withQuickInsert = (editor) => {
10691
10830
  return editor;
10692
10831
  };
10693
10832
 
10833
+ const withSoftBreak = (options = { rules: [{ hotkey: 'shift+enter' }] }) => (editor) => {
10834
+ const { onKeydown } = editor;
10835
+ editor.onKeydown = (event) => {
10836
+ const { rules } = options;
10837
+ const entry = getBlockAbove(editor);
10838
+ rules.forEach(({ hotkey, query }) => {
10839
+ if (isHotkey(hotkey, event) && isNodeType(entry, query)) {
10840
+ event.preventDefault();
10841
+ editor.insertText('\n');
10842
+ }
10843
+ });
10844
+ onKeydown(event);
10845
+ };
10846
+ return editor;
10847
+ };
10848
+
10694
10849
  const internalPlugins = [
10695
10850
  withTheHistory,
10696
10851
  withAutoInsertData(),
@@ -10708,6 +10863,17 @@ const internalPlugins = [
10708
10863
  withCode,
10709
10864
  withHeading,
10710
10865
  withMark(),
10866
+ withSoftBreak({
10867
+ rules: [
10868
+ { hotkey: 'shift+enter' },
10869
+ {
10870
+ hotkey: 'enter',
10871
+ query: {
10872
+ allow: [ElementKinds.blockquote]
10873
+ }
10874
+ }
10875
+ ]
10876
+ }),
10711
10877
  withBlockquote,
10712
10878
  withNodeID({ idKey: ELEMENT_UNIQUE_ID, idCreator }),
10713
10879
  withAutoFormat({ rules: autoFormatRules }),
@@ -10716,9 +10882,9 @@ const internalPlugins = [
10716
10882
  withMoveSelection,
10717
10883
  withInsertParagraphNodes(),
10718
10884
  withGetFragment(),
10885
+ withImage,
10719
10886
  withDeserializeHMTL,
10720
10887
  withDeserializeMd(),
10721
- withImage,
10722
10888
  withQuickInsert
10723
10889
  ];
10724
10890
  const internalToolbarItems = [
@@ -10822,8 +10988,8 @@ const autoFocus = (editor, isFocus) => {
10822
10988
  setTimeout(() => {
10823
10989
  if (editor && editor.children.length > 0 && isFocus) {
10824
10990
  HistoryEditor.withoutMerging(editor, () => {
10825
- AngularEditor.focus(editor);
10826
10991
  Transforms.select(editor, Editor.start(editor, [0]));
10992
+ AngularEditor.focus(editor);
10827
10993
  });
10828
10994
  }
10829
10995
  });
@@ -11092,11 +11258,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
11092
11258
  }] } });
11093
11259
 
11094
11260
  class TheInlineToolbarComponent {
11095
- constructor(elementRef, scrollDispatcher, cdr, ngZone) {
11261
+ constructor(elementRef, scrollDispatcher, cdr, ngZone, contextService) {
11096
11262
  this.elementRef = elementRef;
11097
11263
  this.scrollDispatcher = scrollDispatcher;
11098
11264
  this.cdr = cdr;
11099
11265
  this.ngZone = ngZone;
11266
+ this.contextService = contextService;
11100
11267
  this.destroy$ = new Subject();
11101
11268
  }
11102
11269
  ngOnInit() {
@@ -11156,7 +11323,8 @@ class TheInlineToolbarComponent {
11156
11323
  boundary = range.startContainer.getBoundingClientRect();
11157
11324
  }
11158
11325
  }
11159
- const editableRect = document.querySelector('.the-editor-typo').getBoundingClientRect();
11326
+ const editableElement = this.contextService.getEditableElement();
11327
+ const editableRect = editableElement.getBoundingClientRect();
11160
11328
  const toolbarHeight = toolbarElement.offsetHeight;
11161
11329
  const toolbarWidth = toolbarElement.offsetWidth;
11162
11330
  const halfOffsetWidth = toolbarWidth / 2;
@@ -11184,7 +11352,7 @@ class TheInlineToolbarComponent {
11184
11352
  this.destroy$.complete();
11185
11353
  }
11186
11354
  }
11187
- TheInlineToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheInlineToolbarComponent, deps: [{ token: i0.ElementRef }, { token: i2$1.ScrollDispatcher }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
11355
+ TheInlineToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheInlineToolbarComponent, deps: [{ token: i0.ElementRef }, { token: i2$1.ScrollDispatcher }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: TheContextService }], target: i0.ɵɵFactoryTarget.Component });
11188
11356
  TheInlineToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: { editor: "editor", toolbarItems: "toolbarItems" }, host: { properties: { "class.hide": "toolbarItems.length === 0" } }, viewQueries: [{ propertyName: "inlineToolbar", first: true, predicate: ["inlineToolbar"], descendants: true }], ngImport: i0, template: `<the-toolbar
11189
11357
  #inlineToolbar
11190
11358
  class="the-inline-toolbar"
@@ -11208,7 +11376,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
11208
11376
  },
11209
11377
  changeDetection: ChangeDetectionStrategy.OnPush
11210
11378
  }]
11211
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i2$1.ScrollDispatcher }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }]; }, propDecorators: { editor: [{
11379
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i2$1.ScrollDispatcher }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: TheContextService }]; }, propDecorators: { editor: [{
11212
11380
  type: Input
11213
11381
  }], toolbarItems: [{
11214
11382
  type: Input
@@ -11232,13 +11400,14 @@ class TheQuickInsertComponent {
11232
11400
  event.stopPropagation();
11233
11401
  }
11234
11402
  checkStatus() {
11235
- var _a;
11236
11403
  const { editor } = this;
11237
11404
  if (isCleanEmptyParagraph(editor)) {
11238
- 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]]);
11239
- const rootNode = AngularEditor.toDOMNode(editor, block);
11240
- this.isHide = false;
11241
- this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
11405
+ setTimeout(() => {
11406
+ var _a;
11407
+ 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]]);
11408
+ const rootNode = AngularEditor.toDOMNode(editor, block);
11409
+ this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
11410
+ });
11242
11411
  return;
11243
11412
  }
11244
11413
  this.isHide = true;
@@ -11287,9 +11456,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
11287
11456
  }] } });
11288
11457
 
11289
11458
  class ThePlaceholderComponent {
11290
- constructor(renderer, elementRef) {
11459
+ constructor(renderer, elementRef, contextService) {
11291
11460
  this.renderer = renderer;
11292
11461
  this.elementRef = elementRef;
11462
+ this.contextService = contextService;
11293
11463
  this.isHide = true;
11294
11464
  }
11295
11465
  handleCompositionStart() {
@@ -11304,19 +11474,24 @@ class ThePlaceholderComponent {
11304
11474
  }
11305
11475
  }
11306
11476
  checkStatus() {
11307
- var _a, _b;
11477
+ var _a, _b, _c;
11308
11478
  const { editor } = this;
11479
+ const isEmptyShow = typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isEmptyShowPlaceholder) === 'undefined' ? true : this.options.isEmptyShowPlaceholder;
11480
+ const isMustShow = (_b = this.options) === null || _b === void 0 ? void 0 : _b.isMustShowPlaceholder;
11481
+ const isReadonly = (_c = this.options) === null || _c === void 0 ? void 0 : _c.readonly;
11309
11482
  // empty content and no selection processing
11310
- if (!(editor === null || editor === void 0 ? void 0 : editor.selection) && isEmptyContent(editor.children)) {
11311
- // normal top is 28, but margin-top: -41px is set when maxHeight is set, so top is 69
11312
- const firstTop = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.maxHeight) ? 69 : 28;
11313
- this.updatePosition(30, firstTop);
11483
+ if (!isReadonly && isEmptyShow && isEmptyContent(editor.children)) {
11484
+ const firstElementChild = this.contextService.getFirstElementChild();
11485
+ const offsetTop = firstElementChild.offsetTop;
11486
+ const offsetLeft = firstElementChild.offsetLeft;
11487
+ this.updatePosition(offsetLeft, offsetTop);
11314
11488
  return;
11315
11489
  }
11316
- if (isCleanEmptyParagraph(editor)) {
11317
- const block = Node.ancestor(editor, [(_b = editor === null || editor === void 0 ? void 0 : editor.selection) === null || _b === void 0 ? void 0 : _b.anchor.path[0]]);
11318
- const rootNode = AngularEditor.toDOMNode(editor, block);
11490
+ if (isMustShow && isCleanEmptyParagraph(editor)) {
11319
11491
  setTimeout(() => {
11492
+ var _a;
11493
+ 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]]);
11494
+ const rootNode = AngularEditor.toDOMNode(editor, block);
11320
11495
  this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
11321
11496
  });
11322
11497
  return;
@@ -11332,7 +11507,7 @@ class ThePlaceholderComponent {
11332
11507
  this.isHide = true;
11333
11508
  }
11334
11509
  }
11335
- ThePlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
11510
+ ThePlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: TheContextService }], target: i0.ɵɵFactoryTarget.Component });
11336
11511
  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 });
11337
11512
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, decorators: [{
11338
11513
  type: Component,
@@ -11344,7 +11519,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
11344
11519
  '[class.hide]': 'isHide'
11345
11520
  }
11346
11521
  }]
11347
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }]; }, propDecorators: { editor: [{
11522
+ }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: TheContextService }]; }, propDecorators: { editor: [{
11348
11523
  type: Input
11349
11524
  }], options: [{
11350
11525
  type: Input
@@ -11519,6 +11694,12 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
11519
11694
  this.onSlaCompositionEnd = (event) => { };
11520
11695
  this.onSlaDragStart = (event) => { };
11521
11696
  this.onSlaDragOver = (event) => { };
11697
+ this.onDrop = (event) => {
11698
+ event.stopPropagation();
11699
+ this.theOnDOMEvent.emit({
11700
+ nativeEvent: event
11701
+ });
11702
+ };
11522
11703
  }
11523
11704
  get theGlobalToolbarInstance() {
11524
11705
  return this.theGlobalToolbar ? this.theGlobalToolbar : this.globalToolbarInstance;
@@ -11536,15 +11717,18 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
11536
11717
  this.onErrorHandler();
11537
11718
  }
11538
11719
  ngOnChanges(changes) {
11539
- var _a, _b, _c;
11720
+ var _a, _b, _c, _d, _e;
11540
11721
  const options = changes.theOptions;
11541
11722
  if (options) {
11542
11723
  this.initializeOptions();
11543
11724
  }
11725
+ if (options && ((_a = options.currentValue) === null || _a === void 0 ? void 0 : _a.readonly) !== ((_b = options.previousValue) === null || _b === void 0 ? void 0 : _b.readonly)) {
11726
+ this.applyAutoFocus();
11727
+ }
11544
11728
  if (changes['theDecorate']) {
11545
11729
  this.generateDecorate();
11546
11730
  }
11547
- if (((_a = this.editor) === null || _a === void 0 ? void 0 : _a.selection) && (((_b = options === null || options === void 0 ? void 0 : options.currentValue) === null || _b === void 0 ? void 0 : _b.readonly) || ((_c = options === null || options === void 0 ? void 0 : options.currentValue) === null || _c === void 0 ? void 0 : _c.disabled))) {
11731
+ if (((_c = this.editor) === null || _c === void 0 ? void 0 : _c.selection) && (((_d = options === null || options === void 0 ? void 0 : options.currentValue) === null || _d === void 0 ? void 0 : _d.readonly) || ((_e = options === null || options === void 0 ? void 0 : options.currentValue) === null || _e === void 0 ? void 0 : _e.disabled))) {
11548
11732
  Transforms.deselect(this.editor);
11549
11733
  }
11550
11734
  }
@@ -11561,7 +11745,9 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
11561
11745
  this.theContextService.initialize({ nativeElement: this.elementRef.nativeElement, viewContainerRef: this.viewContainerRef });
11562
11746
  this.toolbarCalculate();
11563
11747
  setTimeout(() => {
11748
+ var _a;
11564
11749
  this.theEditorCreated.emit(this.editor);
11750
+ (_a = this.placeholderInstance) === null || _a === void 0 ? void 0 : _a.checkStatus();
11565
11751
  this.applyAutoFocus();
11566
11752
  });
11567
11753
  }
@@ -11577,9 +11763,9 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
11577
11763
  }
11578
11764
  }
11579
11765
  applyAutoFocus() {
11580
- var _a, _b, _c, _d;
11581
- if (((_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.autoFocus) && !((_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.readonly) && !((_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.disabled)) {
11582
- autoFocus(this.editor, (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.autoFocus);
11766
+ var _a, _b, _c;
11767
+ if (!((_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled) && !((_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.readonly)) {
11768
+ autoFocus(this.editor, (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.autoFocus);
11583
11769
  }
11584
11770
  }
11585
11771
  toolbarCalculate() {
@@ -11611,14 +11797,14 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
11611
11797
  this.onTouchedCallback = fn;
11612
11798
  }
11613
11799
  valueChange(value) {
11614
- var _a, _b, _c, _d, _e;
11800
+ var _a, _b, _c, _d, _e, _f;
11615
11801
  (_a = this.theGlobalToolbarInstance) === null || _a === void 0 ? void 0 : _a.statusChange(this.editor);
11616
11802
  (_b = this.quickInsertInstance) === null || _b === void 0 ? void 0 : _b.checkStatus();
11617
- this.placeholderInstance.checkStatus();
11803
+ (_c = this.placeholderInstance) === null || _c === void 0 ? void 0 : _c.checkStatus();
11618
11804
  // auto scroll view
11619
- const scrollContainer = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.scrollContainer;
11620
- const maxHeight = (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.maxHeight;
11621
- if (!((_e = this.theOptions) === null || _e === void 0 ? void 0 : _e.readonly) && (scrollContainer || maxHeight)) {
11805
+ const scrollContainer = (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.scrollContainer;
11806
+ const maxHeight = (_e = this.theOptions) === null || _e === void 0 ? void 0 : _e.maxHeight;
11807
+ if (!((_f = this.theOptions) === null || _f === void 0 ? void 0 : _f.readonly) && (scrollContainer || maxHeight)) {
11622
11808
  const container = maxHeight ? DEFAULT_SCROLL_CONTAINER : scrollContainer;
11623
11809
  this.autoScrollView(this.editor, container);
11624
11810
  }
@@ -11743,7 +11929,7 @@ TheEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", ver
11743
11929
  useExisting: forwardRef(() => TheEditorComponent),
11744
11930
  multi: true
11745
11931
  }
11746
- ], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }, { propertyName: "placeholderInstance", first: true, predicate: ["placeholder"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<the-toolbar\n *ngIf=\"!theOptions?.readonly && !theGlobalToolbar\"\n [ngClass]=\"{\n 'the-toolbar-disabled': theOptions?.disabled\n }\"\n #globalToolbar\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.global\"\n [containerClass]=\"globalToolbarClass\"\n [align]=\"theOptions?.toolbar?.align\"\n></the-toolbar>\n\n<div\n class=\"the-editable-container\"\n [ngClass]=\"{\n 'the-editor-disabled': theOptions?.disabled,\n 'max-height': maxHeight\n }\"\n [ngStyle]=\"{ 'max-height': maxHeight }\"\n>\n <slate-editable\n class=\"the-editor-typo\"\n [editor]=\"editor\"\n [ngModel]=\"editorValue\"\n (ngModelChange)=\"valueChange($event)\"\n [decorate]=\"decorate\"\n [renderElement]=\"renderElement\"\n [renderText]=\"renderText\"\n [renderLeaf]=\"renderLeaf\"\n [readonly]=\"theOptions?.readonly || theOptions?.disabled\"\n [keydown]=\"onKeyDown\"\n [click]=\"onClick\"\n [paste]=\"onSlaPaste\"\n [beforeInput]=\"onSlaBeforeInput\"\n [blur]=\"onSlaBlur\"\n [focus]=\"onSlaFocus\"\n [copy]=\"onSlaCopy\"\n [cut]=\"onSlaCut\"\n [isStrictDecorate]=\"false\"\n [compositionStart]=\"onSlaCompositionStart\"\n [compositionEnd]=\"onSlaCompositionEnd\"\n [dragStart]=\"onSlaDragStart\"\n [dragOver]=\"onSlaDragOver\"\n (mousedown)=\"mousedown($event)\"\n ></slate-editable>\n <the-inline-toolbar *ngIf=\"!theOptions?.readonly\" [editor]=\"editor\" [toolbarItems]=\"toolbarEntity.inline\"></the-inline-toolbar>\n <div #quickInsert theQuickInsert [editor]=\"editor\" [quickToolbarItems]=\"quickToolbarItems\"></div>\n <div #placeholder thePlaceholder [editor]=\"editor\" [options]=\"theOptions\"></div>\n <the-template #templateInstance></the-template>\n</div>\n", components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }, { type: i1.SlateEditableComponent, selector: "slate-editable", inputs: ["editor", "renderElement", "renderLeaf", "renderText", "decorate", "isStrictDecorate", "trackBy", "readonly", "beforeInput", "blur", "click", "compositionEnd", "compositionStart", "copy", "cut", "dragOver", "dragStart", "dragEnd", "drop", "focus", "keydown", "paste", "spellCheck", "autoCorrect", "autoCapitalize"] }, { type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: ["editor", "toolbarItems"] }, { type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: ["editor", "quickToolbarItems"] }, { type: ThePlaceholderComponent, selector: "div[thePlaceholder]", inputs: ["editor", "options"] }, { type: TheTemplateComponent, selector: "the-template,[theTemplate]" }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
11932
+ ], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }, { propertyName: "placeholderInstance", first: true, predicate: ["placeholder"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<the-toolbar\n *ngIf=\"!theOptions?.readonly && !theGlobalToolbar\"\n [ngClass]=\"{\n 'the-toolbar-disabled': theOptions?.disabled\n }\"\n #globalToolbar\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.global\"\n [containerClass]=\"globalToolbarClass\"\n [align]=\"theOptions?.toolbar?.align\"\n></the-toolbar>\n\n<div\n class=\"the-editable-container\"\n [ngClass]=\"{\n 'the-editor-disabled': theOptions?.disabled,\n 'max-height': maxHeight\n }\"\n [ngStyle]=\"{ 'max-height': maxHeight }\"\n>\n <slate-editable\n class=\"the-editor-typo\"\n [editor]=\"editor\"\n [ngModel]=\"editorValue\"\n (ngModelChange)=\"valueChange($event)\"\n [decorate]=\"decorate\"\n [renderElement]=\"renderElement\"\n [renderText]=\"renderText\"\n [renderLeaf]=\"renderLeaf\"\n [readonly]=\"theOptions?.readonly || theOptions?.disabled\"\n [keydown]=\"onKeyDown\"\n [click]=\"onClick\"\n [paste]=\"onSlaPaste\"\n [beforeInput]=\"onSlaBeforeInput\"\n [blur]=\"onSlaBlur\"\n [focus]=\"onSlaFocus\"\n [copy]=\"onSlaCopy\"\n [cut]=\"onSlaCut\"\n [isStrictDecorate]=\"false\"\n [compositionStart]=\"onSlaCompositionStart\"\n [compositionEnd]=\"onSlaCompositionEnd\"\n [dragStart]=\"onSlaDragStart\"\n [dragOver]=\"onSlaDragOver\"\n [drop]=\"onDrop\"\n (mousedown)=\"mousedown($event)\"\n ></slate-editable>\n <the-inline-toolbar *ngIf=\"!theOptions?.readonly\" [editor]=\"editor\" [toolbarItems]=\"toolbarEntity.inline\"></the-inline-toolbar>\n <div #quickInsert theQuickInsert [editor]=\"editor\" [quickToolbarItems]=\"quickToolbarItems\"></div>\n <div #placeholder thePlaceholder [editor]=\"editor\" [options]=\"theOptions\"></div>\n <the-template #templateInstance></the-template>\n</div>\n", components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }, { type: i1.SlateEditableComponent, selector: "slate-editable", inputs: ["editor", "renderElement", "renderLeaf", "renderText", "decorate", "isStrictDecorate", "trackBy", "readonly", "beforeInput", "blur", "click", "compositionEnd", "compositionStart", "copy", "cut", "dragOver", "dragStart", "dragEnd", "drop", "focus", "keydown", "paste", "spellCheck", "autoCorrect", "autoCapitalize"] }, { type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: ["editor", "toolbarItems"] }, { type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: ["editor", "quickToolbarItems"] }, { type: ThePlaceholderComponent, selector: "div[thePlaceholder]", inputs: ["editor", "options"] }, { type: TheTemplateComponent, selector: "the-template,[theTemplate]" }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
11747
11933
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheEditorComponent, decorators: [{
11748
11934
  type: Component,
11749
11935
  args: [{
@@ -12074,5 +12260,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
12074
12260
  * Generated bundle index. Do not edit.
12075
12261
  */
12076
12262
 
12077
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BLOCK_INSERT_ORIGIN, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, HEADING_TYPES, HeadingEditor, HrEditor, ImageEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeMode, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, plainToTheia, toolbarCompose, withTheEditor };
12263
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeMode, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, plainToTheia, toolbarCompose, withTheEditor };
12078
12264
  //# sourceMappingURL=worktile-theia.js.map