Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] Update mark input/paste rules to tiptap v2 regular expressions #1976

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions src/marks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { Bold, Italic as TipTapItalic, Strike as TipTapStrike, Link as TipTapLink } from 'tiptap-extensions'
import { Plugin } from 'tiptap'
import { getMarkAttrs } from 'tiptap-utils'
import { markInputRule, markPasteRule } from 'tiptap-commands'
import { domHref, parseHref } from './../helpers/links'
import { markdownit } from './../EditorFactory'

Expand All @@ -37,6 +38,22 @@ class Strong extends Bold {
return 'strong'
}

// TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/, type),
markInputRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/, type),
]
}

// TODO: remove once we upgraded to tiptap v2
pasteRules({ type }) {
return [
markPasteRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g, type),
markPasteRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g, type),
]
}

}

class Italic extends TipTapItalic {
Expand All @@ -45,6 +62,22 @@ class Italic extends TipTapItalic {
return 'em'
}

// TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/, type),
markInputRule(/(?:^|\s)((?:_)((?:[^_]+))(?:_))$/, type),
]
}

// TODO: remove once we upgraded to tiptap v2
pasteRules({ type }) {
return [
markPasteRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g, type),
markPasteRule(/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g, type),
]
}

}

class Strike extends TipTapStrike {
Expand Down Expand Up @@ -76,6 +109,20 @@ class Strike extends TipTapStrike {
}
}

// TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/, type),
]
}

// TODO: remove once we upgraded to tiptap v2
pasteRules({ type }) {
return [
markPasteRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/g, type),
]
}

}

class Link extends TipTapLink {
Expand Down