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?
This commit is contained in:
Robert Schäfer 2019-08-05 17:26:50 +02:00
parent 8093fece00
commit 52e0361087
4 changed files with 24 additions and 3 deletions

View File

@ -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'

View File

@ -0,0 +1,7 @@
import { Bold as TipTapBold } from 'tiptap-extensions'
export default class Bold extends TipTapBold {
pasteRules() {
return []
}
}

View File

@ -0,0 +1,7 @@
import { Italic as TipTapItalic } from 'tiptap-extensions'
export default class Italic extends TipTapItalic {
pasteRules() {
return []
}
}

View File

@ -0,0 +1,7 @@
import { Strike as TipTapStrike } from 'tiptap-extensions'
export default class Strike extends TipTapStrike {
pasteRules() {
return []
}
}