Skip to content

Commit

Permalink
Update preview
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed May 23, 2022
1 parent f30b871 commit c0df582
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/options/extern/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 };
6 changes: 4 additions & 2 deletions src/options/logic/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -43,7 +45,7 @@ export class Preview {
}

async updateText(previewText: string, lookupWithCapitalized: boolean): Promise<void> {
const { entries, lang } = entry.build(previewText, lookupWithCapitalized, false);
const { entries, lang } = this.buildEntries(previewText, lookupWithCapitalized, false);

console.time("update");

Expand Down

0 comments on commit c0df582

Please sign in to comment.