Fixes #421
parent
0c006bb84c
commit
75aa3171ff
|
@ -5,6 +5,7 @@ interface WrapElement {
|
||||||
selector: string;
|
selector: string;
|
||||||
class: string;
|
class: string;
|
||||||
nesting?: boolean;
|
nesting?: boolean;
|
||||||
|
disableSpellCheck?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function lineWrapper(wrapElements: WrapElement[]) {
|
export function lineWrapper(wrapElements: WrapElement[]) {
|
||||||
|
@ -15,6 +16,10 @@ export function lineWrapper(wrapElements: WrapElement[]) {
|
||||||
syntaxTree(state).iterate({
|
syntaxTree(state).iterate({
|
||||||
enter: ({ type, from, to }) => {
|
enter: ({ type, from, to }) => {
|
||||||
for (const wrapElement of wrapElements) {
|
for (const wrapElement of wrapElements) {
|
||||||
|
const spellCheckAttributes = wrapElement.disableSpellCheck
|
||||||
|
? { attributes: { spellcheck: "false" } }
|
||||||
|
: {};
|
||||||
|
|
||||||
if (type.name == wrapElement.selector) {
|
if (type.name == wrapElement.selector) {
|
||||||
if (wrapElement.nesting) {
|
if (wrapElement.nesting) {
|
||||||
elementStack.push(type.name);
|
elementStack.push(type.name);
|
||||||
|
@ -29,6 +34,7 @@ export function lineWrapper(wrapElements: WrapElement[]) {
|
||||||
widgets.push(
|
widgets.push(
|
||||||
Decoration.line({
|
Decoration.line({
|
||||||
class: cls,
|
class: cls,
|
||||||
|
...spellCheckAttributes,
|
||||||
}).range(doc.lineAt(idx).from),
|
}).range(doc.lineAt(idx).from),
|
||||||
);
|
);
|
||||||
idx += line.length + 1;
|
idx += line.length + 1;
|
||||||
|
|
|
@ -916,7 +916,11 @@ export class Editor {
|
||||||
{ selector: "Blockquote", class: "sb-line-blockquote" },
|
{ selector: "Blockquote", class: "sb-line-blockquote" },
|
||||||
{ selector: "Task", class: "sb-line-task" },
|
{ selector: "Task", class: "sb-line-task" },
|
||||||
{ selector: "CodeBlock", class: "sb-line-code" },
|
{ selector: "CodeBlock", class: "sb-line-code" },
|
||||||
{ selector: "FencedCode", class: "sb-line-fenced-code" },
|
{
|
||||||
|
selector: "FencedCode",
|
||||||
|
class: "sb-line-fenced-code",
|
||||||
|
disableSpellCheck: true,
|
||||||
|
},
|
||||||
{ selector: "Comment", class: "sb-line-comment" },
|
{ selector: "Comment", class: "sb-line-comment" },
|
||||||
{ selector: "BulletList", class: "sb-line-ul" },
|
{ selector: "BulletList", class: "sb-line-ul" },
|
||||||
{ selector: "OrderedList", class: "sb-line-ol" },
|
{ selector: "OrderedList", class: "sb-line-ol" },
|
||||||
|
|
Loading…
Reference in New Issue