Skip to content

Commit

Permalink
Add key bindings for uppercase letters for bold, italic underline
Browse files Browse the repository at this point in the history
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:
ueberdosis/tiptap#2426
ueberdosis/tiptap#2478

Fixes: #2050

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Feb 3, 2022
1 parent 8379e96 commit 238db0d
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 17 deletions.
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.

34 changes: 32 additions & 2 deletions src/marks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -44,6 +44,14 @@ class Strong extends Bold {
return 'strong'
}

// 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 [
Expand All @@ -66,6 +74,14 @@ class Italic extends TipTapItalic {
return 'em'
}

// 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 [
Expand Down Expand Up @@ -113,6 +129,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 [
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 238db0d

Please sign in to comment.