monaco-editor-core 0.56.0-dev-20260119 → 0.56.0-dev-20260121

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 (91) hide show
  1. package/esm/nls.messages.cs.js +1 -1
  2. package/esm/nls.messages.de.js +1 -1
  3. package/esm/nls.messages.es.js +1 -1
  4. package/esm/nls.messages.fr.js +1 -1
  5. package/esm/nls.messages.it.js +1 -1
  6. package/esm/nls.messages.ja.js +1 -1
  7. package/esm/nls.messages.ko.js +1 -1
  8. package/esm/nls.messages.pl.js +1 -1
  9. package/esm/nls.messages.pt-br.js +1 -1
  10. package/esm/nls.messages.ru.js +1 -1
  11. package/esm/nls.messages.tr.js +1 -1
  12. package/esm/nls.messages.zh-cn.js +1 -1
  13. package/esm/nls.messages.zh-tw.js +1 -1
  14. package/esm/vs/base/browser/dom.js +8 -0
  15. package/esm/vs/base/browser/dom.js.map +1 -1
  16. package/esm/vs/base/browser/markdownRenderer.js +1 -0
  17. package/esm/vs/base/browser/markdownRenderer.js.map +1 -1
  18. package/esm/vs/base/browser/ui/actionbar/actionViewItems.js +4 -1
  19. package/esm/vs/base/browser/ui/actionbar/actionViewItems.js.map +1 -1
  20. package/esm/vs/base/browser/ui/actionbar/actionbar.css +8 -5
  21. package/esm/vs/base/browser/ui/contextview/contextview.js +1 -1
  22. package/esm/vs/base/browser/ui/contextview/contextview.js.map +1 -1
  23. package/esm/vs/base/browser/ui/hover/hover.js.map +1 -1
  24. package/esm/vs/base/browser/ui/list/list.js +1 -0
  25. package/esm/vs/base/browser/ui/list/list.js.map +1 -1
  26. package/esm/vs/base/browser/ui/list/listWidget.js +62 -5
  27. package/esm/vs/base/browser/ui/list/listWidget.js.map +1 -1
  28. package/esm/vs/base/browser/ui/tree/abstractTree.js +4 -1
  29. package/esm/vs/base/browser/ui/tree/abstractTree.js.map +1 -1
  30. package/esm/vs/base/browser/ui/tree/asyncDataTree.js +4 -1
  31. package/esm/vs/base/browser/ui/tree/asyncDataTree.js.map +1 -1
  32. package/esm/vs/base/common/defaultAccount.js +0 -4
  33. package/esm/vs/base/common/defaultAccount.js.map +1 -1
  34. package/esm/vs/editor/browser/controller/editContext/clipboardUtils.js +81 -35
  35. package/esm/vs/editor/browser/controller/editContext/clipboardUtils.js.map +1 -1
  36. package/esm/vs/editor/browser/controller/editContext/editContext.js +11 -0
  37. package/esm/vs/editor/browser/controller/editContext/editContext.js.map +1 -1
  38. package/esm/vs/editor/browser/controller/editContext/native/nativeEditContext.js +38 -18
  39. package/esm/vs/editor/browser/controller/editContext/native/nativeEditContext.js.map +1 -1
  40. package/esm/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.js +4 -0
  41. package/esm/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.js.map +1 -1
  42. package/esm/vs/editor/browser/controller/editContext/textArea/textAreaEditContextInput.js +39 -16
  43. package/esm/vs/editor/browser/controller/editContext/textArea/textAreaEditContextInput.js.map +1 -1
  44. package/esm/vs/editor/browser/editorBrowser.js.map +1 -1
  45. package/esm/vs/editor/browser/view.js +21 -1
  46. package/esm/vs/editor/browser/view.js.map +1 -1
  47. package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js +18 -0
  48. package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js.map +1 -1
  49. package/esm/vs/editor/common/model/bracketPairsTextModelPart/colorizedBracketPairsDecorationProvider.js +3 -3
  50. package/esm/vs/editor/common/model/bracketPairsTextModelPart/colorizedBracketPairsDecorationProvider.js.map +1 -1
  51. package/esm/vs/editor/common/model/textModel.js +7 -5
  52. package/esm/vs/editor/common/model/textModel.js.map +1 -1
  53. package/esm/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.js +21 -17
  54. package/esm/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.js.map +1 -1
  55. package/esm/vs/editor/common/model.js.map +1 -1
  56. package/esm/vs/editor/common/viewModel/viewModelDecorations.js +11 -4
  57. package/esm/vs/editor/common/viewModel/viewModelDecorations.js.map +1 -1
  58. package/esm/vs/editor/common/viewModel/viewModelImpl.js +25 -14
  59. package/esm/vs/editor/common/viewModel/viewModelImpl.js.map +1 -1
  60. package/esm/vs/editor/common/viewModel.js.map +1 -1
  61. package/esm/vs/editor/contrib/clipboard/browser/clipboard.js +3 -3
  62. package/esm/vs/editor/contrib/clipboard/browser/clipboard.js.map +1 -1
  63. package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +28 -64
  64. package/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js.map +1 -1
  65. package/esm/vs/editor/contrib/floatingMenu/browser/floatingMenu.css +27 -20
  66. package/esm/vs/editor/contrib/floatingMenu/browser/floatingMenu.js +37 -10
  67. package/esm/vs/editor/contrib/floatingMenu/browser/floatingMenu.js.map +1 -1
  68. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +2 -2
  69. package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js.map +1 -1
  70. package/esm/vs/editor/contrib/inlineCompletions/browser/view/ghostText/ghostTextView.css +7 -0
  71. package/esm/vs/editor/contrib/inlineCompletions/browser/view/ghostText/ghostTextView.js +22 -3
  72. package/esm/vs/editor/contrib/inlineCompletions/browser/view/ghostText/ghostTextView.js.map +1 -1
  73. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js +19 -13
  74. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/components/gutterIndicatorView.js.map +1 -1
  75. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineSuggestionsView.js +1 -0
  76. package/esm/vs/editor/contrib/inlineCompletions/browser/view/inlineSuggestionsView.js.map +1 -1
  77. package/esm/vs/editor/editor.api.d.ts +5 -1
  78. package/esm/vs/platform/actionWidget/browser/actionList.js +46 -6
  79. package/esm/vs/platform/actionWidget/browser/actionList.js.map +1 -1
  80. package/esm/vs/platform/actionWidget/browser/actionWidget.js +8 -1
  81. package/esm/vs/platform/actionWidget/browser/actionWidget.js.map +1 -1
  82. package/esm/vs/platform/actions/common/actions.js +2 -1
  83. package/esm/vs/platform/actions/common/actions.js.map +1 -1
  84. package/esm/vs/platform/defaultAccount/common/defaultAccount.js.map +1 -1
  85. package/esm/vs/platform/hover/browser/hoverService.js +1 -0
  86. package/esm/vs/platform/hover/browser/hoverService.js.map +1 -1
  87. package/esm/vs/platform/product/common/product.js +16 -1
  88. package/esm/vs/platform/product/common/product.js.map +1 -1
  89. package/monaco.d.ts +5 -1
  90. package/package.json +2 -2
  91. package/version.txt +1 -1
@@ -1,6 +1,2 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
1
  export {};
6
2
  //# sourceMappingURL=defaultAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/defaultAccount.ts","vs/base/common/defaultAccount.ts"],"names":[],"mappings":"AAAA;;;gGAGgG","file":"defaultAccount.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface IDefaultAccount {\n\treadonly access_type_sku?: string;\n\treadonly copilot_plan?: string;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface IDefaultAccount {\n\treadonly access_type_sku?: string;\n\treadonly copilot_plan?: string;\n}\n"]}
1
+ {"version":3,"file":"defaultAccount.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sources":["vs/base/common/defaultAccount.ts"],"names":[],"mappings":"","sourcesContent":["\n\nexport interface ILegacyQuotaSnapshotData {\n}\n\nexport interface IEntitlementsData extends ILegacyQuotaSnapshotData {\n\treadonly access_type_sku: string;\n\treadonly copilot_plan: string;\n}\n\nexport interface IDefaultAccount {\n\treadonly entitlementsData?: IEntitlementsData | null;\n}\n"]}
@@ -1,54 +1,41 @@
1
1
  import { isWindows } from '../../../../base/common/platform.js';
2
2
  import { Mimes } from '../../../../base/common/mime.js';
3
- import { LogLevel } from '../../../../platform/log/common/log.js';
4
3
  import { generateUuid } from '../../../../base/common/uuid.js';
