Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(chrome-ext): work within Gutenberg `<iframe />`s (#3702)
Elijah Potter41033543e938
diff --git a/packages/chrome-plugin/src/contentScript/index.ts b/packages/chrome-plugin/src/contentScript/index.tsindex 95c625ec3..ef66ba665 100644--- a/packages/chrome-plugin/src/contentScript/index.ts+++ b/packages/chrome-plugin/src/contentScript/index.ts@@ -113,27 +113,29 @@ function scan() {fw.addTarget(element);});- document.querySelectorAll('[data-testid="gutenberg-editor"]').forEach((element) => {- const leafs = leafNodes(element);+ document+ .querySelectorAll('[data-testid="gutenberg-editor"], .block-editor-iframe__body')+ .forEach((element) => {+ const leafs = leafNodes(element);- const seenBlockContainers = new Set<Element>();+ const seenBlockContainers = new Set<Element>();- for (const leaf of leafs) {- const blockContainer = getClosestBlockAncestor(leaf, element);+ for (const leaf of leafs) {+ const blockContainer = getClosestBlockAncestor(leaf, element);- if (!blockContainer || seenBlockContainers.has(blockContainer)) {- continue;- }+ if (!blockContainer || seenBlockContainers.has(blockContainer)) {+ continue;+ }- seenBlockContainers.add(blockContainer);+ seenBlockContainers.add(blockContainer);- if (!isVisible(blockContainer)) {- continue;- }+ if (!isVisible(blockContainer)) {+ continue;+ }- fw.addTarget(blockContainer);- }- });+ fw.addTarget(blockContainer);+ }+ });document.querySelectorAll<HTMLElement>('.cm-editor .cm-content[contenteditable="true"]')diff --git a/packages/chrome-plugin/src/manifest.ts b/packages/chrome-plugin/src/manifest.tsindex d7eb16785..c754c57a3 100644--- a/packages/chrome-plugin/src/manifest.ts+++ b/packages/chrome-plugin/src/manifest.ts@@ -70,6 +70,7 @@ export default defineManifest({matches: ['<all_urls>'],all_frames: true,match_about_blank: true,+ match_origin_as_fallback: true,js: ['src/contentScript/index.ts'],run_at: 'document_idle',},