1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

iOS: Fixes #10047: Allow pasting URLs copied from the share sheet (#10048)

This commit is contained in:
Henry Heino 2024-03-05 08:57:18 -08:00 committed by GitHub
parent a1cea6776f
commit 1dfebf5ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}