Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(web): will now work on Hacker News (#2053)
Elijah Potter7080ee71f036
diff --git a/packages/chrome-plugin/src/background/index.ts b/packages/chrome-plugin/src/background/index.tsindex 8ab3770ad..6ff2b7cba 100644--- a/packages/chrome-plugin/src/background/index.ts+++ b/packages/chrome-plugin/src/background/index.ts@@ -91,6 +91,7 @@ async function enableDefaultDomains() {'write.ellipsus.com','www.facebook.com','www.upwork.com',+ 'news.ycombinator.com',];for (const item of defaultEnabledDomains) {diff --git a/packages/chrome-plugin/tests/hn.spec.ts b/packages/chrome-plugin/tests/hn.spec.tsnew file mode 100644index 000000000..df45cc94b--- /dev/null+++ b/packages/chrome-plugin/tests/hn.spec.ts@@ -0,0 +1,50 @@+import { test } from './fixtures';+import {+ assertHarperHighlightBoxes,+ getTextarea,+ replaceEditorContent,+ testBasicSuggestionTextarea,+ testCanIgnoreTextareaSuggestion,+} from './testUtils';++const TEST_PAGE_URL = 'https://news.ycombinator.com/item?id=45453448';++testBasicSuggestionTextarea(TEST_PAGE_URL);+testCanIgnoreTextareaSuggestion(TEST_PAGE_URL);++test('Hacker News wraps correctly', async ({ page }) => {+ await page.goto(TEST_PAGE_URL);++ await page.waitForTimeout(2000);+ await page.reload();++ const editor = getTextarea(page);+ await replaceEditorContent(+ editor,+ 'This is a test of the Harper grammar checker, specifically if \nit is wrapped around a line weirdl y',+ );++ await page.waitForTimeout(6000);++ await assertHarperHighlightBoxes(page, [+ { x: 352.578125, y: 113, width: 63.984375, height: 19 },+ { x: 592.484375, y: 96, width: 24, height: 19 },+ ]);+});++test('Hacker News scrolls correctly', async ({ page }) => {+ await page.goto(TEST_PAGE_URL);++ await page.waitForTimeout(2000);+ await page.reload();++ const editor = getTextarea(page);+ await replaceEditorContent(+ editor,+ 'This is a test of the the Harper grammar checker, specifically if \n\n\n\n\n\n\n\n\n\n\n\n\nit scrolls beyo nd the height of the buffer.',+ );++ await page.waitForTimeout(6000);++ await assertHarperHighlightBoxes(page, [{ x: 216.625, y: 217, width: 56, height: 19 }]);+});diff --git a/packages/chrome-plugin/tests/testUtils.ts b/packages/chrome-plugin/tests/testUtils.tsindex 32128f084..2ff5c510c 100644--- a/packages/chrome-plugin/tests/testUtils.ts+++ b/packages/chrome-plugin/tests/testUtils.ts@@ -140,5 +140,5 @@ export function assertBoxesClose(a: Box, b: Box) {}function assertClose(actual: number, expected: number) {- expect(Math.abs(actual - expected)).toBeLessThanOrEqual(9);+ expect(Math.abs(actual - expected)).toBeLessThanOrEqual(15);}diff --git a/packages/lint-framework/src/lint/Highlights.ts b/packages/lint-framework/src/lint/Highlights.tsindex e5a7b576d..039e513af 100644--- a/packages/lint-framework/src/lint/Highlights.ts+++ b/packages/lint-framework/src/lint/Highlights.ts@@ -91,13 +91,8 @@ export default class Highlights {const value = sourceToBoxes.get(box.source);const icr = getInitialContainingRect(renderBox.getShadowHost());- const parent = renderBox.getShadowHost().offsetParent;let cpa = null;- if (parent != null && parent != document.body && parent.shadowRoot == null) {- cpa = parent.getBoundingClientRect();- }-if (cpa == null) {if (icr != null) {cpa = icr;@@ -131,6 +126,8 @@ export default class Highlights {hostStyle.pointerEvents = 'none';hostStyle.width = '0px';hostStyle.height = '0px';+ } else if (host.hasAttribute('style')) {+ host.removeAttribute('style');}renderBox.render(this.renderTree(boxes));