From 811a41366bbf8201105c12ef92f8c8abb907f028 Mon Sep 17 00:00:00 2001 From: Valerii Varankin Date: Sat, 26 Nov 2022 00:24:17 +0300 Subject: [PATCH] Fix: check for Files substitutions before handling files paste (#1928) * FIX: Paste text from MS Word instead of image * changelog added * Update CHANGELOG.md * rm submodule change Co-authored-by: Peter Savchenko --- docs/CHANGELOG.md | 1 + src/components/modules/paste.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ae636e35..035791ae 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,7 @@ - `Fix` — Wrong element not highlighted anymore when popover opened. - `Fix` — When Tunes Menu open keydown events can not be handled inside plugins. - `Fix` — If a Tool specifies some tags to substitute on paste, all attributes of that tags will be removed before passing them to the tool. Possible XSS vulnerability fixed. +- `Fix` — Pasting from Microsoft Word to Chrome (Mac OS) fixed. Now if there is no image-tools connected, regular text content will be pasted. - `Fix` — Workaround for the HTMLJanitor bug with Tables (https://github.com/guardian/html-janitor/issues/3) added - `Improvement` — *Tools API* — `pasteConfig().tags` now support sanitizing configuration. It allows you to leave some explicitly specified attributes for pasted content. - `Improvement` — *CodeStyle* — [CodeX ESLint Config](https://github.com/codex-team/eslint-config) has bee updated. All ESLint/Spelling issues resolved diff --git a/src/components/modules/paste.ts b/src/components/modules/paste.ts index 3f313a67..bc568169 100644 --- a/src/components/modules/paste.ts +++ b/src/components/modules/paste.ts @@ -174,7 +174,7 @@ export default class Paste extends Module { // eslint-disable-next-line @typescript-eslint/no-explicit-any const includesFiles = types.includes ? types.includes('Files') : (types as any).contains('Files'); - if (includesFiles) { + if (includesFiles && !_.isEmpty(this.toolsFiles)) { await this.processFiles(dataTransfer.files); return;