mirror of
https://github.com/memodack/memodack.git
synced 2026-07-22 11:50:25 +00:00
fix: translation after active file change
This commit is contained in:
parent
f7f276059e
commit
f22019c633
3 changed files with 8 additions and 7 deletions
|
|
@ -59,7 +59,6 @@ export class Register implements IRegister {
|
|||
registerServices(): void {
|
||||
const services: Array<[string, any]> = [
|
||||
["ISettingsService", SettingsService],
|
||||
["IEditorService", EditorService],
|
||||
["IManifestService", ManifestService],
|
||||
["IVaultService", VaultService],
|
||||
["IWorkspaceService", WorkspaceService],
|
||||
|
|
@ -68,7 +67,6 @@ export class Register implements IRegister {
|
|||
["IConductorService", ConductorService],
|
||||
["IMppService", MppService],
|
||||
["ITranslationService", TranslationService],
|
||||
["ITranslateCommandService", TranslateCommandService],
|
||||
["IPartsService", PartsService],
|
||||
["IPlayerService", PlayerService],
|
||||
["IAudioService", AudioService],
|
||||
|
|
@ -91,6 +89,9 @@ export class Register implements IRegister {
|
|||
services.forEach(([token, value]) => {
|
||||
container.registerSingleton(token, value);
|
||||
});
|
||||
|
||||
container.register("ITranslateCommandService", TranslateCommandService);
|
||||
container.register("IEditorService", EditorService);
|
||||
}
|
||||
|
||||
registerEditor(editor: Editor): void {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import type { Editor } from "obsidian";
|
||||
import { inject, singleton } from "tsyringe";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
export interface IEditorService {
|
||||
getSelection(): string;
|
||||
replaceSelection(replacement: string, origin?: string): void;
|
||||
}
|
||||
|
||||
@singleton()
|
||||
@injectable()
|
||||
export class EditorService implements IEditorService {
|
||||
constructor(@inject("Editor") private readonly editor: Editor) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { inject, singleton } from "tsyringe";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
import type { ITranslationService } from "../types";
|
||||
import type { IConductorService } from "./conductor.service";
|
||||
import type { IEditorService } from "./editor.service";
|
||||
import type { ISettingsService } from "./settings.service";
|
||||
import type { ITranslationService } from "./translation.service";
|
||||
|
||||
export interface ITranslateCommandService {
|
||||
getCallback: () => Promise<void>;
|
||||
}
|
||||
|
||||
@singleton()
|
||||
@injectable()
|
||||
export class TranslateCommandService implements ITranslateCommandService {
|
||||
constructor(
|
||||
@inject("IEditorService") private readonly editorService: IEditorService,
|
||||
|
|
|
|||
Loading…
Reference in a new issue