Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(chrome-ext): properly support Zendesk (#2424)

Elijah Potter1dcc4ae03d16
diff --git a/packages/chrome-plugin/src/background/index.ts b/packages/chrome-plugin/src/background/index.ts
index 8e8f76a2b..df10e5f76 100644
--- a/packages/chrome-plugin/src/background/index.ts
+++ b/packages/chrome-plugin/src/background/index.ts
@@ -104,6 +104,7 @@ async function enableDefaultDomains() {
'classroom.google.com',
'quilljs.com',
'www.wattpad.com',
+ 'ckeditor.com',
];
for (const item of defaultEnabledDomains) {
diff --git a/packages/chrome-plugin/src/contentScript/index.ts b/packages/chrome-plugin/src/contentScript/index.ts
index baf0b4e99..60edc959c 100644
--- a/packages/chrome-plugin/src/contentScript/index.ts
+++ b/packages/chrome-plugin/src/contentScript/index.ts
@@ -106,6 +106,22 @@ function scan() {
return;
}
+ if (element.classList.contains('ck-editor__editable')) {
+ element.querySelectorAll('p').forEach((paragraph) => {
+ if (paragraph.closest('[contenteditable="false"],[disabled],[readonly]') != null) {
+ return;
+ }
+
+ if (!isVisible(paragraph)) {
+ return;
+ }
+
+ fw.addTarget(paragraph);
+ });
+
+ return;
+ }
+
const leafs = leafNodes(element);
const seenBlockContainers = new Set<Element>();
diff --git a/packages/lint-framework/src/lint/computeLintBoxes.ts b/packages/lint-framework/src/lint/computeLintBoxes.ts
index 2698f057e..4ea907dd2 100644
--- a/packages/lint-framework/src/lint/computeLintBoxes.ts
+++ b/packages/lint-framework/src/lint/computeLintBoxes.ts
@@ -1,7 +1,7 @@
import type { Span } from 'harper.js';
import { domRectToBox, type IgnorableLintBox, isBottomEdgeInBox, shrinkBoxToFit } from './Box';
import { getRangeForTextSpan } from './domUtils';
-import { getLexicalRoot, getSlateRoot } from './editorUtils';
+import { getCkEditorRoot, getLexicalRoot, getSlateRoot } from './editorUtils';
import TextFieldRange from './TextFieldRange';
import { applySuggestion, type UnpackedLint, type UnpackedSuggestion } from './unpackLint';
@@ -93,6 +93,8 @@ function replaceValue(el: HTMLElement, value: string) {
replaceRichTextValue(el, value, { mode: 'lexical' });
} else if (getSlateRoot(el) != null) {
replaceRichTextValue(el, value, { mode: 'slate' });
+ } else if (getCkEditorRoot(el) != null) {
+ replaceRichTextValue(el, value, { mode: 'slate' });
} else {
replaceGenericContentEditable(el, value);
}
diff --git a/packages/lint-framework/src/lint/editorUtils.ts b/packages/lint-framework/src/lint/editorUtils.ts
index 03118e0eb..52b2502e2 100644
--- a/packages/lint-framework/src/lint/editorUtils.ts
+++ b/packages/lint-framework/src/lint/editorUtils.ts
@@ -62,6 +62,13 @@ export function getLexicalRoot(el: SourceElement): SourceElement | null {
);
}
+export function getCkEditorRoot(el: SourceElement): SourceElement | null {
+ return findAncestor(
+ el,
+ (node: SourceElement) => !isTextNode(node) && node.classList.contains('ck-editor__editable'),
+ );
+}
+
export function getLexicalEditable(el: SourceElement): SourceElement | null {
return findAncestor(
el,