Skip to content

Commit 565a720

Browse files
committed
allow overriding formatting when holding shift
1 parent 2644272 commit 565a720

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

web_src/js/features/comp/ComboMarkdownEditor.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ class ComboMarkdownEditor {
8484
if (el.nodeName === 'BUTTON' && !el.getAttribute('type')) el.setAttribute('type', 'button');
8585
}
8686

87+
this.textarea.addEventListener('keydown', (e) => {
88+
if (e.shiftKey) {
89+
e.target._giteaShiftDown = true;
90+
}
91+
});
92+
this.textarea.addEventListener('keyup', (e) => {
93+
if (!e.shiftKey) {
94+
e.target._giteaShiftDown = false;
95+
}
96+
});
97+
8798
const monospaceButton = this.container.querySelector('.markdown-switch-monospace');
8899
const monospaceEnabled = localStorage?.getItem('markdown-editor-monospace') === 'true';
89100
const monospaceText = monospaceButton.getAttribute(monospaceEnabled ? 'data-disable-text' : 'data-enable-text');

web_src/js/features/comp/Paste.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function handleClipboardText(textarea, text, e) {
125125
const {value, selectionStart, selectionEnd} = textarea;
126126
const selectedText = value.substring(selectionStart, selectionEnd);
127127
const trimmedText = text.trim();
128-
if (selectedText && isUrl(trimmedText)) {
128+
if (selectedText && isUrl(trimmedText) && !textarea._giteaShiftDown) {
129129
e.stopPropagation();
130130
e.preventDefault();
131131
replaceTextareaSelection(textarea, `[${selectedText}](${trimmedText})`);

0 commit comments

Comments
 (0)