@lvce-editor/editor-worker 18.0.0 → 18.1.0

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.
@@ -1123,7 +1123,7 @@ const LeftArrow = 13;
1123
1123
  const UpArrow = 14;
1124
1124
  const RightArrow = 15;
1125
1125
  const DownArrow = 16;
1126
- const Delete = 18;
1126
+ const Delete$1 = 18;
1127
1127
  const KeyA = 29;
1128
1128
  const KeyC = 31;
1129
1129
  const KeyD = 32;
@@ -1811,6 +1811,7 @@ const loadContent$2 = async (state, parentUid) => {
1811
1811
  // TODO use numeric enum
1812
1812
  const CompositionUpdate = 'compositionUpdate';
1813
1813
  const ContentEditableInput = 'contentEditableInput';
1814
+ const Delete = 'delete';
1814
1815
  const DeleteHorizontalRight = 'deleteHorizontalRight';
1815
1816
  const DeleteLeft = 'deleteLeft';
1816
1817
  const EditorCut = 'editorCut';
@@ -3784,7 +3785,7 @@ const setBounds = (editor, x, y, width, height, columnWidth) => {
3784
3785
  y
3785
3786
  };
3786
3787
  };
3787
- const setText = (editor, text) => {
3788
+ const setText$1 = (editor, text) => {
3788
3789
  const lines = splitLines(text);
3789
3790
  const {
3790
3791
  itemHeight,
@@ -4182,7 +4183,7 @@ const createEditor = async ({
4182
4183
 
4183
4184
  // TODO avoid creating intermediate editors here
4184
4185
  const newEditor1 = setBounds(editor, x, y, width, height, 9);
4185
- const newEditor2 = setText(newEditor1, content);
4186
+ const newEditor2 = setText$1(newEditor1, content);
4186
4187
  let newEditor3;
4187
4188
  if (lineToReveal && columnToReveal) {
4188
4189
  const delta = lineToReveal * rowHeight;
@@ -5405,6 +5406,33 @@ const cut$1 = async editor => {
5405
5406
  return cutSelectedText(editor);
5406
5407
  };
5407
5408
 
5409
+ const deleteAll = editor => {
5410
+ const {
5411
+ lines
5412
+ } = editor;
5413
+ const endRowIndex = lines.length - 1;
5414
+ const endColumnIndex = lines.at(-1).length;
5415
+ const start = {
5416
+ columnIndex: 0,
5417
+ rowIndex: 0
5418
+ };
5419
+ const end = {
5420
+ columnIndex: endColumnIndex,
5421
+ rowIndex: endRowIndex
5422
+ };
5423
+ const changes = [{
5424
+ deleted: getSelectionText(editor, {
5425
+ end,
5426
+ start
5427
+ }),
5428
+ end,
5429
+ inserted: [''],
5430
+ origin: Delete,
5431
+ start
5432
+ }];
5433
+ return scheduleDocumentAndCursorsSelections(editor, changes);
5434
+ };
5435
+
5408
5436
  // TODO optimize this function by profiling and not allocating too many objects
5409
5437
  // @ts-ignore
5410
5438
  const getChanges$5 = (lines, selections, getDelta) => {
@@ -8129,6 +8157,11 @@ const setSelections = (editor, selections) => {
8129
8157
  };
8130
8158
  };
8131
8159
 
8160
+ const setText = (editor, text) => {
8161
+ string(text);
8162
+ return setText$1(editor, text);
8163
+ };
8164
+
8132
8165
  const create$1 = () => {
8133
8166
  const uid = create$7();
8134
8167
  const widget = {
@@ -10206,7 +10239,7 @@ const getKeyBindings = () => {
10206
10239
  when: FocusEditorText
10207
10240
  }, {
10208
10241
  command: 'Editor.deleteWordPartRight',
10209
- key: Alt$1 | Delete,
10242
+ key: Alt$1 | Delete$1,
10210
10243
  when: FocusEditorText
10211
10244
  }, {
10212
10245
  command: 'Editor.deleteWordLeft',
@@ -10214,7 +10247,7 @@ const getKeyBindings = () => {
10214
10247
  when: FocusEditorText
10215
10248
  }, {
10216
10249
  command: 'Editor.deleteWordRight',
10217
- key: CtrlCmd | Delete,
10250
+ key: CtrlCmd | Delete$1,
10218
10251
  when: FocusEditorText
10219
10252
  }, {
10220
10253
  command: 'Editor.selectNextOccurrence',
@@ -10290,7 +10323,7 @@ const getKeyBindings = () => {
10290
10323
  when: FocusEditorText
10291
10324
  }, {
10292
10325
  command: 'Editor.deleteAllRight',
10293
- key: CtrlCmd | Shift | Delete,
10326
+ key: CtrlCmd | Shift | Delete$1,
10294
10327
  when: FocusEditorText
10295
10328
  }, {
10296
10329
  command: 'Editor.cancelSelection',
@@ -10322,7 +10355,7 @@ const getKeyBindings = () => {
10322
10355
  when: FocusEditorText
10323
10356
  }, {
10324
10357
  command: 'Editor.deleteRight',
10325
- key: Delete,
10358
+ key: Delete$1,
10326
10359
  when: FocusEditorText
10327
10360
  }, {
10328
10361
  command: 'Editor.insertLineBreak',
@@ -11411,6 +11444,7 @@ const commandMap = {
11411
11444
  'Editor.cursorWordPartRight': wrapCommand(cursorWordPartRight),
11412
11445
  'Editor.cursorWordRight': wrapCommand(cursorWordRight),
11413
11446
  'Editor.cut': wrapCommand(cut$1),
11447
+ 'Editor.deleteAll': wrapCommand(deleteAll),
11414
11448
  'Editor.deleteAllLeft': wrapCommand(deleteAllLeft),
11415
11449
  'Editor.deleteAllRight': wrapCommand(deleteAllRight),
11416
11450
  'Editor.deleteCharacterLeft': wrapCommand(deleteCharacterLeft),
@@ -11523,6 +11557,7 @@ const commandMap = {
11523
11557
  'Editor.setLanguageId': wrapCommand(setLanguageId),
11524
11558
  'Editor.setSelections': wrapCommand(setSelections),
11525
11559
  'Editor.setSelections2': setSelections2,
11560
+ 'Editor.setText': wrapCommand(setText),
11526
11561
  'Editor.showHover': showHover,
11527
11562
  'Editor.showHover2': showHover3,
11528
11563
  'Editor.showSourceActions': showSourceActions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.0.0",
3
+ "version": "18.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"