From 5e26401a24235f9a7b13cf02ff0a8e59219b0bfd Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 20 Jul 2023 20:28:22 -0400 Subject: [PATCH] (core) Re-render assistant code blocks on theme change Summary: When the browser theme transitioned while the assistant was open, messages containing code blocks were not being re-rendered with the new theme. Test Plan: Manual. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3965 --- app/client/widgets/FormulaAssistant.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/client/widgets/FormulaAssistant.ts b/app/client/widgets/FormulaAssistant.ts index 6b77b50c..bddb53e9 100644 --- a/app/client/widgets/FormulaAssistant.ts +++ b/app/client/widgets/FormulaAssistant.ts @@ -23,7 +23,7 @@ import {loadingDots} from 'app/client/ui2018/loaders'; import {menu, menuCssClass, menuItem} from 'app/client/ui2018/menus'; import {TelemetryEvent, TelemetryMetadata} from 'app/common/Telemetry'; import {Computed, Disposable, dom, DomElementArg, makeTestId, - MutableObsArray, obsArray, Observable, styled} from 'grainjs'; + MutableObsArray, obsArray, Observable, styled, subscribeElem} from 'grainjs'; import debounce from 'lodash/debounce'; import noop from 'lodash/noop'; import {marked} from 'marked'; @@ -931,7 +931,7 @@ class ChatHistory extends Disposable { const doc = this._options.gristDoc; if (this.supportsMarkdown()) { return dom('div', - (el) => { + (el) => subscribeElem(el, doc.currentTheme, () => { const content = sanitizeHTML(marked(message, { highlight: (code) => { const codeBlock = buildHighlightedCode(code, { @@ -942,10 +942,9 @@ class ChatHistory extends Disposable { }, })); el.innerHTML = content; - }, + }), ...args ); - } else { return buildHighlightedCode(message, { gristTheme: doc.currentTheme,