From c0df5820e9faf712e64b7dc862359dd832ad1c72 Mon Sep 17 00:00:00 2001 From: wtetsu Date: Mon, 23 May 2022 22:36:58 +0900 Subject: [PATCH] Update preview --- src/options/extern/index.ts | 3 ++- src/options/logic/preview.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/options/extern/index.ts b/src/options/extern/index.ts index f104455d..5ac6906e 100644 --- a/src/options/extern/index.ts +++ b/src/options/extern/index.ts @@ -8,6 +8,7 @@ // References to "main" functions import entry from "../../main/core/entry"; +import entryDefault from "../../main/core/entry/default"; import Generator from "../../main/core/generator"; import view from "../../main/core/view"; import dom from "../../main/lib/dom"; @@ -18,4 +19,4 @@ import * as env from "./env"; import * as storage from "./storage"; import * as defaultSettings from "./settings"; -export { entry, Generator, view, dom, template, defaultSettings, env, config, storage }; +export { entry, entryDefault, Generator, view, dom, template, defaultSettings, env, config, storage }; diff --git a/src/options/logic/preview.ts b/src/options/logic/preview.ts index 31af0882..4398fa92 100644 --- a/src/options/logic/preview.ts +++ b/src/options/logic/preview.ts @@ -6,7 +6,7 @@ import immer from "immer"; import { debounce } from "../logic"; -import { dom, Generator, view, entry, storage } from "../extern"; +import { dom, Generator, view, entryDefault, storage } from "../extern"; import { MouseDictionarySettings } from "../types"; type PreviewWindow = { dialog: HTMLElement; content: HTMLElement }; @@ -16,6 +16,7 @@ export class Preview { update: (settings: MouseDictionarySettings, text: string, refresh: boolean) => void; previewWindow: PreviewWindow; generator: Generator; + buildEntries: (text: string, withCapitalized: boolean, includeOrgText: boolean) => { entries: string[]; lang: string }; constructor(settings: MouseDictionarySettings) { this.update = debounce(this.updateBody.bind(this), 64); @@ -24,6 +25,7 @@ export class Preview { document.body.appendChild(this.element); this.refreshGenerator(settings); this.refreshElement(settings); + this.buildEntries = entryDefault(); } updateBody(settings: MouseDictionarySettings, text: string, refresh: boolean): void { @@ -43,7 +45,7 @@ export class Preview { } async updateText(previewText: string, lookupWithCapitalized: boolean): Promise { - const { entries, lang } = entry.build(previewText, lookupWithCapitalized, false); + const { entries, lang } = this.buildEntries(previewText, lookupWithCapitalized, false); console.time("update");