From bf975b47824a678aaf026ee39e268723ab2151b1 Mon Sep 17 00:00:00 2001 From: Todd Riley Date: Tue, 16 Sep 2025 15:21:34 -0400 Subject: [PATCH 1/4] Set line-height to match github. Also extract shared options to a single object. --- browser-extension/src/lib/enhancers/github/ghOptions.ts | 7 +++++++ .../src/lib/enhancers/github/githubIssueAddComment.ts | 4 ++-- .../src/lib/enhancers/github/githubIssueNewComment.ts | 4 ++-- .../src/lib/enhancers/github/githubPRAddComment.ts | 3 ++- .../src/lib/enhancers/github/githubPRNewComment.ts | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 browser-extension/src/lib/enhancers/github/ghOptions.ts diff --git a/browser-extension/src/lib/enhancers/github/ghOptions.ts b/browser-extension/src/lib/enhancers/github/ghOptions.ts new file mode 100644 index 0000000..321389b --- /dev/null +++ b/browser-extension/src/lib/enhancers/github/ghOptions.ts @@ -0,0 +1,7 @@ +import type { Options } from 'overtype' + +export const commonGithubOptions: Options = { + autoResize: true, + lineHeight: 'var(--text-body-lineHeight-medium, 1.4285)', + padding: 'var(--base-size-16)', +} diff --git a/browser-extension/src/lib/enhancers/github/githubIssueAddComment.ts b/browser-extension/src/lib/enhancers/github/githubIssueAddComment.ts index bfdc02f..b279429 100644 --- a/browser-extension/src/lib/enhancers/github/githubIssueAddComment.ts +++ b/browser-extension/src/lib/enhancers/github/githubIssueAddComment.ts @@ -2,6 +2,7 @@ import OverType, { type OverTypeInstance } from 'overtype' import type { CommentEnhancer, CommentSpot } from '../../enhancer' import { logger } from '../../logger' import { modifyDOM } from '../modifyDOM' +import { commonGithubOptions } from './ghOptions' import { githubHighlighter } from './githubHighlighter' interface GitHubIssueAddCommentSpot extends CommentSpot { @@ -47,9 +48,8 @@ export class GitHubIssueAddCommentEnhancer implements CommentEnhancer Date: Tue, 16 Sep 2025 16:33:10 -0400 Subject: [PATCH 2/4] Handle textareas being initialized after initial page load. --- browser-extension/src/lib/registries.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/browser-extension/src/lib/registries.ts b/browser-extension/src/lib/registries.ts index d6cf1aa..cce6ce9 100644 --- a/browser-extension/src/lib/registries.ts +++ b/browser-extension/src/lib/registries.ts @@ -69,6 +69,7 @@ export class EnhancerRegistry { this.preparedEnhancers.add(enhancer) } const overtype = enhancer.enhance(textarea, spot) + this.handleDelayedValueInjection(overtype) return { enhancer, overtype, spot, textarea } } } catch (error) { @@ -78,6 +79,24 @@ export class EnhancerRegistry { return null } + private handleDelayedValueInjection(overtype: OverTypeInstance): void { + // GitHub sometimes injects textarea content after a delay + // We need to trigger OverType to update its preview after such injections + // https://github.com/diffplug/gitcasso/issues/46 + setTimeout(() => { + overtype.updatePreview() + }, 100) + setTimeout(() => { + overtype.updatePreview() + }, 200) + setTimeout(() => { + overtype.updatePreview() + }, 400) + setTimeout(() => { + overtype.updatePreview() + }, 8000) + } + getEnhancerCount(): number { return this.enhancers.size } From 4dc0403e8cb214cf89e8432261ac1d12c2c77a82 Mon Sep 17 00:00:00 2001 From: Todd Riley Date: Tue, 16 Sep 2025 16:49:33 -0400 Subject: [PATCH 3/4] Add updatePreview to mock. --- browser-extension/tests/har-fixture.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/browser-extension/tests/har-fixture.ts b/browser-extension/tests/har-fixture.ts index 60e7e90..befcdf9 100644 --- a/browser-extension/tests/har-fixture.ts +++ b/browser-extension/tests/har-fixture.ts @@ -18,6 +18,7 @@ vi.mock('overtype', () => { preview: document.createElement('div'), setValue: vi.fn(), textarea: document.createElement('textarea'), + updatePreview: vi.fn(), wrapper: document.createElement('div'), }, ]) From 9cef603975f00275cc62258185d1339b999bd5a2 Mon Sep 17 00:00:00 2001 From: Todd Riley Date: Tue, 16 Sep 2025 16:36:33 -0400 Subject: [PATCH 4/4] Remove style that makes some textareas too big on github. --- packages/overtype | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/overtype b/packages/overtype index 80caa5d..35cb823 160000 --- a/packages/overtype +++ b/packages/overtype @@ -1 +1 @@ -Subproject commit 80caa5d1a0139171e3e250c9c9e25bd63a67d331 +Subproject commit 35cb82382c6f2d4352e4608f3e437ff5c3bcd032