From 52e03610876b4a580951315ab2c5dc477dad0c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 5 Aug 2019 17:26:50 +0200 Subject: [PATCH] Fixing pasteRules for Embeds Apparently the default pasteRules of tiptap interfere with the pasteRules of a Link (in our case an Embed node). Consider this example: https://de.wikipedia.org/wiki/Yin_und_Yang Depending on some random conditions, tiptap might parse the `_und_` to be italic because it's wrapped with underscores (markdown syntax). The result is: https://de.wikipedia.org/wiki/Yin # link _und_ # italic Yang # plain text So let's remove the default pasteRules of `Bold`, `Strike` and `Italic` marks respectively to prefer our Embeds. Who is copy+pasting from one tiptap editor to another tiptap editor anyways? --- webapp/components/Editor/defaultExtensions.js | 6 +++--- webapp/components/Editor/marks/Bold.js | 7 +++++++ webapp/components/Editor/marks/Italic.js | 7 +++++++ webapp/components/Editor/marks/Strike.js | 7 +++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 webapp/components/Editor/marks/Bold.js create mode 100644 webapp/components/Editor/marks/Italic.js create mode 100644 webapp/components/Editor/marks/Strike.js diff --git a/webapp/components/Editor/defaultExtensions.js b/webapp/components/Editor/defaultExtensions.js index fea3e74f8..4b0eff1f9 100644 --- a/webapp/components/Editor/defaultExtensions.js +++ b/webapp/components/Editor/defaultExtensions.js @@ -1,5 +1,8 @@ import Embed from '~/components/Editor/nodes/Embed.js' import Link from '~/components/Editor/nodes/Link.js' +import Strike from '~/components/Editor/marks/Strike' +import Italic from '~/components/Editor/marks/Italic' +import Bold from '~/components/Editor/marks/Bold' import EmbedQuery from '~/graphql/EmbedQuery.js' import { Heading, @@ -10,9 +13,6 @@ import { OrderedList, HorizontalRule, Placeholder, - Bold, - Italic, - Strike, Underline, } from 'tiptap-extensions' diff --git a/webapp/components/Editor/marks/Bold.js b/webapp/components/Editor/marks/Bold.js new file mode 100644 index 000000000..f803ff9cc --- /dev/null +++ b/webapp/components/Editor/marks/Bold.js @@ -0,0 +1,7 @@ +import { Bold as TipTapBold } from 'tiptap-extensions' + +export default class Bold extends TipTapBold { + pasteRules() { + return [] + } +} diff --git a/webapp/components/Editor/marks/Italic.js b/webapp/components/Editor/marks/Italic.js new file mode 100644 index 000000000..07493bd39 --- /dev/null +++ b/webapp/components/Editor/marks/Italic.js @@ -0,0 +1,7 @@ +import { Italic as TipTapItalic } from 'tiptap-extensions' + +export default class Italic extends TipTapItalic { + pasteRules() { + return [] + } +} diff --git a/webapp/components/Editor/marks/Strike.js b/webapp/components/Editor/marks/Strike.js new file mode 100644 index 000000000..260ce6a0a --- /dev/null +++ b/webapp/components/Editor/marks/Strike.js @@ -0,0 +1,7 @@ +import { Strike as TipTapStrike } from 'tiptap-extensions' + +export default class Strike extends TipTapStrike { + pasteRules() { + return [] + } +}