(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
pull/590/head
George Gevoian 11 months ago
parent 391c8ee087
commit 5e26401a24

@ -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,

Loading…
Cancel
Save