diff options
author | Azul <azul@riseup.net> | 2021-10-25 13:59:52 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-01-24 14:29:09 +0300 |
commit | 4221a8243aa5a64abe8782dff838a0d4c4bafdad (patch) | |
tree | 5ce62f2f18b40e7689924c6854f9a6bd168a14e2 /src/marks | |
parent | 02bb65ad2b22c9bf2905940a46690662f79a1b5a (diff) |
Support underline - use `____` in markdown
Fixes: #75.
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'src/marks')
-rw-r--r-- | src/marks/index.js | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/marks/index.js b/src/marks/index.js index 0275bae57..88c9ad995 100644 --- a/src/marks/index.js +++ b/src/marks/index.js @@ -20,7 +20,13 @@ * */ -import { Bold, Italic as TipTapItalic, Strike as TipTapStrike, Link as TipTapLink } from 'tiptap-extensions' +import { + Bold, + Italic as TipTapItalic, + Strike as TipTapStrike, + Link as TipTapLink, + Underline as TipTapUnderline, +} from 'tiptap-extensions' import { Plugin } from 'tiptap' import { getMarkAttrs } from 'tiptap-utils' import { markInputRule, markPasteRule } from 'tiptap-commands' @@ -201,11 +207,36 @@ class Link extends TipTapLink { } -/** Strike is currently unsupported by prosemirror-markdown */ +class Underline extends TipTapUnderline { + + get schema() { + return { + parseDOM: [ + { + tag: 'u', + }, + { + style: 'text-decoration', + getAttrs: value => value === 'underline', + }, + ], + toDOM: () => ['u', 0], + toMarkdown: { + open: '____', + close: '____', + mixable: true, + expelEnclosingWhitespace: true, + }, + } + } +} + +/** Strike is currently unsupported by prosemirror-markdown */ export { Strong, Italic, Strike, Link, + Underline, } |