Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #901 from solita/feature/ae-1764-rte-tabnav
Browse files Browse the repository at this point in the history
AE-1764 Make Quill ignore the tab key
  • Loading branch information
muep authored Sep 26, 2022
2 parents 78bbb58 + 2abb560 commit ae47a9f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/components/text-editor/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ const dispatchEvent = (name, node, editor) =>
})
);

export const quill = (node, { html, toolbar }) => {
export const quill = (node, { html, toolbar, keyboard }) => {
const q = new Quill(node, {
modules: {
imageDrop: false,
magicUrl: true,
toolbar: toolbar
toolbar,
keyboard
},
placeholder: '',
theme: 'snow' // or 'bubble'
Expand Down
19 changes: 18 additions & 1 deletion src/components/text-editor/text-editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as R from 'ramda';
import { quill } from './quill';
import * as keys from '@Utility/keys';
import * as MD from './markdown';
import Turndown from 'turndown';
import Style from '@Component/text-editor/style.svelte';
Expand Down Expand Up @@ -36,6 +37,22 @@
['clean']
];
const keyboard = {
bindings: {
tab: {
key: keys.TAB,
handler: R.always(true)
},
'remove tab': {
key: keys.TAB,
shiftKey: true,
collapsed: true,
prefix: /\t$/,
handler: R.always(true)
}
}
};
const toMarkdown = R.bind(turndownService.turndown, turndownService);
</script>

Expand All @@ -61,7 +78,7 @@
on:focusin={api.focus}
on:editor-focus-out={event => api.blur(toMarkdown(event.detail.html))}
on:text-change={event => api.input(toMarkdown(event.detail.html))}
use:quill={{ html: MD.toHtml(viewValue), toolbar }} />
use:quill={{ html: MD.toHtml(viewValue), toolbar, keyboard }} />
{:else}
{@html MD.toHtml(viewValue)}
{/if}
Expand Down

0 comments on commit ae47a9f

Please sign in to comment.