5
- export function ensureClipboardGetsEditorSelection(e, context, logService, isFirefox) {
6
- const viewModel = context.viewModel;
7
- const options = context.configuration.options;
8
- let id = undefined;
9
- if (logService.getLevel() === LogLevel.Trace) {
10
- id = generateUuid();
11
- }
12
- const { dataToCopy, storedMetadata } = generateDataToCopyAndStoreInMemory(viewModel, options, id, isFirefox);
13
- // !!!!!
14
- // This is a workaround for what we think is an Electron bug where
15
- // execCommand('copy') does not always work (it does not fire a clipboard event)
16
- // !!!!!
17
- // We signal that we have executed a copy command
18
- CopyOptions.electronBugWorkaroundCopyEventHasFired = true;
19
- e.preventDefault();
20
- if (e.clipboardData) {
21
- ClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, storedMetadata);
22
- }
23
- logService.trace('ensureClipboardGetsEditorSelection with id : ', id, ' with text.length: ', dataToCopy.text.length);
4
+ import { toExternalVSDataTransfer } from '../../dataTransfer.js';
5
+ export function generateDataToCopyAndStoreInMemory(viewModel, id, isFirefox) {
6
+ const { dataToCopy, metadata } = generateDataToCopy(viewModel);
7
+ storeMetadataInMemory(dataToCopy.text, metadata, isFirefox);
8
+ return { dataToCopy, metadata };
9
+ }
10
+ function storeMetadataInMemory(textToCopy, metadata, isFirefox) {
11
+ InMemoryClipboardMetadataManager.INSTANCE.set(
12
+ // When writing "LINE\r\n" to the clipboard and then pasting,
13
+ // Firefox pastes "LINE\n", so let's work around this quirk
14
+ (isFirefox ? textToCopy.replace(/\r\n/g, '\n') : textToCopy), metadata);
24
15
  }
