From b678bfcec90c33948b5dfedbbcc48dcd338226d0 Mon Sep 17 00:00:00 2001 From: Itallo Date: Mon, 17 Jun 2024 12:40:19 -0300 Subject: [PATCH] feat: public navigationManager to use in portal --- src/editor/index.ts | 4 ++++ src/editor/navigationFields.ts | 6 +++++- src/syncfusion/navigationFields/index.ts | 8 ++++++-- src/tinymce/index.ts | 3 +++ src/tinymce/navigationFields.ts | 3 +++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/editor/index.ts b/src/editor/index.ts index e85dc34..adc7812 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -101,6 +101,10 @@ export abstract class EditorAdapter { return this._navigationFieldManager.hasEmptyRequiredFields(); } + navigationManagerFields(): IaraEditorNavigationFieldManager { + return this._navigationFieldManager; + } + private _initCommands(): void { this._recognition.commands.add("iara copiar laudo", async () => { if (this.hasEmptyRequiredFields()) { diff --git a/src/editor/navigationFields.ts b/src/editor/navigationFields.ts index 19cfc82..20abcf1 100644 --- a/src/editor/navigationFields.ts +++ b/src/editor/navigationFields.ts @@ -5,7 +5,11 @@ export abstract class IaraEditorNavigationFieldManager { abstract previousField(): void; abstract goToField(title: string): void; abstract hasEmptyRequiredFields(): boolean; - + abstract insertField( + content?: string, + title?: string, + type?: "Field" | "Mandatory" | "Optional" + ): void; constructor(private _recognition: IaraSpeechRecognition) { this._recognition.addEventListener("iaraSpeechMikeForwardButtonPress", () => this.nextField() diff --git a/src/syncfusion/navigationFields/index.ts b/src/syncfusion/navigationFields/index.ts index a9a608d..a6f42d7 100644 --- a/src/syncfusion/navigationFields/index.ts +++ b/src/syncfusion/navigationFields/index.ts @@ -76,8 +76,12 @@ export class IaraSyncfusionNavigationFieldManager extends IaraEditorNavigationFi this._documentEditor.selection.clear(); this._documentEditor.selection.moveNextPosition(); this._documentEditor.editor.insertText(content); - if (type === "Mandatory") this._documentEditor.editor.insertText(`*`); - if (type === "Optional") this._documentEditor.editor.insertText(`?`); + if (type === "Mandatory") { + if (!content.includes("*")) this._documentEditor.editor.insertText(`*`); + } + if (type === "Optional") { + if (!content.includes("?")) this._documentEditor.editor.insertText(`?`); + } this.getBookmarks(); this.isFirstNextNavigation = true; this.isFirstPreviousNavigation = true; diff --git a/src/tinymce/index.ts b/src/tinymce/index.ts index e36a7e3..c9cf72f 100644 --- a/src/tinymce/index.ts +++ b/src/tinymce/index.ts @@ -100,4 +100,7 @@ export class IaraTinyMCEAdapter extends EditorAdapter implements EditorAdapter { hasEmptyRequiredFields(): boolean { throw new Error("Method not implemented."); } + insertField() { + throw new Error("Method not implemented."); + } } diff --git a/src/tinymce/navigationFields.ts b/src/tinymce/navigationFields.ts index d2c7a09..f8d0439 100644 --- a/src/tinymce/navigationFields.ts +++ b/src/tinymce/navigationFields.ts @@ -14,4 +14,7 @@ export class IaraTinyMceNavigationFieldManager extends IaraEditorNavigationField hasEmptyRequiredFields(): boolean { throw new Error("Method not implemented."); } + insertField(): void { + throw new Error("Method not implemented."); + } }