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

macOS: Fixed paste as text in Rich Text editor

This commit is contained in:
Laurent Cozic 2021-01-01 12:38:17 +00:00
parent 568d11bddf
commit 83b29d7c51
3 changed files with 24 additions and 15 deletions

View File

@ -1475,9 +1475,12 @@ packages/server/src/db.js.map
packages/server/src/middleware/notificationHandler.d.ts packages/server/src/middleware/notificationHandler.d.ts
packages/server/src/middleware/notificationHandler.js packages/server/src/middleware/notificationHandler.js
packages/server/src/middleware/notificationHandler.js.map packages/server/src/middleware/notificationHandler.js.map
packages/server/src/middleware/requestProcessor.d.ts packages/server/src/middleware/ownerHandler.d.ts
packages/server/src/middleware/requestProcessor.js packages/server/src/middleware/ownerHandler.js
packages/server/src/middleware/requestProcessor.js.map packages/server/src/middleware/ownerHandler.js.map
packages/server/src/middleware/routeHandler.d.ts
packages/server/src/middleware/routeHandler.js
packages/server/src/middleware/routeHandler.js.map
packages/server/src/migrations/20190913171451_create.d.ts packages/server/src/migrations/20190913171451_create.d.ts
packages/server/src/migrations/20190913171451_create.js packages/server/src/migrations/20190913171451_create.js
packages/server/src/migrations/20190913171451_create.js.map packages/server/src/migrations/20190913171451_create.js.map

9
.gitignore vendored
View File

@ -1464,9 +1464,12 @@ packages/server/src/db.js.map
packages/server/src/middleware/notificationHandler.d.ts packages/server/src/middleware/notificationHandler.d.ts
packages/server/src/middleware/notificationHandler.js packages/server/src/middleware/notificationHandler.js
packages/server/src/middleware/notificationHandler.js.map packages/server/src/middleware/notificationHandler.js.map
packages/server/src/middleware/requestProcessor.d.ts packages/server/src/middleware/ownerHandler.d.ts
packages/server/src/middleware/requestProcessor.js packages/server/src/middleware/ownerHandler.js
packages/server/src/middleware/requestProcessor.js.map packages/server/src/middleware/ownerHandler.js.map
packages/server/src/middleware/routeHandler.d.ts
packages/server/src/middleware/routeHandler.js
packages/server/src/middleware/routeHandler.js.map
packages/server/src/migrations/20190913171451_create.d.ts packages/server/src/migrations/20190913171451_create.d.ts
packages/server/src/migrations/20190913171451_create.js packages/server/src/migrations/20190913171451_create.js
packages/server/src/migrations/20190913171451_create.js.map packages/server/src/migrations/20190913171451_create.js.map

View File

@ -19,7 +19,7 @@ const taboverride = require('taboverride');
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
const BaseItem = require('@joplin/lib/models/BaseItem'); const BaseItem = require('@joplin/lib/models/BaseItem');
const { themeStyle } = require('@joplin/lib/theme'); const { themeStyle } = require('@joplin/lib/theme');
// const { clipboard } = require('electron'); const { clipboard } = require('electron');
const supportedLocales = require('./supportedLocales'); const supportedLocales = require('./supportedLocales');
function markupRenderOptions(override: any = null) { function markupRenderOptions(override: any = null) {
@ -1015,19 +1015,22 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
} }
} }
function onKeyDown(_event: any) { function onKeyDown(event: any) {
// It seems "paste as text" is now handled automatically by // It seems "paste as text" is handled automatically by
// either Chrome, Electron and/or TinyMCE so the code below // on Windows so the code below so we need to run the below
// should not longer be necessary. Also fixes // code only on macOS (and maybe Linux). If we were to run
// this on Windows we would have this double-paste issue:
// https://github.com/laurent22/joplin/issues/4243 // https://github.com/laurent22/joplin/issues/4243
// Handle "paste as text". Note that when pressing CtrlOrCmd+Shift+V it's going // Handle "paste as text". Note that when pressing CtrlOrCmd+Shift+V it's going
// to trigger the "keydown" event but not the "paste" event, so it's ok to process // to trigger the "keydown" event but not the "paste" event, so it's ok to process
// it here and we don't need to do anything special in onPaste // it here and we don't need to do anything special in onPaste
// if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.code === 'KeyV') { if (!shim.isWindows()) {
// const pastedText = clipboard.readText(); if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.code === 'KeyV') {
// if (pastedText) editor.insertContent(pastedText); const pastedText = clipboard.readText();
// } if (pastedText) editor.insertContent(pastedText);
}
}
} }
editor.on('keyup', onKeyUp); editor.on('keyup', onKeyUp);