Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas <jonas@freesources.org>2022-02-03 15:18:18 +0300
committerJonas <jonas@freesources.org>2022-02-03 16:40:14 +0300
commitbb74b1bdd0232483de8d58ca822dc661c8619bc9 (patch)
tree8c2ce54bc5bcb27427335fbdaa15d37ad7489af2 /src/marks/index.js
parentc8a18545755ff5a4d1459333f3a9b8fad368659e (diff)
Add key bindings for uppercase letters for bold, italic underline
This way, key bindings 'Mod-B', 'Mod-I' and 'Mod-U' with active caps lock have the same effect as their lowercase siblings. This is supposed to be fixed in Tiptap v2 upstream: https://github.com/ueberdosis/tiptap/issues/2426 https://github.com/ueberdosis/tiptap/pull/2478 Fixes: #2050 Signed-off-by: Jonas <jonas@freesources.org>
Diffstat (limited to 'src/marks/index.js')
-rw-r--r--src/marks/index.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/marks/index.js b/src/marks/index.js
index 2c536b12c..9f8de6f7d 100644
--- a/src/marks/index.js
+++ b/src/marks/index.js
@@ -29,7 +29,7 @@ import {
} from 'tiptap-extensions'
import { Plugin } from 'tiptap'
import { getMarkAttrs } from 'tiptap-utils'
-import { markInputRule, markPasteRule } from 'tiptap-commands'
+import { markInputRule, markPasteRule, toggleMark } from 'tiptap-commands'
import { domHref, parseHref } from './../helpers/links'
import markdownit from './../markdownit'
@@ -45,6 +45,14 @@ class Strong extends Bold {
}
// TODO: remove once we upgraded to tiptap v2
+ keys({ type }) {
+ return {
+ 'Mod-b': toggleMark(type),
+ 'Mod-B': toggleMark(type),
+ }
+ }
+
+ // TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/, type),
@@ -67,6 +75,14 @@ class Italic extends TipTapItalic {
}
// TODO: remove once we upgraded to tiptap v2
+ keys({ type }) {
+ return {
+ 'Mod-i': toggleMark(type),
+ 'Mod-I': toggleMark(type),
+ }
+ }
+
+ // TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/, type),
@@ -114,6 +130,14 @@ class Strike extends TipTapStrike {
}
// TODO: remove once we upgraded to tiptap v2
+ keys({ type }) {
+ return {
+ 'Mod-d': toggleMark(type),
+ 'Mod-D': toggleMark(type),
+ }
+ }
+
+ // TODO: remove once we upgraded to tiptap v2
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/, type),
@@ -229,13 +253,19 @@ class Underline extends TipTapUnderline {
}
// TODO: remove once we upgraded to tiptap v2
+ keys({ type }) {
+ return {
+ 'Mod-u': toggleMark(type),
+ 'Mod-U': toggleMark(type),
+ }
+ }
+
inputRules({ type }) {
return [
markInputRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))$/, type),
]
}
- // TODO: remove once we upgraded to tiptap v2
pasteRules({ type }) {
return [
markPasteRule(/(?:^|\s)((?:__)((?:[^__]+))(?:__))/g, type),