|
@@ -1224,7 +1224,19 @@ export abstract class AttachmentsCell extends Cell {
|
|
|
*/
|
|
|
private _evtPaste(event: ClipboardEvent): void {
|
|
|
if (event.clipboardData) {
|
|
|
- this._attachFiles(event.clipboardData.items);
|
|
|
+ const items = event.clipboardData.items;
|
|
|
+ for (let i = 0; i < items.length; i++) {
|
|
|
+ if (items[i].type === 'text/plain') {
|
|
|
+ // Skip if this text is the path to a file
|
|
|
+ if (i < items.length - 1 && items[i + 1].kind === 'file') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ items[i].getAsString(text => {
|
|
|
+ this.editor.replaceSelection?.(text);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this._attachFiles(event.clipboardData.items);
|
|
|
+ }
|
|
|
}
|
|
|
event.preventDefault();
|
|
|
}
|
|
@@ -1385,6 +1397,9 @@ export class MarkdownCell extends AttachmentsCell {
|
|
|
})
|
|
|
});
|
|
|
|
|
|
+ // Stop codemirror handling paste
|
|
|
+ this.editor.setOption('handlePaste', false);
|
|
|
+
|
|
|
// Throttle the rendering rate of the widget.
|
|
|
this._monitor = new ActivityMonitor({
|
|
|
signal: this.model.contentChanged,
|
|
@@ -1468,7 +1483,7 @@ export class MarkdownCell extends AttachmentsCell {
|
|
|
) {
|
|
|
const textToBeAppended = ``;
|
|
|
- this.model.value.insert(this.model.value.text.length, textToBeAppended);
|
|
|
+ this.editor.replaceSelection?.(textToBeAppended);
|
|
|
}
|
|
|
|
|
|
/**
|