25
- export function generateDataToCopyAndStoreInMemory(viewModel, options, id, isFirefox) {
26
- const emptySelectionClipboard = options.get(45 /* EditorOption.emptySelectionClipboard */);
27
- const copyWithSyntaxHighlighting = options.get(31 /* EditorOption.copyWithSyntaxHighlighting */);
16
+ function generateDataToCopy(viewModel) {
17
+ const emptySelectionClipboard = viewModel.getEditorOption(45 /* EditorOption.emptySelectionClipboard */);
18
+ const copyWithSyntaxHighlighting = viewModel.getEditorOption(31 /* EditorOption.copyWithSyntaxHighlighting */);
28
19
  const selections = viewModel.getCursorStates().map(cursorState => cursorState.modelState.selection);
29
20
  const dataToCopy = getDataToCopy(viewModel, selections, emptySelectionClipboard, copyWithSyntaxHighlighting);
30
- const storedMetadata = {
21
+ const metadata = {
31
22
  version: 1,
32
- id,
23
+ id: generateUuid(),
33
24
  isFromEmptySelection: dataToCopy.isFromEmptySelection,
34
25
  multicursorText: dataToCopy.multicursorText,
35
26
  mode: dataToCopy.mode
36
27
  };
37
- InMemoryClipboardMetadataManager.INSTANCE.set(
38
- // When writing "LINE\r\n" to the clipboard and then pasting,
39
- // Firefox pastes "LINE\n", so let's work around this quirk
40
- (isFirefox ? dataToCopy.text.replace(/\r\n/g, '\n') : dataToCopy.text), storedMetadata);
41
- return { dataToCopy, storedMetadata };
28
+ return { dataToCopy, metadata };
42
29
  }
43
30
  function getDataToCopy(viewModel, modelSelections, emptySelectionClipboard, copyWithSyntaxHighlighting) {
44
- const rawTextToCopy = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);
31
+ const { sourceRanges, sourceText } = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);
45
32
  const newLineCharacter = viewModel.model.getEOL();
46
33
  const isFromEmptySelection = (emptySelectionClipboard && modelSelections.length === 1 && modelSelections[0].isEmpty());
47
- const multicursorText = (Array.isArray(rawTextToCopy) ? rawTextToCopy : null);
48
- const text = (Array.isArray(rawTextToCopy) ? rawTextToCopy.join(newLineCharacter) : rawTextToCopy);
34
+ const multicursorText = (Array.isArray(sourceText) ? sourceText : null);
35
+ const text = (Array.isArray(sourceText) ? sourceText.join(newLineCharacter) : sourceText);
49
36
  let html = undefined;
50
37
  let mode = null;
51
- if (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && text.length < 65536)) {
38
+ if (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && sourceText.length < 65536)) {
52
39
  const richText = viewModel.getRichTextToCopy(modelSelections, emptySelectionClipboard);
53
40
  if (richText) {
54
41
  html = richText.html;
@@ -57,6 +44,7 @@ function getDataToCopy(viewModel, modelSelections, emptySelectionClipboard, copy
57
44
  }
58
45
  const dataToCopy = {
59
46
  isFromEmptySelection,
47
+ sourceRanges,
60
48
  multicursorText,
61
49
  text,
62
50
  html,
@@ -90,7 +78,7 @@ export const CopyOptions = {
90
78
  forceCopyWithSyntaxHighlighting: false,
91
79
  electronBugWorkaroundCopyEventHasFired: false
92
80
  };
93
- export const ClipboardEventUtils = {
81
+ const ClipboardEventUtils = {
94
82
  getTextData(clipboardData) {
95
83
  const text = clipboardData.getData(Mimes.text);
96
84
  let metadata = null;
@@ -121,4 +109,62 @@ export const ClipboardEventUtils = {
121
109
  clipboardData.setData('vscode-editor-data', JSON.stringify(metadata));
122
110
  }
123
111
  };
112
+ /**
113
+ * Creates an IClipboardCopyEvent from a DOM ClipboardEvent.
114
+ */
115
+ export function createClipboardCopyEvent(e, isCut, context, logService, isFirefox) {
116
+ const { dataToCopy, metadata } = generateDataToCopy(context.viewModel);
117
+ let handled = false;
118
+ return {
119
+ isCut,
120
+ clipboardData: {
121
+ setData: (type, value) => {
122
+ e.clipboardData?.setData(type, value);
123
+ },
124
+ },
125
+ dataToCopy,
126
+ ensureClipboardGetsEditorData: () => {
127
+ e.preventDefault();
128
+ if (e.clipboardData) {
129
+ ClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, metadata);
130
+ }
131
+ storeMetadataInMemory(dataToCopy.text, metadata, isFirefox);
132
+ logService.trace('ensureClipboardGetsEditorSelection with id : ', metadata.id, ' with text.length: ', dataToCopy.text.length);
133
+ },
134
+ setHandled: () => {
135
+ handled = true;
136
+ e.preventDefault();
137
+ e.stopImmediatePropagation();
138
+ },
139
+ get isHandled() { return handled; },
140
+ };
141
+ }
142
+ /**
143
+ * Creates an IClipboardPasteEvent from a DOM ClipboardEvent.
144
+ */
145
+ export function createClipboardPasteEvent(e) {
146
+ let handled = false;
147
+ let [text, metadata] = e.clipboardData ? ClipboardEventUtils.getTextData(e.clipboardData) : ['', null];
148
+ metadata = metadata || InMemoryClipboardMetadataManager.INSTANCE.get(text);
149
+ return {
150
+ clipboardData: createReadableClipboardData(e.clipboardData),
151
+ metadata,
152
+ text,
153
+ toExternalVSDataTransfer: () => e.clipboardData ? toExternalVSDataTransfer(e.clipboardData) : undefined,
154
+ browserEvent: e,
155
+ setHandled: () => {
156
+ handled = true;
157
+ e.preventDefault();
158
+ e.stopImmediatePropagation();
159
+ },
160
+ get isHandled() { return handled; },
161
+ };
162
+ }
163
+ export function createReadableClipboardData(dataTransfer) {
164
+ return {
165
+ types: Array.from(dataTransfer?.types ?? []),
166
+ files: Array.prototype.slice.call(dataTransfer?.files ?? [], 0),
167
+ getData: (type) => dataTransfer?.getData(type) ?? '',
168
+ };
169
+ }
124
170
  //# sourceMappingURL=clipboardUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/browser/controller/editContext/clipboardUtils.ts","vs/editor/browser/controller/editContext/clipboardUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAe,QAAQ,EAAE,MAAM,wCAAwC,C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C;YAC9B,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;QACD,aAAa,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvE,CAAC;CACD,CAAC","file":"clipboardUtils.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { IViewModel } from '../../../common/viewModel.js';\nimport { Range } from '../../../common/core/range.js';\nimport { isWindows } from '../../../../base/common/platform.js';\nimport { Mimes } from '../../../../base/common/mime.js';\nimport { ViewContext } from '../../../common/viewModel/viewContext.js';\nimport { ILogService, LogLevel } from '../../../../platform/log/common/log.js';\nimport { EditorOption, IComputedEditorOptions } from '../../../common/config/editorOptions.js';\nimport { generateUuid } from '../../../../base/common/uuid.js';\n\nexport function ensureClipboardGetsEditorSelection(e: ClipboardEvent, context: ViewContext, logService: ILogService, isFirefox: boolean): void {\n\tconst viewModel = context.viewModel;\n\tconst options = context.configuration.options;\n\tlet id: string | undefined = undefined;\n\tif (logService.getLevel() === LogLevel.Trace) {\n\t\tid = generateUuid();\n\t}\n\n\tconst { dataToCopy, storedMetadata } = generateDataToCopyAndStoreInMemory(viewModel, options, id, isFirefox);\n\n\t// !!!!!\n\t// This is a workaround for what we think is an Electron bug where\n\t// execCommand('copy') does not always work (it does not fire a clipboard event)\n\t// !!!!!\n\t// We signal that we have executed a copy command\n\tCopyOptions.electronBugWorkaroundCopyEventHasFired = true;\n\n\te.preventDefault();\n\tif (e.clipboardData) {\n\t\tClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, storedMetadata);\n\t}\n\tlogService.trace('ensureClipboardGetsEditorSelection with id : ', id, ' with text.length: ', dataToCopy.text.length);\n}\n\nexport function generateDataToCopyAndStoreInMemory(viewModel: IViewModel, options: IComputedEditorOptions, id: string | undefined, isFirefox: boolean) {\n\tconst emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);\n\tconst copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);\n\tconst selections = viewModel.getCursorStates().map(cursorState => cursorState.modelState.selection);\n\tconst dataToCopy = getDataToCopy(viewModel, selections, emptySelectionClipboard, copyWithSyntaxHighlighting);\n\tconst storedMetadata: ClipboardStoredMetadata = {\n\t\tversion: 1,\n\t\tid,\n\t\tisFromEmptySelection: dataToCopy.isFromEmptySelection,\n\t\tmulticursorText: dataToCopy.multicursorText,\n\t\tmode: dataToCopy.mode\n\t};\n\tInMemoryClipboardMetadataManager.INSTANCE.set(\n\t\t// When writing \"LINE\\r\\n\" to the clipboard and then pasting,\n\t\t// Firefox pastes \"LINE\\n\", so let's work around this quirk\n\t\t(isFirefox ? dataToCopy.text.replace(/\\r\\n/g, '\\n') : dataToCopy.text),\n\t\tstoredMetadata\n\t);\n\treturn { dataToCopy, storedMetadata };\n}\n\nfunction getDataToCopy(viewModel: IViewModel, modelSelections: Range[], emptySelectionClipboard: boolean, copyWithSyntaxHighlighting: boolean): ClipboardDataToCopy {\n\tconst rawTextToCopy = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);\n\tconst newLineCharacter = viewModel.model.getEOL();\n\n\tconst isFromEmptySelection = (emptySelectionClipboard && modelSelections.length === 1 && modelSelections[0].isEmpty());\n\tconst multicursorText = (Array.isArray(rawTextToCopy) ? rawTextToCopy : null);\n\tconst text = (Array.isArray(rawTextToCopy) ? rawTextToCopy.join(newLineCharacter) : rawTextToCopy);\n\n\tlet html: string | null | undefined = undefined;\n\tlet mode: string | null = null;\n\tif (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && text.length < 65536)) {\n\t\tconst richText = viewModel.getRichTextToCopy(modelSelections, emptySelectionClipboard);\n\t\tif (richText) {\n\t\t\thtml = richText.html;\n\t\t\tmode = richText.mode;\n\t\t}\n\t}\n\tconst dataToCopy: ClipboardDataToCopy = {\n\t\tisFromEmptySelection,\n\t\tmulticursorText,\n\t\ttext,\n\t\thtml,\n\t\tmode\n\t};\n\treturn dataToCopy;\n}\n\n/**\n * Every time we write to the clipboard, we record a bit of extra metadata here.\n * Every time we read from the cipboard, if the text matches our last written text,\n * we can fetch the previous metadata.\n */\nexport class InMemoryClipboardMetadataManager {\n\tpublic static readonly INSTANCE = new InMemoryClipboardMetadataManager();\n\n\tprivate _lastState: InMemoryClipboardMetadata | null;\n\n\tconstructor() {\n\t\tthis._lastState = null;\n\t}\n\n\tpublic set(lastCopiedValue: string, data: ClipboardStoredMetadata): void {\n\t\tthis._lastState = { lastCopiedValue, data };\n\t}\n\n\tpublic get(pastedText: string): ClipboardStoredMetadata | null {\n\t\tif (this._lastState && this._lastState.lastCopiedValue === pastedText) {\n\t\t\t// match!\n\t\t\treturn this._lastState.data;\n\t\t}\n\t\tthis._lastState = null;\n\t\treturn null;\n\t}\n}\n\nexport interface ClipboardDataToCopy {\n\tisFromEmptySelection: boolean;\n\tmulticursorText: string[] | null | undefined;\n\ttext: string;\n\thtml: string | null | undefined;\n\tmode: string | null;\n}\n\nexport interface ClipboardStoredMetadata {\n\tversion: 1;\n\tid: string | undefined;\n\tisFromEmptySelection: boolean | undefined;\n\tmulticursorText: string[] | null | undefined;\n\tmode: string | null;\n}\n\nexport const CopyOptions = {\n\tforceCopyWithSyntaxHighlighting: false,\n\telectronBugWorkaroundCopyEventHasFired: false\n};\n\ninterface InMemoryClipboardMetadata {\n\tlastCopiedValue: string;\n\tdata: ClipboardStoredMetadata;\n}\n\nexport const ClipboardEventUtils = {\n\n\tgetTextData(clipboardData: DataTransfer): [string, ClipboardStoredMetadata | null] {\n\t\tconst text = clipboardData.getData(Mimes.text);\n\t\tlet metadata: ClipboardStoredMetadata | null = null;\n\t\tconst rawmetadata = clipboardData.getData('vscode-editor-data');\n\t\tif (typeof rawmetadata === 'string') {\n\t\t\ttry {\n\t\t\t\tmetadata = <ClipboardStoredMetadata>JSON.parse(rawmetadata);\n\t\t\t\tif (metadata.version !== 1) {\n\t\t\t\t\tmetadata = null;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t// no problem!\n\t\t\t}\n\t\t}\n\t\tif (text.length === 0 && metadata === null && clipboardData.files.length > 0) {\n\t\t\t// no textual data pasted, generate text from file names\n\t\t\tconst files: File[] = Array.prototype.slice.call(clipboardData.files, 0);\n\t\t\treturn [files.map(file => file.name).join('\\n'), null];\n\t\t}\n\t\treturn [text, metadata];\n\t},\n\n\tsetTextData(clipboardData: DataTransfer, text: string, html: string | null | undefined, metadata: ClipboardStoredMetadata): void {\n\t\tclipboardData.setData(Mimes.text, text);\n\t\tif (typeof html === 'string') {\n\t\t\tclipboardData.setData('text/html', html);\n\t\t}\n\t\tclipboardData.setData('vscode-editor-data', JSON.stringify(metadata));\n\t}\n};\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { IViewModel } from '../../../common/viewModel.js';\nimport { Range } from '../../../common/core/range.js';\nimport { isWindows } from '../../../../base/common/platform.js';\nimport { Mimes } from '../../../../base/common/mime.js';\nimport { ViewContext } from '../../../common/viewModel/viewContext.js';\nimport { ILogService, LogLevel } from '../../../../platform/log/common/log.js';\nimport { EditorOption, IComputedEditorOptions } from '../../../common/config/editorOptions.js';\nimport { generateUuid } from '../../../../base/common/uuid.js';\n\nexport function ensureClipboardGetsEditorSelection(e: ClipboardEvent, context: ViewContext, logService: ILogService, isFirefox: boolean): void {\n\tconst viewModel = context.viewModel;\n\tconst options = context.configuration.options;\n\tlet id: string | undefined = undefined;\n\tif (logService.getLevel() === LogLevel.Trace) {\n\t\tid = generateUuid();\n\t}\n\n\tconst { dataToCopy, storedMetadata } = generateDataToCopyAndStoreInMemory(viewModel, options, id, isFirefox);\n\n\t// !!!!!\n\t// This is a workaround for what we think is an Electron bug where\n\t// execCommand('copy') does not always work (it does not fire a clipboard event)\n\t// !!!!!\n\t// We signal that we have executed a copy command\n\tCopyOptions.electronBugWorkaroundCopyEventHasFired = true;\n\n\te.preventDefault();\n\tif (e.clipboardData) {\n\t\tClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, storedMetadata);\n\t}\n\tlogService.trace('ensureClipboardGetsEditorSelection with id : ', id, ' with text.length: ', dataToCopy.text.length);\n}\n\nexport function generateDataToCopyAndStoreInMemory(viewModel: IViewModel, options: IComputedEditorOptions, id: string | undefined, isFirefox: boolean) {\n\tconst emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);\n\tconst copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);\n\tconst selections = viewModel.getCursorStates().map(cursorState => cursorState.modelState.selection);\n\tconst dataToCopy = getDataToCopy(viewModel, selections, emptySelectionClipboard, copyWithSyntaxHighlighting);\n\tconst storedMetadata: ClipboardStoredMetadata = {\n\t\tversion: 1,\n\t\tid,\n\t\tisFromEmptySelection: dataToCopy.isFromEmptySelection,\n\t\tmulticursorText: dataToCopy.multicursorText,\n\t\tmode: dataToCopy.mode\n\t};\n\tInMemoryClipboardMetadataManager.INSTANCE.set(\n\t\t// When writing \"LINE\\r\\n\" to the clipboard and then pasting,\n\t\t// Firefox pastes \"LINE\\n\", so let's work around this quirk\n\t\t(isFirefox ? dataToCopy.text.replace(/\\r\\n/g, '\\n') : dataToCopy.text),\n\t\tstoredMetadata\n\t);\n\treturn { dataToCopy, storedMetadata };\n}\n\nfunction getDataToCopy(viewModel: IViewModel, modelSelections: Range[], emptySelectionClipboard: boolean, copyWithSyntaxHighlighting: boolean): ClipboardDataToCopy {\n\tconst rawTextToCopy = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);\n\tconst newLineCharacter = viewModel.model.getEOL();\n\n\tconst isFromEmptySelection = (emptySelectionClipboard && modelSelections.length === 1 && modelSelections[0].isEmpty());\n\tconst multicursorText = (Array.isArray(rawTextToCopy) ? rawTextToCopy : null);\n\tconst text = (Array.isArray(rawTextToCopy) ? rawTextToCopy.join(newLineCharacter) : rawTextToCopy);\n\n\tlet html: string | null | undefined = undefined;\n\tlet mode: string | null = null;\n\tif (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && text.length < 65536)) {\n\t\tconst richText = viewModel.getRichTextToCopy(modelSelections, emptySelectionClipboard);\n\t\tif (richText) {\n\t\t\thtml = richText.html;\n\t\t\tmode = richText.mode;\n\t\t}\n\t}\n\tconst dataToCopy: ClipboardDataToCopy = {\n\t\tisFromEmptySelection,\n\t\tmulticursorText,\n\t\ttext,\n\t\thtml,\n\t\tmode\n\t};\n\treturn dataToCopy;\n}\n\n/**\n * Every time we write to the clipboard, we record a bit of extra metadata here.\n * Every time we read from the cipboard, if the text matches our last written text,\n * we can fetch the previous metadata.\n */\nexport class InMemoryClipboardMetadataManager {\n\tpublic static readonly INSTANCE = new InMemoryClipboardMetadataManager();\n\n\tprivate _lastState: InMemoryClipboardMetadata | null;\n\n\tconstructor() {\n\t\tthis._lastState = null;\n\t}\n\n\tpublic set(lastCopiedValue: string, data: ClipboardStoredMetadata): void {\n\t\tthis._lastState = { lastCopiedValue, data };\n\t}\n\n\tpublic get(pastedText: string): ClipboardStoredMetadata | null {\n\t\tif (this._lastState && this._lastState.lastCopiedValue === pastedText) {\n\t\t\t// match!\n\t\t\treturn this._lastState.data;\n\t\t}\n\t\tthis._lastState = null;\n\t\treturn null;\n\t}\n}\n\nexport interface ClipboardDataToCopy {\n\tisFromEmptySelection: boolean;\n\tmulticursorText: string[] | null | undefined;\n\ttext: string;\n\thtml: string | null | undefined;\n\tmode: string | null;\n}\n\nexport interface ClipboardStoredMetadata {\n\tversion: 1;\n\tid: string | undefined;\n\tisFromEmptySelection: boolean | undefined;\n\tmulticursorText: string[] | null | undefined;\n\tmode: string | null;\n}\n\nexport const CopyOptions = {\n\tforceCopyWithSyntaxHighlighting: false,\n\telectronBugWorkaroundCopyEventHasFired: false\n};\n\ninterface InMemoryClipboardMetadata {\n\tlastCopiedValue: string;\n\tdata: ClipboardStoredMetadata;\n}\n\nexport const ClipboardEventUtils = {\n\n\tgetTextData(clipboardData: DataTransfer): [string, ClipboardStoredMetadata | null] {\n\t\tconst text = clipboardData.getData(Mimes.text);\n\t\tlet metadata: ClipboardStoredMetadata | null = null;\n\t\tconst rawmetadata = clipboardData.getData('vscode-editor-data');\n\t\tif (typeof rawmetadata === 'string') {\n\t\t\ttry {\n\t\t\t\tmetadata = <ClipboardStoredMetadata>JSON.parse(rawmetadata);\n\t\t\t\tif (metadata.version !== 1) {\n\t\t\t\t\tmetadata = null;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t// no problem!\n\t\t\t}\n\t\t}\n\t\tif (text.length === 0 && metadata === null && clipboardData.files.length > 0) {\n\t\t\t// no textual data pasted, generate text from file names\n\t\t\tconst files: File[] = Array.prototype.slice.call(clipboardData.files, 0);\n\t\t\treturn [files.map(file => file.name).join('\\n'), null];\n\t\t}\n\t\treturn [text, metadata];\n\t},\n\n\tsetTextData(clipboardData: DataTransfer, text: string, html: string | null | undefined, metadata: ClipboardStoredMetadata): void {\n\t\tclipboardData.setData(Mimes.text, text);\n\t\tif (typeof html === 'string') {\n\t\t\tclipboardData.setData('text/html', html);\n\t\t}\n\t\tclipboardData.setData('vscode-editor-data', JSON.stringify(metadata));\n\t}\n};\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/browser/controller/editContext/clipboardUtils.ts","vs/editor/browser/controller/editContext/clipboardUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAIxD,OAAO,EAAE,Y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EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;QACvG,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,GAAG,EAAE;YAChB,OAAO,GAAG,IAAI,CAAC;YACf,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,CAAC,CAAC,wBAAwB,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,SAAS,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC;KACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,YAA6C;IACxF,OAAO;QACN,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC;QAC5C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;KAC5D,CAAC;AACH,CAAC","file":"clipboardUtils.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { IViewModel } from '../../../common/viewModel.js';\nimport { Range } from '../../../common/core/range.js';\nimport { isWindows } from '../../../../base/common/platform.js';\nimport { Mimes } from '../../../../base/common/mime.js';\nimport { ViewContext } from '../../../common/viewModel/viewContext.js';\nimport { ILogService } from '../../../../platform/log/common/log.js';\nimport { EditorOption } from '../../../common/config/editorOptions.js';\nimport { generateUuid } from '../../../../base/common/uuid.js';\nimport { VSDataTransfer } from '../../../../base/common/dataTransfer.js';\nimport { toExternalVSDataTransfer } from '../../dataTransfer.js';\n\nexport function generateDataToCopyAndStoreInMemory(viewModel: IViewModel, id: string | undefined, isFirefox: boolean): { dataToCopy: ClipboardDataToCopy; metadata: ClipboardStoredMetadata } {\n\tconst { dataToCopy, metadata } = generateDataToCopy(viewModel);\n\tstoreMetadataInMemory(dataToCopy.text, metadata, isFirefox);\n\treturn { dataToCopy, metadata };\n}\n\nfunction storeMetadataInMemory(textToCopy: string, metadata: ClipboardStoredMetadata, isFirefox: boolean): void {\n\tInMemoryClipboardMetadataManager.INSTANCE.set(\n\t\t// When writing \"LINE\\r\\n\" to the clipboard and then pasting,\n\t\t// Firefox pastes \"LINE\\n\", so let's work around this quirk\n\t\t(isFirefox ? textToCopy.replace(/\\r\\n/g, '\\n') : textToCopy),\n\t\tmetadata\n\t);\n}\n\nfunction generateDataToCopy(viewModel: IViewModel): { dataToCopy: ClipboardDataToCopy; metadata: ClipboardStoredMetadata } {\n\tconst emptySelectionClipboard = viewModel.getEditorOption(EditorOption.emptySelectionClipboard);\n\tconst copyWithSyntaxHighlighting = viewModel.getEditorOption(EditorOption.copyWithSyntaxHighlighting);\n\tconst selections = viewModel.getCursorStates().map(cursorState => cursorState.modelState.selection);\n\tconst dataToCopy = getDataToCopy(viewModel, selections, emptySelectionClipboard, copyWithSyntaxHighlighting);\n\tconst metadata: ClipboardStoredMetadata = {\n\t\tversion: 1,\n\t\tid: generateUuid(),\n\t\tisFromEmptySelection: dataToCopy.isFromEmptySelection,\n\t\tmulticursorText: dataToCopy.multicursorText,\n\t\tmode: dataToCopy.mode\n\t};\n\treturn { dataToCopy, metadata };\n}\n\nfunction getDataToCopy(viewModel: IViewModel, modelSelections: Range[], emptySelectionClipboard: boolean, copyWithSyntaxHighlighting: boolean): ClipboardDataToCopy {\n\tconst { sourceRanges, sourceText } = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);\n\tconst newLineCharacter = viewModel.model.getEOL();\n\n\tconst isFromEmptySelection = (emptySelectionClipboard && modelSelections.length === 1 && modelSelections[0].isEmpty());\n\tconst multicursorText = (Array.isArray(sourceText) ? sourceText : null);\n\tconst text = (Array.isArray(sourceText) ? sourceText.join(newLineCharacter) : sourceText);\n\n\tlet html: string | null | undefined = undefined;\n\tlet mode: string | null = null;\n\tif (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && sourceText.length < 65536)) {\n\t\tconst richText = viewModel.getRichTextToCopy(modelSelections, emptySelectionClipboard);\n\t\tif (richText) {\n\t\t\thtml = richText.html;\n\t\t\tmode = richText.mode;\n\t\t}\n\t}\n\tconst dataToCopy: ClipboardDataToCopy = {\n\t\tisFromEmptySelection,\n\t\tsourceRanges,\n\t\tmulticursorText,\n\t\ttext,\n\t\thtml,\n\t\tmode\n\t};\n\treturn dataToCopy;\n}\n\n/**\n * Every time we write to the clipboard, we record a bit of extra metadata here.\n * Every time we read from the cipboard, if the text matches our last written text,\n * we can fetch the previous metadata.\n */\nexport class InMemoryClipboardMetadataManager {\n\tpublic static readonly INSTANCE = new InMemoryClipboardMetadataManager();\n\n\tprivate _lastState: InMemoryClipboardMetadata | null;\n\n\tconstructor() {\n\t\tthis._lastState = null;\n\t}\n\n\tpublic set(lastCopiedValue: string, data: ClipboardStoredMetadata): void {\n\t\tthis._lastState = { lastCopiedValue, data };\n\t}\n\n\tpublic get(pastedText: string): ClipboardStoredMetadata | null {\n\t\tif (this._lastState && this._lastState.lastCopiedValue === pastedText) {\n\t\t\t// match!\n\t\t\treturn this._lastState.data;\n\t\t}\n\t\tthis._lastState = null;\n\t\treturn null;\n\t}\n}\n\nexport interface ClipboardDataToCopy {\n\tisFromEmptySelection: boolean;\n\tsourceRanges: Range[];\n\tmulticursorText: string[] | null | undefined;\n\ttext: string;\n\thtml: string | null | undefined;\n\tmode: string | null;\n}\n\nexport interface ClipboardStoredMetadata {\n\tversion: 1;\n\tid: string | undefined;\n\tisFromEmptySelection: boolean | undefined;\n\tmulticursorText: string[] | null | undefined;\n\tmode: string | null;\n}\n\nexport const CopyOptions = {\n\tforceCopyWithSyntaxHighlighting: false,\n\telectronBugWorkaroundCopyEventHasFired: false\n};\n\ninterface InMemoryClipboardMetadata {\n\tlastCopiedValue: string;\n\tdata: ClipboardStoredMetadata;\n}\n\nconst ClipboardEventUtils = {\n\n\tgetTextData(clipboardData: IReadableClipboardData | DataTransfer): [string, ClipboardStoredMetadata | null] {\n\t\tconst text = clipboardData.getData(Mimes.text);\n\t\tlet metadata: ClipboardStoredMetadata | null = null;\n\t\tconst rawmetadata = clipboardData.getData('vscode-editor-data');\n\t\tif (typeof rawmetadata === 'string') {\n\t\t\ttry {\n\t\t\t\tmetadata = <ClipboardStoredMetadata>JSON.parse(rawmetadata);\n\t\t\t\tif (metadata.version !== 1) {\n\t\t\t\t\tmetadata = null;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t// no problem!\n\t\t\t}\n\t\t}\n\t\tif (text.length === 0 && metadata === null && clipboardData.files.length > 0) {\n\t\t\t// no textual data pasted, generate text from file names\n\t\t\tconst files: File[] = Array.prototype.slice.call(clipboardData.files, 0);\n\t\t\treturn [files.map(file => file.name).join('\\n'), null];\n\t\t}\n\t\treturn [text, metadata];\n\t},\n\n\tsetTextData(clipboardData: IWritableClipboardData, text: string, html: string | null | undefined, metadata: ClipboardStoredMetadata): void {\n\t\tclipboardData.setData(Mimes.text, text);\n\t\tif (typeof html === 'string') {\n\t\t\tclipboardData.setData('text/html', html);\n\t\t}\n\t\tclipboardData.setData('vscode-editor-data', JSON.stringify(metadata));\n\t}\n};\n\n/**\n * Readable clipboard data for paste operations.\n */\nexport interface IReadableClipboardData {\n\t/**\n\t * All MIME types present in the clipboard.\n\t */\n\ttypes: string[];\n\n\t/**\n\t * Files from the clipboard (for paste operations).\n\t */\n\treadonly files: readonly File[];\n\n\t/**\n\t * Get data for a specific MIME type.\n\t */\n\tgetData(type: string): string;\n}\n\n/**\n * Writable clipboard data for copy/cut operations.\n */\nexport interface IWritableClipboardData {\n\t/**\n\t * Set data for a specific MIME type.\n\t */\n\tsetData(type: string, value: string): void;\n}\n\n/**\n * Event data for clipboard copy/cut events.\n */\nexport interface IClipboardCopyEvent {\n\t/**\n\t * Whether this is a cut operation.\n\t */\n\treadonly isCut: boolean;\n\n\t/**\n\t * The clipboard data to write to.\n\t */\n\treadonly clipboardData: IWritableClipboardData;\n\n\t/**\n\t * The data to be copied to the clipboard.\n\t */\n\treadonly dataToCopy: ClipboardDataToCopy;\n\n\t/**\n\t * Ensure that the clipboard gets the editor data.\n\t */\n\tensureClipboardGetsEditorData(): void;\n\n\t/**\n\t * Signal that the event has been handled and default processing should be skipped.\n\t */\n\tsetHandled(): void;\n\n\t/**\n\t * Whether the event has been marked as handled.\n\t */\n\treadonly isHandled: boolean;\n}\n\n/**\n * Event data for clipboard paste events.\n */\nexport interface IClipboardPasteEvent {\n\t/**\n\t * The clipboard data being pasted.\n\t */\n\treadonly clipboardData: IReadableClipboardData;\n\n\t/**\n\t * The metadata stored alongside the clipboard data, if any.\n\t */\n\treadonly metadata: ClipboardStoredMetadata | null;\n\n\t/**\n\t * The text content being pasted.\n\t */\n\treadonly text: string;\n\n\t/**\n\t * The underlying DOM event, if available.\n\t * @deprecated Use clipboardData instead. This is provided for backward compatibility.\n\t */\n\treadonly browserEvent: ClipboardEvent | undefined;\n\n\ttoExternalVSDataTransfer(): VSDataTransfer | undefined;\n\n\t/**\n\t * Signal that the event has been handled and default processing should be skipped.\n\t */\n\tsetHandled(): void;\n\n\t/**\n\t * Whether the event has been marked as handled.\n\t */\n\treadonly isHandled: boolean;\n}\n\n/**\n * Creates an IClipboardCopyEvent from a DOM ClipboardEvent.\n */\nexport function createClipboardCopyEvent(e: ClipboardEvent, isCut: boolean, context: ViewContext, logService: ILogService, isFirefox: boolean): IClipboardCopyEvent {\n\tconst { dataToCopy, metadata } = generateDataToCopy(context.viewModel);\n\tlet handled = false;\n\treturn {\n\t\tisCut,\n\t\tclipboardData: {\n\t\t\tsetData: (type: string, value: string) => {\n\t\t\t\te.clipboardData?.setData(type, value);\n\t\t\t},\n\t\t},\n\t\tdataToCopy,\n\t\tensureClipboardGetsEditorData: (): void => {\n\t\t\te.preventDefault();\n\t\t\tif (e.clipboardData) {\n\t\t\t\tClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, metadata);\n\t\t\t}\n\t\t\tstoreMetadataInMemory(dataToCopy.text, metadata, isFirefox);\n\t\t\tlogService.trace('ensureClipboardGetsEditorSelection with id : ', metadata.id, ' with text.length: ', dataToCopy.text.length);\n\t\t},\n\t\tsetHandled: () => {\n\t\t\thandled = true;\n\t\t\te.preventDefault();\n\t\t\te.stopImmediatePropagation();\n\t\t},\n\t\tget isHandled() { return handled; },\n\t};\n}\n\n/**\n * Creates an IClipboardPasteEvent from a DOM ClipboardEvent.\n */\nexport function createClipboardPasteEvent(e: ClipboardEvent): IClipboardPasteEvent {\n\tlet handled = false;\n\tlet [text, metadata] = e.clipboardData ? ClipboardEventUtils.getTextData(e.clipboardData) : ['', null];\n\tmetadata = metadata || InMemoryClipboardMetadataManager.INSTANCE.get(text);\n\treturn {\n\t\tclipboardData: createReadableClipboardData(e.clipboardData),\n\t\tmetadata,\n\t\ttext,\n\t\ttoExternalVSDataTransfer: () => e.clipboardData ? toExternalVSDataTransfer(e.clipboardData) : undefined,\n\t\tbrowserEvent: e,\n\t\tsetHandled: () => {\n\t\t\thandled = true;\n\t\t\te.preventDefault();\n\t\t\te.stopImmediatePropagation();\n\t\t},\n\t\tget isHandled() { return handled; },\n\t};\n}\n\nexport function createReadableClipboardData(dataTransfer: DataTransfer | undefined | null): IReadableClipboardData {\n\treturn {\n\t\ttypes: Array.from(dataTransfer?.types ?? []),\n\t\tfiles: Array.prototype.slice.call(dataTransfer?.files ?? [], 0),\n\t\tgetData: (type: string) => dataTransfer?.getData(type) ?? '',\n\t};\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport { IViewModel } from '../../../common/viewModel.js';\nimport { Range } from '../../../common/core/range.js';\nimport { isWindows } from '../../../../base/common/platform.js';\nimport { Mimes } from '../../../../base/common/mime.js';\nimport { ViewContext } from '../../../common/viewModel/viewContext.js';\nimport { ILogService } from '../../../../platform/log/common/log.js';\nimport { EditorOption } from '../../../common/config/editorOptions.js';\nimport { generateUuid } from '../../../../base/common/uuid.js';\nimport { VSDataTransfer } from '../../../../base/common/dataTransfer.js';\nimport { toExternalVSDataTransfer } from '../../dataTransfer.js';\n\nexport function generateDataToCopyAndStoreInMemory(viewModel: IViewModel, id: string | undefined, isFirefox: boolean): { dataToCopy: ClipboardDataToCopy; metadata: ClipboardStoredMetadata } {\n\tconst { dataToCopy, metadata } = generateDataToCopy(viewModel);\n\tstoreMetadataInMemory(dataToCopy.text, metadata, isFirefox);\n\treturn { dataToCopy, metadata };\n}\n\nfunction storeMetadataInMemory(textToCopy: string, metadata: ClipboardStoredMetadata, isFirefox: boolean): void {\n\tInMemoryClipboardMetadataManager.INSTANCE.set(\n\t\t// When writing \"LINE\\r\\n\" to the clipboard and then pasting,\n\t\t// Firefox pastes \"LINE\\n\", so let's work around this quirk\n\t\t(isFirefox ? textToCopy.replace(/\\r\\n/g, '\\n') : textToCopy),\n\t\tmetadata\n\t);\n}\n\nfunction generateDataToCopy(viewModel: IViewModel): { dataToCopy: ClipboardDataToCopy; metadata: ClipboardStoredMetadata } {\n\tconst emptySelectionClipboard = viewModel.getEditorOption(EditorOption.emptySelectionClipboard);\n\tconst copyWithSyntaxHighlighting = viewModel.getEditorOption(EditorOption.copyWithSyntaxHighlighting);\n\tconst selections = viewModel.getCursorStates().map(cursorState => cursorState.modelState.selection);\n\tconst dataToCopy = getDataToCopy(viewModel, selections, emptySelectionClipboard, copyWithSyntaxHighlighting);\n\tconst metadata: ClipboardStoredMetadata = {\n\t\tversion: 1,\n\t\tid: generateUuid(),\n\t\tisFromEmptySelection: dataToCopy.isFromEmptySelection,\n\t\tmulticursorText: dataToCopy.multicursorText,\n\t\tmode: dataToCopy.mode\n\t};\n\treturn { dataToCopy, metadata };\n}\n\nfunction getDataToCopy(viewModel: IViewModel, modelSelections: Range[], emptySelectionClipboard: boolean, copyWithSyntaxHighlighting: boolean): ClipboardDataToCopy {\n\tconst { sourceRanges, sourceText } = viewModel.getPlainTextToCopy(modelSelections, emptySelectionClipboard, isWindows);\n\tconst newLineCharacter = viewModel.model.getEOL();\n\n\tconst isFromEmptySelection = (emptySelectionClipboard && modelSelections.length === 1 && modelSelections[0].isEmpty());\n\tconst multicursorText = (Array.isArray(sourceText) ? sourceText : null);\n\tconst text = (Array.isArray(sourceText) ? sourceText.join(newLineCharacter) : sourceText);\n\n\tlet html: string | null | undefined = undefined;\n\tlet mode: string | null = null;\n\tif (CopyOptions.forceCopyWithSyntaxHighlighting || (copyWithSyntaxHighlighting && sourceText.length < 65536)) {\n\t\tconst richText = viewModel.getRichTextToCopy(modelSelections, emptySelectionClipboard);\n\t\tif (richText) {\n\t\t\thtml = richText.html;\n\t\t\tmode = richText.mode;\n\t\t}\n\t}\n\tconst dataToCopy: ClipboardDataToCopy = {\n\t\tisFromEmptySelection,\n\t\tsourceRanges,\n\t\tmulticursorText,\n\t\ttext,\n\t\thtml,\n\t\tmode\n\t};\n\treturn dataToCopy;\n}\n\n/**\n * Every time we write to the clipboard, we record a bit of extra metadata here.\n * Every time we read from the cipboard, if the text matches our last written text,\n * we can fetch the previous metadata.\n */\nexport class InMemoryClipboardMetadataManager {\n\tpublic static readonly INSTANCE = new InMemoryClipboardMetadataManager();\n\n\tprivate _lastState: InMemoryClipboardMetadata | null;\n\n\tconstructor() {\n\t\tthis._lastState = null;\n\t}\n\n\tpublic set(lastCopiedValue: string, data: ClipboardStoredMetadata): void {\n\t\tthis._lastState = { lastCopiedValue, data };\n\t}\n\n\tpublic get(pastedText: string): ClipboardStoredMetadata | null {\n\t\tif (this._lastState && this._lastState.lastCopiedValue === pastedText) {\n\t\t\t// match!\n\t\t\treturn this._lastState.data;\n\t\t}\n\t\tthis._lastState = null;\n\t\treturn null;\n\t}\n}\n\nexport interface ClipboardDataToCopy {\n\tisFromEmptySelection: boolean;\n\tsourceRanges: Range[];\n\tmulticursorText: string[] | null | undefined;\n\ttext: string;\n\thtml: string | null | undefined;\n\tmode: string | null;\n}\n\nexport interface ClipboardStoredMetadata {\n\tversion: 1;\n\tid: string | undefined;\n\tisFromEmptySelection: boolean | undefined;\n\tmulticursorText: string[] | null | undefined;\n\tmode: string | null;\n}\n\nexport const CopyOptions = {\n\tforceCopyWithSyntaxHighlighting: false,\n\telectronBugWorkaroundCopyEventHasFired: false\n};\n\ninterface InMemoryClipboardMetadata {\n\tlastCopiedValue: string;\n\tdata: ClipboardStoredMetadata;\n}\n\nconst ClipboardEventUtils = {\n\n\tgetTextData(clipboardData: IReadableClipboardData | DataTransfer): [string, ClipboardStoredMetadata | null] {\n\t\tconst text = clipboardData.getData(Mimes.text);\n\t\tlet metadata: ClipboardStoredMetadata | null = null;\n\t\tconst rawmetadata = clipboardData.getData('vscode-editor-data');\n\t\tif (typeof rawmetadata === 'string') {\n\t\t\ttry {\n\t\t\t\tmetadata = <ClipboardStoredMetadata>JSON.parse(rawmetadata);\n\t\t\t\tif (metadata.version !== 1) {\n\t\t\t\t\tmetadata = null;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\t// no problem!\n\t\t\t}\n\t\t}\n\t\tif (text.length === 0 && metadata === null && clipboardData.files.length > 0) {\n\t\t\t// no textual data pasted, generate text from file names\n\t\t\tconst files: File[] = Array.prototype.slice.call(clipboardData.files, 0);\n\t\t\treturn [files.map(file => file.name).join('\\n'), null];\n\t\t}\n\t\treturn [text, metadata];\n\t},\n\n\tsetTextData(clipboardData: IWritableClipboardData, text: string, html: string | null | undefined, metadata: ClipboardStoredMetadata): void {\n\t\tclipboardData.setData(Mimes.text, text);\n\t\tif (typeof html === 'string') {\n\t\t\tclipboardData.setData('text/html', html);\n\t\t}\n\t\tclipboardData.setData('vscode-editor-data', JSON.stringify(metadata));\n\t}\n};\n\n/**\n * Readable clipboard data for paste operations.\n */\nexport interface IReadableClipboardData {\n\t/**\n\t * All MIME types present in the clipboard.\n\t */\n\ttypes: string[];\n\n\t/**\n\t * Files from the clipboard (for paste operations).\n\t */\n\treadonly files: readonly File[];\n\n\t/**\n\t * Get data for a specific MIME type.\n\t */\n\tgetData(type: string): string;\n}\n\n/**\n * Writable clipboard data for copy/cut operations.\n */\nexport interface IWritableClipboardData {\n\t/**\n\t * Set data for a specific MIME type.\n\t */\n\tsetData(type: string, value: string): void;\n}\n\n/**\n * Event data for clipboard copy/cut events.\n */\nexport interface IClipboardCopyEvent {\n\t/**\n\t * Whether this is a cut operation.\n\t */\n\treadonly isCut: boolean;\n\n\t/**\n\t * The clipboard data to write to.\n\t */\n\treadonly clipboardData: IWritableClipboardData;\n\n\t/**\n\t * The data to be copied to the clipboard.\n\t */\n\treadonly dataToCopy: ClipboardDataToCopy;\n\n\t/**\n\t * Ensure that the clipboard gets the editor data.\n\t */\n\tensureClipboardGetsEditorData(): void;\n\n\t/**\n\t * Signal that the event has been handled and default processing should be skipped.\n\t */\n\tsetHandled(): void;\n\n\t/**\n\t * Whether the event has been marked as handled.\n\t */\n\treadonly isHandled: boolean;\n}\n\n/**\n * Event data for clipboard paste events.\n */\nexport interface IClipboardPasteEvent {\n\t/**\n\t * The clipboard data being pasted.\n\t */\n\treadonly clipboardData: IReadableClipboardData;\n\n\t/**\n\t * The metadata stored alongside the clipboard data, if any.\n\t */\n\treadonly metadata: ClipboardStoredMetadata | null;\n\n\t/**\n\t * The text content being pasted.\n\t */\n\treadonly text: string;\n\n\t/**\n\t * The underlying DOM event, if available.\n\t * @deprecated Use clipboardData instead. This is provided for backward compatibility.\n\t */\n\treadonly browserEvent: ClipboardEvent | undefined;\n\n\ttoExternalVSDataTransfer(): VSDataTransfer | undefined;\n\n\t/**\n\t * Signal that the event has been handled and default processing should be skipped.\n\t */\n\tsetHandled(): void;\n\n\t/**\n\t * Whether the event has been marked as handled.\n\t */\n\treadonly isHandled: boolean;\n}\n\n/**\n * Creates an IClipboardCopyEvent from a DOM ClipboardEvent.\n */\nexport function createClipboardCopyEvent(e: ClipboardEvent, isCut: boolean, context: ViewContext, logService: ILogService, isFirefox: boolean): IClipboardCopyEvent {\n\tconst { dataToCopy, metadata } = generateDataToCopy(context.viewModel);\n\tlet handled = false;\n\treturn {\n\t\tisCut,\n\t\tclipboardData: {\n\t\t\tsetData: (type: string, value: string) => {\n\t\t\t\te.clipboardData?.setData(type, value);\n\t\t\t},\n\t\t},\n\t\tdataToCopy,\n\t\tensureClipboardGetsEditorData: (): void => {\n\t\t\te.preventDefault();\n\t\t\tif (e.clipboardData) {\n\t\t\t\tClipboardEventUtils.setTextData(e.clipboardData, dataToCopy.text, dataToCopy.html, metadata);\n\t\t\t}\n\t\t\tstoreMetadataInMemory(dataToCopy.text, metadata, isFirefox);\n\t\t\tlogService.trace('ensureClipboardGetsEditorSelection with id : ', metadata.id, ' with text.length: ', dataToCopy.text.length);\n\t\t},\n\t\tsetHandled: () => {\n\t\t\thandled = true;\n\t\t\te.preventDefault();\n\t\t\te.stopImmediatePropagation();\n\t\t},\n\t\tget isHandled() { return handled; },\n\t};\n}\n\n/**\n * Creates an IClipboardPasteEvent from a DOM ClipboardEvent.\n */\nexport function createClipboardPasteEvent(e: ClipboardEvent): IClipboardPasteEvent {\n\tlet handled = false;\n\tlet [text, metadata] = e.clipboardData ? ClipboardEventUtils.getTextData(e.clipboardData) : ['', null];\n\tmetadata = metadata || InMemoryClipboardMetadataManager.INSTANCE.get(text);\n\treturn {\n\t\tclipboardData: createReadableClipboardData(e.clipboardData),\n\t\tmetadata,\n\t\ttext,\n\t\ttoExternalVSDataTransfer: () => e.clipboardData ? toExternalVSDataTransfer(e.clipboardData) : undefined,\n\t\tbrowserEvent: e,\n\t\tsetHandled: () => {\n\t\t\thandled = true;\n\t\t\te.preventDefault();\n\t\t\te.stopImmediatePropagation();\n\t\t},\n\t\tget isHandled() { return handled; },\n\t};\n}\n\nexport function createReadableClipboardData(dataTransfer: DataTransfer | undefined | null): IReadableClipboardData {\n\treturn {\n\t\ttypes: Array.from(dataTransfer?.types ?? []),\n\t\tfiles: Array.prototype.slice.call(dataTransfer?.files ?? [], 0),\n\t\tgetData: (type: string) => dataTransfer?.getData(type) ?? '',\n\t};\n}\n"]}
@@ -2,7 +2,18 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ import { Emitter } from '../../../../base/common/event.js';
5
6
  import { ViewPart } from '../../view/viewPart.js';
6
7
  export class AbstractEditContext extends ViewPart {
8
+ constructor() {
9
+ super(...arguments);
10
+ // Clipboard events - emitted before the default clipboard handling
11
+ this._onWillCopy = this._register(new Emitter());
12
+ this.onWillCopy = this._onWillCopy.event;
13
+ this._onWillCut = this._register(new Emitter());
14
+ this.onWillCut = this._onWillCut.event;
15
+ this._onWillPaste = this._register(new Emitter());
16
+ this.onWillPaste = this._onWillPaste.event;
17
+ }
7
18
  }
8
19
  //# sourceMappingURL=editContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/browser/controller/editContext/editContext.ts","vs/editor/browser/controller/editContext/editContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAKhG,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,MAAM,OAAgB,mBAAoB,SAAQ,QAAQ;CAQzD","file":"editContext.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { FastDomNode } from '../../../../base/browser/fastDomNode.js';\nimport { Position } from '../../../common/core/position.js';\nimport { IEditorAriaOptions } from '../../editorBrowser.js';\nimport { ViewPart } from '../../view/viewPart.js';\n\nexport abstract class AbstractEditContext extends ViewPart {\n\tabstract domNode: FastDomNode<HTMLElement>;\n\tabstract focus(): void;\n\tabstract isFocused(): boolean;\n\tabstract refreshFocusState(): void;\n\tabstract setAriaOptions(options: IEditorAriaOptions): void;\n\tabstract getLastRenderData(): Position | null;\n\tabstract writeScreenReaderContent(reason: string): void;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { FastDomNode } from '../../../../base/browser/fastDomNode.js';\nimport { Position } from '../../../common/core/position.js';\nimport { IEditorAriaOptions } from '../../editorBrowser.js';\nimport { ViewPart } from '../../view/viewPart.js';\n\nexport abstract class AbstractEditContext extends ViewPart {\n\tabstract domNode: FastDomNode<HTMLElement>;\n\tabstract focus(): void;\n\tabstract isFocused(): boolean;\n\tabstract refreshFocusState(): void;\n\tabstract setAriaOptions(options: IEditorAriaOptions): void;\n\tabstract getLastRenderData(): Position | null;\n\tabstract writeScreenReaderContent(reason: string): void;\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/browser/controller/editContext/editContext.ts","vs/editor/browser/controller/editContext/editContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,OAAO,EAAS,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,MAAM,OAAgB,mBAAoB,SAAQ,QAAQ;IAA1D;;QASC,mEAAmE;QAChD,gBAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,EAAuB,CAAC,CAAC;QACpE,eAAU,GAA+B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAE7D,eAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,EAAuB,CAAC,CAAC;QACnE,cAAS,GAA+B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAE3D,iBAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,EAAwB,CAAC,CAAC;QACtE,gBAAW,GAAgC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACpF,CAAC;CAAA","file":"editContext.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { FastDomNode } from '../../../../base/browser/fastDomNode.js';\nimport { Emitter, Event } from '../../../../base/common/event.js';\nimport { Position } from '../../../common/core/position.js';\nimport { IEditorAriaOptions } from '../../editorBrowser.js';\nimport { ViewPart } from '../../view/viewPart.js';\nimport { IClipboardCopyEvent, IClipboardPasteEvent } from './clipboardUtils.js';\n\nexport abstract class AbstractEditContext extends ViewPart {\n\tabstract domNode: FastDomNode<HTMLElement>;\n\tabstract focus(): void;\n\tabstract isFocused(): boolean;\n\tabstract refreshFocusState(): void;\n\tabstract setAriaOptions(options: IEditorAriaOptions): void;\n\tabstract getLastRenderData(): Position | null;\n\tabstract writeScreenReaderContent(reason: string): void;\n\n\t// Clipboard events - emitted before the default clipboard handling\n\tprotected readonly _onWillCopy = this._register(new Emitter<IClipboardCopyEvent>());\n\tpublic readonly onWillCopy: Event<IClipboardCopyEvent> = this._onWillCopy.event;\n\n\tprotected readonly _onWillCut = this._register(new Emitter<IClipboardCopyEvent>());\n\tpublic readonly onWillCut: Event<IClipboardCopyEvent> = this._onWillCut.event;\n\n\tprotected readonly _onWillPaste = this._register(new Emitter<IClipboardPasteEvent>());\n\tpublic readonly onWillPaste: Event<IClipboardPasteEvent> = this._onWillPaste.event;\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { FastDomNode } from '../../../../base/browser/fastDomNode.js';\nimport { Emitter, Event } from '../../../../base/common/event.js';\nimport { Position } from '../../../common/core/position.js';\nimport { IEditorAriaOptions } from '../../editorBrowser.js';\nimport { ViewPart } from '../../view/viewPart.js';\nimport { IClipboardCopyEvent, IClipboardPasteEvent } from './clipboardUtils.js';\n\nexport abstract class AbstractEditContext extends ViewPart {\n\tabstract domNode: FastDomNode<HTMLElement>;\n\tabstract focus(): void;\n\tabstract isFocused(): boolean;\n\tabstract refreshFocusState(): void;\n\tabstract setAriaOptions(options: IEditorAriaOptions): void;\n\tabstract getLastRenderData(): Position | null;\n\tabstract writeScreenReaderContent(reason: string): void;\n\n\t// Clipboard events - emitted before the default clipboard handling\n\tprotected readonly _onWillCopy = this._register(new Emitter<IClipboardCopyEvent>());\n\tpublic readonly onWillCopy: Event<IClipboardCopyEvent> = this._onWillCopy.event;\n\n\tprotected readonly _onWillCut = this._register(new Emitter<IClipboardCopyEvent>());\n\tpublic readonly onWillCut: Event<IClipboardCopyEvent> = this._onWillCut.event;\n\n\tprotected readonly _onWillPaste = this._register(new Emitter<IClipboardPasteEvent>());\n\tpublic readonly onWillPaste: Event<IClipboardPasteEvent> = this._onWillPaste.event;\n}\n"]}
@@ -17,7 +17,7 @@ import { addDisposableListener, getActiveElement, getWindow, getWindowId } from
17
17
  import { FastDomNode } from '../../../../../base/browser/fastDomNode.js';
18
18
  import { StandardKeyboardEvent } from '../../../../../base/browser/keyboardEvent.js';
19
19
  import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
20
- import { ClipboardEventUtils, ensureClipboardGetsEditorSelection, InMemoryClipboardMetadataManager } from '../clipboardUtils.js';
20
+ import { CopyOptions, createClipboardCopyEvent, createClipboardPasteEvent } from '../clipboardUtils.js';
21
21
  import { AbstractEditContext } from '../editContext.js';
22
22
  import { editContextAddDisposableListener, FocusTracker } from './nativeEditContextUtils.js';
23
23
  import { ScreenReaderSupport } from './screenReaderSupport.js';
@@ -79,14 +79,30 @@ let NativeEditContext = class NativeEditContext extends AbstractEditContext {
79
79
  this._screenReaderSupport = this._register(instantiationService.createInstance(ScreenReaderSupport, this.domNode, context, this._viewController));
80
80
  this._register(addDisposableListener(this.domNode.domNode, 'copy', (e) => {
81
81
  this.logService.trace('NativeEditContext#copy');
82
- ensureClipboardGetsEditorSelection(e, this._context, this.logService, isFirefox);
82
+ // !!!!!
83
+ // This is a workaround for what we think is an Electron bug where
84
+ // execCommand('copy') does not always work (it does not fire a clipboard event)
85
+ // !!!!!
86
+ // We signal that we have executed a copy command
87
+ CopyOptions.electronBugWorkaroundCopyEventHasFired = true;
88
+ const copyEvent = createClipboardCopyEvent(e, /* isCut */ false, this._context, this.logService, isFirefox);
89
+ this._onWillCopy.fire(copyEvent);
90
+ if (copyEvent.isHandled) {
91
+ return;
92
+ }
93
+ copyEvent.ensureClipboardGetsEditorData();
83
94
  }));
84
95
  this._register(addDisposableListener(this.domNode.domNode, 'cut', (e) => {
85
96
  this.logService.trace('NativeEditContext#cut');
97
+ const cutEvent = createClipboardCopyEvent(e, /* isCut */ true, this._context, this.logService, isFirefox);
98
+ this._onWillCut.fire(cutEvent);
99
+ if (cutEvent.isHandled) {
100
+ return;
101
+ }
86
102
  // Pretend here we touched the text area, as the `cut` event will most likely
87
103
  // result in a `selectionchange` event which we want to ignore
88
104
  this._screenReaderSupport.onWillCut();
89
- ensureClipboardGetsEditorSelection(e, this._context, this.logService, isFirefox);
105
+ cutEvent.ensureClipboardGetsEditorData();
90
106
  this.logService.trace('NativeEditContext#cut (before viewController.cut)');
91
107
  this._viewController.cut();
92
108
  }));
@@ -105,28 +121,32 @@ let NativeEditContext = class NativeEditContext extends AbstractEditContext {
105
121
  }));
106
122
  this._register(addDisposableListener(this.domNode.domNode, 'paste', (e) => {
107
123
  this.logService.trace('NativeEditContext#paste');
124
+ const pasteEvent = createClipboardPasteEvent(e);
125
+ this._onWillPaste.fire(pasteEvent);
126
+ if (pasteEvent.isHandled) {
127
+ e.preventDefault();
128
+ return;
129
+ }
108
130
  e.preventDefault();
109
131
  if (!e.clipboardData) {
110
132
  return;
111
133
  }
112
- let [text, metadata] = ClipboardEventUtils.getTextData(e.clipboardData);
113
- this.logService.trace('NativeEditContext#paste with id : ', metadata?.id, ' with text.length: ', text.length);
114
- if (!text) {
134
+ this.logService.trace('NativeEditContext#paste with id : ', pasteEvent.metadata?.id, ' with text.length: ', pasteEvent.text.length);
135
+ if (!pasteEvent.text) {
115
136
  return;
116
137
  }
117
- metadata = metadata || InMemoryClipboardMetadataManager.INSTANCE.get(text);
118
138
  let pasteOnNewLine = false;
119
139
  let multicursorText = null;
120
140
  let mode = null;
121
- if (metadata) {
141
+ if (pasteEvent.metadata) {
122
142
  const options = this._context.configuration.options;
123
143
  const emptySelectionClipboard = options.get(45 /* EditorOption.emptySelectionClipboard */);
124
- pasteOnNewLine = emptySelectionClipboard && !!metadata.isFromEmptySelection;
125
- multicursorText = typeof metadata.multicursorText !== 'undefined' ? metadata.multicursorText : null;
126
- mode = metadata.mode;
144
+ pasteOnNewLine = emptySelectionClipboard && !!pasteEvent.metadata.isFromEmptySelection;
145
+ multicursorText = typeof pasteEvent.metadata.multicursorText !== 'undefined' ? pasteEvent.metadata.multicursorText : null;
146
+ mode = pasteEvent.metadata.mode;
127
147
  }
128
148
  this.logService.trace('NativeEditContext#paste (before viewController.paste)');
129
- this._viewController.paste(text, pasteOnNewLine, multicursorText, mode);
149
+ this._viewController.paste(pasteEvent.text, pasteOnNewLine, multicursorText, mode);
130
150
  }));
131
151
  // Edit context events
132
152
  this._register(editContextAddDisposableListener(this._editContext, 'textformatupdate', (e) => this._handleTextFormatUpdate(e)));
@@ -258,15 +278,15 @@ let NativeEditContext = class NativeEditContext extends AbstractEditContext {
258
278
  onZonesChanged(e) {
259
279
  return true;
260
280
  }
261
- onWillPaste() {
262
- this.logService.trace('NativeEditContext#onWillPaste');
263
- this._onWillPaste();
281
+ handleWillPaste() {
282
+ this.logService.trace('NativeEditContext#handleWillPaste');
283
+ this._prepareScreenReaderForPaste();
264
284
  }
265
- _onWillPaste() {
285
+ _prepareScreenReaderForPaste() {
266
286
  this._screenReaderSupport.onWillPaste();
267
287
  }
268
- onWillCopy() {
269
- this.logService.trace('NativeEditContext#onWillCopy');
288
+ handleWillCopy() {
289
+ this.logService.trace('NativeEditContext#handleWillCopy');
270
290
  this.logService.trace('NativeEditContext#isFocused : ', this.domNode.domNode === getActiveElement());
271
291
  }
272
292
  writeScreenReaderContent() {