mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
This commit is contained in:
parent
a1cea6776f
commit
1dfebf5ed3
@ -17,7 +17,7 @@ import CodeMirrorControl from '@joplin/editor/CodeMirror/CodeMirrorControl';
|
||||
export function initCodeMirror(
|
||||
parentElement: HTMLElement, initialText: string, settings: EditorSettings,
|
||||
): CodeMirrorControl {
|
||||
return createEditor(parentElement, {
|
||||
const editor = createEditor(parentElement, {
|
||||
initialText,
|
||||
settings,
|
||||
|
||||
@ -28,5 +28,20 @@ export function initCodeMirror(
|
||||
postMessage('onEditorEvent', event);
|
||||
},
|
||||
});
|
||||
|
||||
// Works around https://github.com/laurent22/joplin/issues/10047 by handling
|
||||
// the text/uri-list MIME type when pasting, rather than sending the paste event
|
||||
// to CodeMirror.
|
||||
//
|
||||
// TODO: Remove this workaround when the issue has been fixed upstream.
|
||||
editor.on('paste', (_editor, event: ClipboardEvent) => {
|
||||
const clipboardData = event.clipboardData;
|
||||
if (clipboardData.types.length === 1 && clipboardData.types[0] === 'text/uri-list') {
|
||||
event.preventDefault();
|
||||
editor.insertText(clipboardData.getData('text/uri-list'));
|
||||
}
|
||||
});
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user