Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(chrome-ext): properly place highlights relative to Draft.js root (#1535)
Elijah Potter710a1ff6cf38
diff --git a/packages/chrome-plugin/src/Highlights.ts b/packages/chrome-plugin/src/Highlights.tsindex f3a0ac13c..bad06d4ec 100644--- a/packages/chrome-plugin/src/Highlights.ts+++ b/packages/chrome-plugin/src/Highlights.ts@@ -4,6 +4,7 @@ import { type LintBox, isBoxInScreen } from './Box';import RenderBox from './RenderBox';import {getCMRoot,+ getDraftRoot,getGutenbergRoot,getLexicalRoot,getMediumRoot,@@ -130,6 +131,7 @@ export default class Highlights {}const queries = [+ getDraftRoot,getPMRoot,getCMRoot,getNotionRoot,diff --git a/packages/chrome-plugin/src/background/index.ts b/packages/chrome-plugin/src/background/index.tsindex bd9d6bad9..5323eb234 100644--- a/packages/chrome-plugin/src/background/index.ts+++ b/packages/chrome-plugin/src/background/index.ts@@ -78,6 +78,7 @@ async function enableDefaultDomains() {'localhost','writewithharper.com','prosemirror.net',+ 'draftjs.org',];for (const item of defaultEnabledDomains) {diff --git a/packages/chrome-plugin/src/editorUtils.ts b/packages/chrome-plugin/src/editorUtils.tsindex e249073b8..ed4b71d8c 100644--- a/packages/chrome-plugin/src/editorUtils.ts+++ b/packages/chrome-plugin/src/editorUtils.ts@@ -44,6 +44,12 @@ export function getSlateRoot(el: HTMLElement): HTMLElement | null {return findAncestor(el, (node: HTMLElement) => node.getAttribute('data-slate-editor') == 'true');}+/** Determines if a given node is a child of a Draft.js editor instance.+ * If so, returns the root node of that instance. */+export function getDraftRoot(el: HTMLElement): HTMLElement | null {+ return findAncestor(el, (node: HTMLElement) => node.classList.contains('DraftEditor-root'));+}+/** Determines if a given node is a child of a Trix editor instance.* If so, returns the root node of that instance. */export function getTrixRoot(el: HTMLElement): HTMLElement | null {