@microsoft/dragon-copilot-sdk-lexical-react 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@hccm/web-tcl/CHANGELOG.md +161 -0
- package/node_modules/@hccm/web-tcl/README.md +99 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/cleanup-helper.d.ts +23 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/cleanup-helper.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/browser.d.ts +17 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/browser.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/coordinates.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/coordinates.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/dom.d.ts +44 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/dom.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/element-extensions.d.ts +26 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/element-extensions.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/error.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/error.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/local-store.d.ts +10 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/local-store.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/selection-info.d.ts +4 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/selection-info.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/string.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/string.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/util.d.ts +73 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/common/util.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/logger/logging.d.ts +67 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/logger/logging.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/main.d.ts +8 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/main.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/package-info.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/package-info.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/shared-data.d.ts +27 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/shared-data.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/speech-document.d.ts +91 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/speech-document.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/base-control.d.ts +100 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/base-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/contenteditable-control.d.ts +18 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/contenteditable-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/custom-control.d.ts +41 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/factory.d.ts +9 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/factory.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/helpers.d.ts +33 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/helpers.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/index.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/input-control.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/input-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/processing-status.d.ts +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/processing-status.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/text-control-manager.d.ts +38 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/text-control-manager.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/text-control.d.ts +64 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/text-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/textarea-control.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/textarea-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/tinymce-control.d.ts +11 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/text-control-lib/tinymce-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/channel.d.ts +15 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/channel.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/commands.d.ts +64 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/commands.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/custom-control.d.ts +212 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/index.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/input-custom-control.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/input-custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/textarea-custom-control.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/custom-controls/textarea-custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/diagnostics.d.ts +37 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/diagnostics.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/dom-observable.d.ts +13 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/dom-observable.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/events.d.ts +39 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/events.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/iframe-support.d.ts +29 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/iframe-support.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/index.d.ts +26 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/processing-status.d.ts +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/processing-status.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/state.d.ts +165 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/state.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/types.d.ts +21 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/types.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/utility-types.d.ts +3 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/utility-types.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/validation.d.ts +35 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/validation.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-attributes.d.ts +104 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-attributes.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-client.d.ts +16 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-client.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-controller.d.ts +8 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/webtcl-controller.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/worker.d.ts +18 -0
- package/node_modules/@hccm/web-tcl/dist/cjs/webtcl/worker.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/cleanup-helper.d.ts +23 -0
- package/node_modules/@hccm/web-tcl/dist/esm/cleanup-helper.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/browser.d.ts +17 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/browser.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/coordinates.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/coordinates.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/dom.d.ts +44 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/dom.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/element-extensions.d.ts +26 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/element-extensions.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/error.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/error.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/local-store.d.ts +10 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/local-store.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/selection-info.d.ts +4 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/selection-info.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/string.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/string.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/util.d.ts +73 -0
- package/node_modules/@hccm/web-tcl/dist/esm/common/util.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/logger/logging.d.ts +67 -0
- package/node_modules/@hccm/web-tcl/dist/esm/logger/logging.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/main.d.ts +8 -0
- package/node_modules/@hccm/web-tcl/dist/esm/main.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/package-info.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/esm/package-info.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/shared-data.d.ts +27 -0
- package/node_modules/@hccm/web-tcl/dist/esm/shared-data.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/speech-document.d.ts +91 -0
- package/node_modules/@hccm/web-tcl/dist/esm/speech-document.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/base-control.d.ts +100 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/base-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/contenteditable-control.d.ts +18 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/contenteditable-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/custom-control.d.ts +41 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/factory.d.ts +9 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/factory.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/helpers.d.ts +33 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/helpers.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/index.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/input-control.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/input-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/processing-status.d.ts +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/processing-status.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/text-control-manager.d.ts +38 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/text-control-manager.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/text-control.d.ts +64 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/text-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/textarea-control.d.ts +7 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/textarea-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/tinymce-control.d.ts +11 -0
- package/node_modules/@hccm/web-tcl/dist/esm/text-control-lib/tinymce-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/channel.d.ts +15 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/channel.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/commands.d.ts +64 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/commands.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/custom-control.d.ts +212 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/index.d.ts +6 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/input-custom-control.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/input-custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/textarea-custom-control.d.ts +2 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/custom-controls/textarea-custom-control.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/diagnostics.d.ts +37 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/diagnostics.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/dom-observable.d.ts +13 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/dom-observable.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/events.d.ts +39 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/events.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/iframe-support.d.ts +29 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/iframe-support.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/index.d.ts +26 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/index.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/processing-status.d.ts +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/processing-status.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/state.d.ts +165 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/state.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/types.d.ts +21 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/types.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/utility-types.d.ts +3 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/utility-types.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/validation.d.ts +35 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/validation.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-attributes.d.ts +104 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-attributes.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-client.d.ts +16 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-client.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-controller.d.ts +8 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/webtcl-controller.js +1 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/worker.d.ts +18 -0
- package/node_modules/@hccm/web-tcl/dist/esm/webtcl/worker.js +1 -0
- package/node_modules/@hccm/web-tcl/package.json +72 -0
- package/package.json +5 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param element
|
|
4
|
+
* @return {boolean}
|
|
5
|
+
* @function
|
|
6
|
+
*/
|
|
7
|
+
export function isElementAttributeEnabled(element: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if an HTML element's 'data-nusa-enabled' or 'data-dragon-enabled' attribute is disabled.
|
|
10
|
+
* The function considers both the attribute's value and a global setting 'shouldEnableAllElements' from SharedData.
|
|
11
|
+
* @param {HTMLElement} element - The HTML element to check.
|
|
12
|
+
* @returns {boolean} - Returns true if the 'data-nusa-enabled' or 'data-dragon-enabled' attribute is considered disabled, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export function isElementAttributeDisabled(element: HTMLElement): boolean;
|
|
15
|
+
export const Class_FocusedElement: "NUSA_focusedElement";
|
|
16
|
+
export const Class_ResultPending: "NUSAI_classResultPending";
|
|
17
|
+
export const Class_ActiveElement: "NUSAI_classActive";
|
|
18
|
+
export const Class_CkEditable: "cke_editable";
|
|
19
|
+
export const Attr_CustomContainerType: "data-nusa-custom-container-type";
|
|
20
|
+
export const Attr_CustomContainerId: "data-nusa-custom-container-id";
|
|
21
|
+
export namespace SharedData {
|
|
22
|
+
let shouldEnableAllElements: boolean;
|
|
23
|
+
let lastDanubeFocusId: string;
|
|
24
|
+
let lastFocusedSpeechElementId: string;
|
|
25
|
+
let activeDocument: Document;
|
|
26
|
+
let isRecording: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SharedData=exports.Attr_CustomContainerId=exports.Attr_CustomContainerType=exports.Class_CkEditable=exports.Class_ActiveElement=exports.Class_ResultPending=exports.Class_FocusedElement=void 0;exports.isElementAttributeEnabled=r;exports.isElementAttributeDisabled=a;const e=require("./common/local-store");const t=require("./webtcl/webtcl-attributes");exports.Class_FocusedElement="NUSA_focusedElement";exports.Class_ResultPending="NUSAI_classResultPending";exports.Class_ActiveElement="NUSAI_classActive";exports.Class_CkEditable="cke_editable";exports.Attr_CustomContainerType="data-nusa-custom-container-type";exports.Attr_CustomContainerId="data-nusa-custom-container-id";const s="SharedData";const o=new e.LocalStore(s,true);exports.SharedData={shouldEnableAllElements:true,lastDanubeFocusId:"",get lastFocusedSpeechElementId(){return o.get("lastFocusedSpeechElementId",null)},set lastFocusedSpeechElementId(e){o.set("lastFocusedSpeechElementId",e)},activeDocument:document,isRecording:false};function r(e){if(!e){return false}const s=(0,t.getAttributeValue)(e,"isEnabled");return s?s.toLowerCase()==="true":false}function a(e){var s;if(!e){return false}const o=(s=(0,t.getAttributeValue)(e,"isEnabled"))===null||s===void 0?void 0:s.toLowerCase();return exports.SharedData.shouldEnableAllElements?o==="false":o!=="true"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { TextControlManager } from "./text-control-lib";
|
|
2
|
+
import type { AdditionalReplaceTextParameters } from "./webtcl/types";
|
|
3
|
+
import type { ProcessingStatus } from "./text-control-lib";
|
|
4
|
+
import type { CustomControlCollection } from "./webtcl/custom-controls";
|
|
5
|
+
type SpeechDocumentInitializationOptions = {
|
|
6
|
+
document: Document;
|
|
7
|
+
selector?: string;
|
|
8
|
+
disableGuiMarkup?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The SpeechDocument
|
|
12
|
+
*/
|
|
13
|
+
export declare class SpeechDocument {
|
|
14
|
+
#private;
|
|
15
|
+
constructor({ customControls }?: {
|
|
16
|
+
customControls?: CustomControlCollection;
|
|
17
|
+
});
|
|
18
|
+
get isInitialized(): boolean;
|
|
19
|
+
get textControlManager(): TextControlManager;
|
|
20
|
+
/**
|
|
21
|
+
* @description initialize and speech enable the supported controls in the document
|
|
22
|
+
*/
|
|
23
|
+
initialize({ document, selector, disableGuiMarkup }: SpeechDocumentInitializationOptions): void;
|
|
24
|
+
/**
|
|
25
|
+
* @function
|
|
26
|
+
* @name deInitialize
|
|
27
|
+
* @description remove speech enablement from the document
|
|
28
|
+
* @memberof SpeechDocument
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
deInitialize(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @description set the active css class of a control
|
|
34
|
+
* @param {string} controlId - the id of the control
|
|
35
|
+
* @param {boolean} active - true if recording is on, mark focused field as Class_FocusedElement
|
|
36
|
+
*/
|
|
37
|
+
setControlActive(controlId: string, active: boolean): void;
|
|
38
|
+
/**
|
|
39
|
+
* @description set the focus to the control
|
|
40
|
+
* @param {string} controlId - the id of the control
|
|
41
|
+
* @memberof SpeechDocument
|
|
42
|
+
*/
|
|
43
|
+
setControlFocus(controlId: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* @description set the text of the control
|
|
46
|
+
* @param {string} controlId - the id of the control
|
|
47
|
+
* @param {string} text - the text to set
|
|
48
|
+
*/
|
|
49
|
+
setText(controlId: string, text: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* @description replace the text of the control
|
|
52
|
+
* @param {string} controlId - the id of the control
|
|
53
|
+
* @param {string} text - the text to set
|
|
54
|
+
* @param {number} fromPos - the start position
|
|
55
|
+
* @param {number} toPos - the end position
|
|
56
|
+
* @param {AdditionalReplaceTextParameters} additionalParameters - optional parameters including matchFormattingAtThe (start/end) to indicate which text formatting to choose.
|
|
57
|
+
*/
|
|
58
|
+
replaceText(controlId: string, text: string, fromPos: number, toPos: number, additionalParameters?: AdditionalReplaceTextParameters): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @description set the selection of the control IF the selection has not been manually changed since the recognition started
|
|
61
|
+
* @param {string} controlId - the id of the control
|
|
62
|
+
* @param {number} start - the start position
|
|
63
|
+
* @param {number} length - the length
|
|
64
|
+
*/
|
|
65
|
+
setSelection(controlId: string, start: number, length: number): void;
|
|
66
|
+
selectNode(controlId: string, focusElement: boolean): void;
|
|
67
|
+
/**
|
|
68
|
+
* Undoes the last action performed on the text control, if undo is supported.
|
|
69
|
+
*
|
|
70
|
+
* @param controlId - The unique identifier of the text control to perform undo on.
|
|
71
|
+
*/
|
|
72
|
+
undo(controlId: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Redoes the last undone action for the specified text control, if redo is supported.
|
|
75
|
+
*
|
|
76
|
+
* @param controlId - The unique identifier of the text control to perform redo on.
|
|
77
|
+
*/
|
|
78
|
+
redo(controlId: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* @description set the proecessing status of the control and apply some visuals
|
|
81
|
+
*/
|
|
82
|
+
setProcessingStatus(controlId: string, status: ProcessingStatus): void;
|
|
83
|
+
scanDocument(selector?: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* @description check if the control has focus
|
|
86
|
+
* @param {string} controlId - the id of the control
|
|
87
|
+
* @returns {boolean} - true if the control has focus
|
|
88
|
+
*/
|
|
89
|
+
hasFocus(controlId: string): boolean;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,i,s,l,n,a,o,r,c,d,u,f,h,m,g,_,v,F,p,P;Object.defineProperty(exports,"__esModule",{value:true});exports.SpeechDocument=void 0;const S=require("tslib");const b=require("./common/error");const C=require("./logger/logging");const E=require("./common/string");const G=require("./text-control-lib");const D=require("./text-control-lib");const I=require("./common/dom");const y=require("./text-control-lib");const x=require("./shared-data");const T=require("./common/util");const w=require("./webtcl/validation");const A=require("./text-control-lib/text-control");const M=require("./webtcl/webtcl-attributes");const k="[data-nusa-container],[data-dragon-container]";const L=`[data-nusa-container]:not([data-nusa-enabled^='false' i]) *,[data-dragon-container]:not([data-nusa-enabled^='false' i]) *,\n [data-nusa-container]:not([data-dragon-enabled^='false' i]) *,[data-dragon-container]:not([data-dragon-enabled^='false' i]) *`;class q{constructor({customControls:d={}}={}){e.add(this);t.set(this,null);i.set(this,new G.TextControlManager);s.set(this,new Map);l.set(this,null);n.set(this,null);a.set(this,false);o.set(this,(0,I.getInternalScriptLocation)()+"../");r.set(this,false);c.set(this,void 0);S.__classPrivateFieldSet(this,c,d,"f")}get isInitialized(){return S.__classPrivateFieldGet(this,t,"f")!==null}get textControlManager(){return S.__classPrivateFieldGet(this,i,"f")}initialize({document:e,selector:i="body",disableGuiMarkup:s=false}){if(S.__classPrivateFieldGet(this,t,"f")){this.deInitialize()}if(!e){C.logger.debug("SpeechDocument.initialize","no root document for container");throw new b.IntegrationError("argument is not valid {null|HTMLDocument|HTMLElement|Array}")}S.__classPrivateFieldSet(this,r,s,"f");S.__classPrivateFieldSet(this,t,e,"f");this.scanDocument(i)}deInitialize(){if(!S.__classPrivateFieldGet(this,t,"f")){C.logger.info("SpeechDocument.deInitialize","no valid #document");return}S.__classPrivateFieldGet(this,e,"m",h).call(this);S.__classPrivateFieldSet(this,t,null,"f")}setControlActive(e,t){let s=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(!s){(0,b.handleNoElement)("SpeechDocument.setControlActive",e);return}s.htmlElement.classList.toggle(x.Class_ActiveElement,t);s=S.__classPrivateFieldGet(this,i,"f").getTextControl("_"+e);if(!s){return}s.htmlElement.classList.toggle(x.Class_ActiveElement,t)}setControlFocus(t){var s;const l=S.__classPrivateFieldGet(this,i,"f").getTextControl(t);if(!l){(0,b.handleNoElement)("SpeechDocument.setControlFocus",t);return}if(l instanceof G.CustomControl){(s=l.onFocus)===null||s===void 0?void 0:s.call(l);S.__classPrivateFieldGet(this,e,"m",d).call(this,l.htmlElement,false);return}const n=l.htmlElement;if(!n){(0,b.handleNoElement)("SpeechDocument.setControlFocus","tried all ids");return}x.SharedData.lastDanubeFocusId=t;C.logger.debug("SpeechDocument.setControlFocus","new NUSAI.Data.lastDanubeFocusId",x.SharedData.lastDanubeFocusId);S.__classPrivateFieldGet(this,e,"m",d).call(this,n,true)}setText(e,t){if(!e)return;const s=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(!s)return;s.setText(t)}replaceText(e,t,s,l,n){if(!e)return false;const a=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(!a)return false;return a.replaceText(t,s,l-s,n)}setSelection(e,t,s){C.logger.debug("SpeechDocument.setSelection",e,t.toString(),s.toString());if(!e){return}const l=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(!l){return}l.setSelection(t,s)}selectNode(t,s){const l=S.__classPrivateFieldGet(this,i,"f").getTextControl(t);if(!!l&&l.isValid()){S.__classPrivateFieldGet(this,e,"m",d).call(this,l.htmlElement,s)}}undo(e){const t=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(t&&(0,A.isUndoableControl)(t)){t.undo()}}redo(e){const t=S.__classPrivateFieldGet(this,i,"f").getTextControl(e);if(t&&(0,A.isUndoableControl)(t)){t.redo()}}setProcessingStatus(t,s){const l=S.__classPrivateFieldGet(this,i,"f").getTextControl(t);if(!!l&&l.isValid()){l.setProcessingStatus(s);S.__classPrivateFieldGet(this,e,"m",v).call(this,l.htmlElement,s==="pending")}}scanDocument(l){var n;S.__classPrivateFieldGet(this,i,"f").removeAll();S.__classPrivateFieldGet(this,s,"f").clear();if(!S.__classPrivateFieldGet(this,t,"f")){C.logger.warning("SpeechDocument.scanDocument","no document");return}const a=l?(n=S.__classPrivateFieldGet(this,t,"f").querySelector(l))!==null&&n!==void 0?n:S.__classPrivateFieldGet(this,t,"f").body:S.__classPrivateFieldGet(this,t,"f").body;const o=a.querySelectorAll(L);if(!o||o.length===0){C.logger.warning("SpeechDocument.scanDocument","no elements");return}C.logger.info("SpeechDocument.scanDocument","elements to check: #"+o.length);S.__classPrivateFieldGet(this,e,"m",F).call(this,Array.from(o));C.logger.info("SpeechDocument.scanDocument","textControls added: #"+this.textControlManager.textControlCount)}hasFocus(e){var i;if(!((i=S.__classPrivateFieldGet(this,t,"f"))===null||i===void 0?void 0:i.activeElement)){return false}return(0,M.getAttributeValue)(S.__classPrivateFieldGet(this,t,"f").activeElement,"controlId")===e}}exports.SpeechDocument=q;t=new WeakMap,i=new WeakMap,s=new WeakMap,l=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,e=new WeakSet,d=function i(s,l){var a;C.logger.debug("SpeechDocument.#selectNodeElement",s===null||s===void 0?void 0:s.id.toString(),l.toString());if(!s){(0,b.handleNoElement)("SpeechDocument.#selectNodeElement");return}S.__classPrivateFieldGet(this,e,"m",P).call(this,s,x.SharedData.isRecording);const o=s.id;let r=s;const c=(0,w.isCustomControl)(s);if(c){const e=(0,D.getCustomControlContainer)(s);if(e)r=e}if(r.classList.contains(x.Class_ResultPending))S.__classPrivateFieldGet(this,e,"m",v).call(this,r,false);if(x.SharedData.lastFocusedSpeechElementId){const i=(a=S.__classPrivateFieldGet(this,t,"f"))===null||a===void 0?void 0:a.getElementById(x.SharedData.lastFocusedSpeechElementId);if(i)S.__classPrivateFieldGet(this,e,"m",v).call(this,i,i.classList.contains(x.Class_ResultPending))}x.SharedData.lastFocusedSpeechElementId=o;if("type"in s&&typeof s.type==="string"){C.logger.debug("SpeechDocument.#selectNodeElement","type:"+s.type)}if(l&&!(0,I.isTextInput)(s)&&"type"in s&&s.type!=="textarea"&&!s.isContentEditable&&!c){s.focus();return}if(l&&S.__classPrivateFieldGet(this,n,"f")!==s){S.__classPrivateFieldGet(this,e,"m",p).call(this,s)}},u=function t(i){const s=(0,I.getEventTarget)(i);if(s===null){C.logger.debug("SpeechDocument.#onElementFocusInternal","no event target - ignore");return}S.__classPrivateFieldSet(this,n,s,"f");C.logger.debug("SpeechDocument.#onElementFocusInternal",s.tagName+", "+s.id);if((0,w.isCustomContainer)(s)){C.logger.debug("SpeechDocument.#onElementFocusInternal - custom container:",s.id);const e=(0,D.getCustomContainerType)(s);C.logger.debug("SpeechDocument.#onElementFocusInternal - customContainerType=",e!==null&&e!==void 0?e:"null")}const l=(0,M.getAttributeValue)(s,"controlId");if((0,E.isEmpty)(l)){C.logger.debug("SpeechDocument.#onElementFocusInternal","no sfId -> ignored");return}if(S.__classPrivateFieldGet(this,a,"f")){C.logger.debug("SpeechDocument.#onElementFocusInternal","ignoring");return}if(s){S.__classPrivateFieldGet(this,e,"m",d).call(this,s,false)}},f=function e(t){const i=(0,I.getEventTarget)(t);if(i===S.__classPrivateFieldGet(this,n,"f"))S.__classPrivateFieldSet(this,n,null,"f")},h=function t(){S.__classPrivateFieldSet(this,l,new Map(S.__classPrivateFieldGet(this,s,"f")),"f");for(const t of S.__classPrivateFieldGet(this,s,"f").keys()){const s=S.__classPrivateFieldGet(this,i,"f").getTextControl(t);if(!(s===null||s===void 0?void 0:s.isValid())){continue}const l=s.htmlElement;S.__classPrivateFieldGet(this,e,"m",_).call(this,l);if(x.SharedData.lastFocusedSpeechElementId===l.id){l.classList.remove(x.Class_FocusedElement)}(0,M.removeAttribute)(l,"controlId")}S.__classPrivateFieldGet(this,i,"f").removeAll();S.__classPrivateFieldGet(this,s,"f").clear()},m=function e(t){if(!S.__classPrivateFieldGet(this,l,"f"))return null;for(const[e,i]of S.__classPrivateFieldGet(this,l,"f").entries()){if(i===t)return e}return null},g=function e(t,i){const l=t.htmlElement;if((0,E.isEmpty)(l.id))l.id=i;S.__classPrivateFieldGet(this,s,"f").set(i,l.id);t.cleanup(true)},_=function e(i){var s,l,n;if((0,w.isCustomControl)(i)||(0,w.isCustomContainer)(i))return;if(S.__classPrivateFieldGet(this,r,"f"))return;let a;const o=(0,M.getAttributeValue)(i,"markerContainer");if(o&&!(0,E.isEmpty)(o)){a=(s=S.__classPrivateFieldGet(this,t,"f"))===null||s===void 0?void 0:s.getElementById(o);if(!a)alert("Element with id="+o+" not found!\nThis is set as the marker container for element id="+i.id)}if(!a)a=i;else{a.style.visibility="hidden";a.style.display="none"}let c="";if(a.tagName==="IMG"&&((l=a.attributes)===null||l===void 0?void 0:l.getNamedItem("src"))){c=(n=a.attributes.getNamedItem("src"))===null||n===void 0?void 0:n.value;if(c===null||c===void 0?void 0:c.includes("nuance-bg."))a.setAttribute("src","");return}let d=a.style.cssText;if(d&&d.length>0){if(!d.includes("nuance-bg."))return}d=d.replace(/nuance-bg.(png|gif)/,"");a.style.cssText=d},v=function e(i,s){var l;if(S.__classPrivateFieldGet(this,r,"f"))return;C.logger.debug("SpeechDocument.#addLogoToElement",i===null||i===void 0?void 0:i.id,s.toString());if(!i){C.logger.warning("SpeechDocument.#addLogoToElement","empty element");return}let n;const a=(0,M.getAttributeValue)(i,"markerContainer");if(a&&!(0,E.isEmpty)(a)){n=(l=S.__classPrivateFieldGet(this,t,"f"))===null||l===void 0?void 0:l.getElementById(a);if(!n)alert("Element with id="+a+" not found!\nThis is set as the marker container for element id="+i.id)}if(!n){if((0,w.isCustomControl)(i)||(0,w.isCustomContainer)(i))return;n=i}else if(n instanceof HTMLElement){n.style.visibility="visible";n.style.display=""}let c="";if(n.tagName==="IMG"){if(s)c=S.__classPrivateFieldGet(this,o,"f")+"images/nuance-bg.gif";else c=S.__classPrivateFieldGet(this,o,"f")+"images/nuance-bg.png";n.setAttribute("src",c);return}let d=n instanceof HTMLElement?n.style.cssText:null;let u=true;if(d&&d.length>0){if(d.includes("nuance_bg."))u=false;else d+=";"}if(u){d+="background-image:url("+S.__classPrivateFieldGet(this,o,"f")+"images/nuance-bg."+(s?"gif":"png")+");background-repeat:no-repeat;background-position:right top;"}else if(d){if(s)d=d.replace("nuance-bg.png","nuance-bg.gif");else d=d.replace("nuance-bg.gif","nuance-bg.png")}if(d&&n instanceof HTMLElement){n.style.cssText=d}},F=function s(l){var n,a,o;let r=false;for(const t of l){if(!t||!(0,I.isElementSpeechEnabled)(t)){continue}const s=(0,y.createTextControl)(t,S.__classPrivateFieldGet(this,c,"f"));if(!s){continue}const l=t.closest(k);if(!l){continue}const o=(n=(0,M.getAttributeValue)(l,"container"))!==null&&n!==void 0?n:"";const d=(0,M.getAttributeValue)(l,"isEnabled");if((d===null||d===void 0?void 0:d.toLocaleLowerCase())==="false"){continue}C.logger.debug("SpeechDocument.processElements","text control created",s.type);if(!(s instanceof G.CustomControl)){s.onFocus=S.__classPrivateFieldGet(this,e,"m",u).bind(this);s.onBlur=S.__classPrivateFieldGet(this,e,"m",f).bind(this)}const h=S.__classPrivateFieldGet(this,e,"m",m).call(this,t.id);let _=h!==null&&h!==void 0?h:"";C.logger.debug("SpeechDocument.processElements",`old sfId for ${t.id}=${_}`);const F=(0,M.getAttributeValue)(t,"controlId");_=F!==null&&F!==void 0?F:_;const p=S.__classPrivateFieldGet(this,i,"f").addTextControl(s,_,o);_=p?p:"";S.__classPrivateFieldGet(this,e,"m",g).call(this,s,_);C.logger.debug("SpeechDocument.processElements","text control - id and sfId set",t.id,_);if(x.SharedData.lastFocusedSpeechElementId===t.id){r=true}let P=(a=(0,M.getAttributeValue)(t,"conceptName"))!==null&&a!==void 0?a:"";P=(0,T.decodeHtml)(P);S.__classPrivateFieldGet(this,e,"m",v).call(this,t,false);let b=(0,M.getAttributeValue)(t,"documentFieldId");if(!b){b=t.id;(0,M.setAttributeValue)(t,"documentFieldId",b)}}if(!r&&x.SharedData.lastFocusedSpeechElementId){const e=(o=S.__classPrivateFieldGet(this,t,"f"))===null||o===void 0?void 0:o.getElementById(x.SharedData.lastFocusedSpeechElementId);e===null||e===void 0?void 0:e.classList.remove(x.Class_FocusedElement);x.SharedData.lastFocusedSpeechElementId=""}},p=function e(s){var l;try{C.logger.debug("SpeechDocument.focusSpeechElement - focus element");S.__classPrivateFieldSet(this,a,true,"f");s.focus();S.__classPrivateFieldSet(this,n,s,"f");if(!((l=S.__classPrivateFieldGet(this,t,"f"))===null||l===void 0?void 0:l.hasFocus())){const e=S.__classPrivateFieldGet(this,i,"f").getTextControlByElement(s);e===null||e===void 0?void 0:e.onElementFocus(null)}}finally{S.__classPrivateFieldSet(this,a,false,"f")}},P=function e(i,s){var l;let n;let a;if(x.SharedData.lastFocusedSpeechElementId!=null){n=(l=S.__classPrivateFieldGet(this,t,"f"))===null||l===void 0?void 0:l.getElementById(x.SharedData.lastFocusedSpeechElementId);if(!n)x.SharedData.lastFocusedSpeechElementId="";else{if((0,w.isCustomControl)(n)){a=(0,D.getCustomControlContainer)(n);if(a!=null)n=a}n.classList.remove(x.Class_FocusedElement)}}let o=false;if((0,w.isCustomControl)(i)){a=(0,D.getCustomControlContainer)(i);if(a!=null){o=true}}if(s&&!o&&!S.__classPrivateFieldGet(this,r,"f")){i.classList.add(x.Class_FocusedElement)}};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** @typedef {import('../common/selection-info').SelectionInfo} SelectionInfo */
|
|
2
|
+
/** @typedef {import('./processing-status').ProcessingStatus} ProcessingStatus */
|
|
3
|
+
/**
|
|
4
|
+
* The base class of all TextControls
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
export class BaseControl {
|
|
8
|
+
constructor(element: any);
|
|
9
|
+
type: string;
|
|
10
|
+
/** @type {string|null} */
|
|
11
|
+
guid: string | null;
|
|
12
|
+
isMultiline: boolean;
|
|
13
|
+
/** @type {ProcessingStatus} */
|
|
14
|
+
processingStatus: ProcessingStatus;
|
|
15
|
+
/** @type {HTMLElement} */
|
|
16
|
+
htmlElement: HTMLElement;
|
|
17
|
+
newlineFormat: string;
|
|
18
|
+
paragraphFormat: string;
|
|
19
|
+
onFocus: any;
|
|
20
|
+
onBlur: any;
|
|
21
|
+
/** @param {SelectionInfo | null} selection */
|
|
22
|
+
set pendingSelection(selection: SelectionInfo | null);
|
|
23
|
+
/** @returns {SelectionInfo | null } */
|
|
24
|
+
get pendingSelection(): SelectionInfo | null;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the HTML element currently has focus.
|
|
27
|
+
*
|
|
28
|
+
* @returns {boolean} True if the HTML element has focus, otherwise false.
|
|
29
|
+
*/
|
|
30
|
+
get hasFocus(): boolean;
|
|
31
|
+
isValid(): boolean;
|
|
32
|
+
invalidate(): void;
|
|
33
|
+
onElementFocus(e: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* @param {FocusEvent} e
|
|
36
|
+
*/
|
|
37
|
+
onElementBlur(e: FocusEvent): void;
|
|
38
|
+
getType(): string;
|
|
39
|
+
setGuid(guid: any): boolean;
|
|
40
|
+
getElementGuid(): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* The dictation mode of the html element
|
|
43
|
+
* @return {string}
|
|
44
|
+
*/
|
|
45
|
+
get dictationMode(): string;
|
|
46
|
+
/**
|
|
47
|
+
* The concept name of the html element
|
|
48
|
+
* @return {string}
|
|
49
|
+
*/
|
|
50
|
+
get conceptName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* The document field id of the html element
|
|
53
|
+
* @return {string}
|
|
54
|
+
*/
|
|
55
|
+
get documentFieldId(): string;
|
|
56
|
+
/** @returns {void} */
|
|
57
|
+
cleanup(_initialCleanup: any): void;
|
|
58
|
+
/**
|
|
59
|
+
* getText
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
getText(): string;
|
|
63
|
+
/** @returns {void} */
|
|
64
|
+
setText(text: any): void;
|
|
65
|
+
/** @returns {boolean} */
|
|
66
|
+
replaceText(text: any, from: any, length: any): boolean;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @returns {SelectionInfo}
|
|
70
|
+
*/
|
|
71
|
+
getSelection(): SelectionInfo;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the selection range of the input element.
|
|
74
|
+
*
|
|
75
|
+
* @param {number} [from=0] - The starting position of the selection.
|
|
76
|
+
* @param {number} [length=0] - The length of the selection.
|
|
77
|
+
*/
|
|
78
|
+
setSelection(from?: number, length?: number): void;
|
|
79
|
+
getTextLength(): number;
|
|
80
|
+
getNewlineFormatString(): string;
|
|
81
|
+
getParagraphFormatString(): string;
|
|
82
|
+
/** @returns {import("../common/coordinates").Coordinates} */
|
|
83
|
+
getSelectionCoordinates(): import("../common/coordinates").Coordinates;
|
|
84
|
+
getLineBreakSubstitute(): string;
|
|
85
|
+
getLineBreakText(node: any): string;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the current processing status.
|
|
88
|
+
* @returns {ProcessingStatus}
|
|
89
|
+
*/
|
|
90
|
+
getProcessingStatus(): ProcessingStatus;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the processing status.
|
|
93
|
+
* @param {ProcessingStatus} status
|
|
94
|
+
*/
|
|
95
|
+
setProcessingStatus(status: ProcessingStatus): void;
|
|
96
|
+
_ensureSelectionIsVisible(from: any, length: any): void;
|
|
97
|
+
#private;
|
|
98
|
+
}
|
|
99
|
+
export type SelectionInfo = import("../common/selection-info").SelectionInfo;
|
|
100
|
+
export type ProcessingStatus = import("./processing-status").ProcessingStatus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t;Object.defineProperty(exports,"__esModule",{value:true});exports.BaseControl=void 0;const e=require("tslib");const n=e.__importStar(require("../common/util"));const i=e.__importStar(require("../common/string"));const l=e.__importStar(require("../common/dom"));const s=require("../common/browser");const r=require("../common/element-extensions");const o=require("rxjs");const h=require("../webtcl/webtcl-attributes");class u{constructor(n){t.set(this,void 0);this.type="TextControl";this.guid=null;this.isMultiline=true;this.processingStatus="idle";this.htmlElement=n;this.newlineFormat="\n";this.paragraphFormat="\n\n";this.onFocus=null;this.onBlur=null;e.__classPrivateFieldSet(this,t,!this.htmlElement?[]:[(0,o.fromEvent)(this.htmlElement,"focus").subscribe(t=>{this.onElementFocus(t)}),(0,o.fromEvent)(this.htmlElement,"blur").subscribe(t=>{this.onElementBlur(t)})],"f")}get pendingSelection(){var t;return(t=r.elementAccessor.get(this.htmlElement,"pendingSelection"))!==null&&t!==void 0?t:null}set pendingSelection(t){r.elementAccessor.set(this.htmlElement,"pendingSelection",t!==null&&t!==void 0?t:undefined);if(!this.hasFocus){this.htmlElement.dispatchEvent(new CustomEvent("pendingSelectionChanged"))}}get hasFocus(){return this.htmlElement===this.htmlElement.ownerDocument.activeElement}isValid(){return!!this.htmlElement}invalidate(){for(const n of e.__classPrivateFieldGet(this,t,"f")){n.unsubscribe()}e.__classPrivateFieldGet(this,t,"f").length=0;this.htmlElement=null;this.guid=null;this.onFocus=null;this.onBlur=null}onElementFocus(t){if(!this){return}const e=this.pendingSelection;if(e){this.pendingSelection=null;this.setSelection(e.start,e.length)}if(typeof this.onFocus==="function"){if(t===null){t={target:this.htmlElement}}this.onFocus(t)}}onElementBlur(t){if(!this)return;if(typeof this.onBlur==="function")this.onBlur(t)}getType(){return this.type}setGuid(t){this.guid=t;(0,h.setAttributeValue)(this.htmlElement,"controlId",t);return true}getElementGuid(){return(0,h.getAttributeValue)(this.htmlElement,"controlId")}get dictationMode(){var t;const e=(t=(0,h.getAttributeValue)(this.htmlElement,"dictationMode"))!==null&&t!==void 0?t:"";return n.decodeHtml(e)}get conceptName(){var t;const e=(t=(0,h.getAttributeValue)(this.htmlElement,"conceptName"))!==null&&t!==void 0?t:"";return n.decodeHtml(e)}get documentFieldId(){var t;const e=(t=(0,h.getAttributeValue)(this.htmlElement,"documentFieldId"))!==null&&t!==void 0?t:"";return n.decodeHtml(e)}cleanup(t){return false}getText(){if(this.htmlElement.value)return this.htmlElement.value;return""}setText(t){t!==null&&t!==void 0?t:t="";if(!this.isMultiline){t=i.replaceAll(t,"\n"," ")}const e=Object.getOwnPropertyDescriptor(this.htmlElement.constructor.prototype,"value").set;e.call(this.htmlElement,t);this.htmlElement.dispatchEvent(new Event("input",{bubbles:true}));return true}replaceText(t,e,l){let s=this.getText();const r=n.getScrollInfo(this.htmlElement);if(!this.isMultiline){t=i.replaceAll(t,"\n"," ")}e=n.forceNumber(e);l=n.forceNumber(l);if(s.length>0)s=i.remove(s,e,e+l);s=i.insert(s,e,t);this.setText(s);if(!n.adjustScrollPosition(this.htmlElement,r))this._ensureSelectionIsVisible(e+t.length,0);return true}getSelection(){var t;if(this.pendingSelection){return this.pendingSelection}const e=(t=this.htmlElement.selectionStart)!==null&&t!==void 0?t:0;const n=this.htmlElement.selectionEnd-e;return{start:e,length:n}}setSelection(t=0,e=0){t=Math.max(0,n.forceNumber(t));e=Math.max(0,n.forceNumber(e));if(!this.hasFocus){this.pendingSelection={start:t,length:e};return}const i=["text","search","tel","url","password"];if(this.type!=="Input"||i.includes(this.htmlElement.type)){this.htmlElement.selectionStart=t;this.htmlElement.selectionEnd=Number(t)+Number(e)}this._ensureSelectionIsVisible(t,e)}getTextLength(){return this.getText().length}getNewlineFormatString(){return this.newlineFormat}getParagraphFormatString(){return this.paragraphFormat}getSelectionCoordinates(){const t=this.getSelection(),e=l.getTextBoundingRect(this.htmlElement,t.start,t.length);return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}getLineBreakSubstitute(){return" "}getLineBreakText(t){if(!t||l.nodeNameEquals(t,"br"))return"\n";if((n.Instance.browserBrand[s.BrowserBrand.Chrome]||n.Instance.browserBrand[s.BrowserBrand.Edge])&&l.nodeNameEquals(t,"div"))return"\n";const e=t.nodeName.toLowerCase();if(e==="li"||e==="ul"||e==="ol")return"\n";if(e==="div"||e==="p"||e.match("h."))return"\f";if(l.nodeNameEquals(t,"td")||l.nodeNameEquals(t,"table"))return String.fromCharCode(127);return""}getProcessingStatus(){return this.processingStatus}setProcessingStatus(t){if(this.processingStatus===t){return}this.processingStatus=t;this.htmlElement.dispatchEvent(new CustomEvent("processingStatusChanged"))}_ensureSelectionIsVisible(t,e){if(t===0){this.htmlElement.scrollTop=this.htmlElement.scrollLeft=0;return}const n=l.getTextBoundingRect(this.htmlElement,t,t+e);const i=this.htmlElement.getBoundingClientRect();const s=n.top-this.htmlElement.scrollTop>=i.top&&n.bottom-this.htmlElement.scrollTop<=i.bottom;const r=n.left-this.htmlElement.scrollLeft>=i.left&&n.right-this.htmlElement.scrollLeft<=i.right;if(!r){this.htmlElement.scrollLeft=n.left-i.left-i.width/2}if(!s){this.htmlElement.scrollTop=n.top-i.top-i.height/2}}}exports.BaseControl=u;t=new WeakMap;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @typedef {import("../common/selection-info").SelectionInfo} SelectionInfo */
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export class ContentEditableControl extends BaseControl {
|
|
6
|
+
keepEmptyTextNode: boolean;
|
|
7
|
+
adjustScrollPosition(element: any, scrollInfo: any, fromPosition: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Ensures that the specified text selection is visible within the contenteditable element
|
|
10
|
+
* by automatically scrolling the element if necessary.
|
|
11
|
+
* @private
|
|
12
|
+
* @param {number} [from] - The starting position of the selection. If not provided, uses current selection.
|
|
13
|
+
*/
|
|
14
|
+
private _ensureSelectionIsVisible;
|
|
15
|
+
#private;
|
|
16
|
+
}
|
|
17
|
+
export type SelectionInfo = import("../common/selection-info").SelectionInfo;
|
|
18
|
+
import { BaseControl } from "./base-control";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,i,l,n,s,o,r,a,d,c,h,u,f,m,g,_,v,N,p,b,F,C,P,x,G,E,S,T,w,B,q,I,y,L,k,V,O,A,M,D,R,W,H,j,z,$,U,J,K,Q,X,Y,Z,ee,te;Object.defineProperty(exports,"__esModule",{value:true});exports.ContentEditableControl=void 0;const ie=require("tslib");const le=require("./base-control");const ne=require("../logger/logging");const se=ie.__importStar(require("../common/util"));const oe=ie.__importStar(require("../common/string"));const re=ie.__importStar(require("../common/dom"));const ae=require("../common/browser");const de=require("../webtcl/webtcl-attributes");class ce extends le.BaseControl{constructor(t){super(t);e.add(this);te.set(this,new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","ul","output","summary","details","dialog"]));this.type="ContentEditable";this.newlineFormat="\n";this.paragraphFormat="\f";this.keepEmptyTextNode=false}invalidate(){super.invalidate.call(this)}onElementFocus(e){const t=this.pendingSelection;if(!(e===null||e===void 0?void 0:e.sourceCapabilities)){if(t){ne.logger.debug("ContentEditableControl.onElementFocus","pendingSelection");this.setSelection(t.start,t.length)}else{ne.logger.debug("ContentEditableControl.onElementFocus","firstTime: setting caret to end of field");this.setSelection(this.getTextLength(),0)}}if(e!==null&&typeof this.onFocus==="function"){this.onFocus(e)}}cleanup(t){var i;const l=this.htmlElement;let o,r;const d=re.selectionMarker;try{ne.logger.debug("ContentEditableControl.cleanup",l===null||l===void 0?void 0:l.id);if(!l||oe.isEmpty(l.innerHTML)){return}if(l===l.ownerDocument.activeElement&&se.Instance.browserBrand[ae.BrowserBrand.Mozilla]){({anchorNodeId:o,focusNodeId:r}=ie.__classPrivateFieldGet(this,e,"m",s).call(this,l))}const i=l.innerHTML.length;re.removeCommentNodes(l);const c=re.removeSourceBlanks(l.innerHTML);if(c.length!==i){l.innerHTML=c}if(se.Instance.browserBrand[ae.BrowserBrand.Mozilla]){ie.__classPrivateFieldGet(this,e,"m",n).call(this,l,t)}if(!ie.__classPrivateFieldGet(this,e,"m",$).call(this,l)){const t=oe.replaceAll(c,d,"");if(!oe.isEmpty(t))ie.__classPrivateFieldGet(this,e,"m",_).call(this,l)}if(o)ie.__classPrivateFieldGet(this,e,"m",a).call(this,l,d,o,r)}catch(e){if(l===null||l===void 0?void 0:l.innerHTML){l.innerHTML=oe.replaceAll(l.innerHTML,d,"")}ne.logger.error("ContentEditableControl.cleanup",(i=e===null||e===void 0?void 0:e.message)!==null&&i!==void 0?i:"unknown error",e)}}getText(){var t;try{ne.logger.debug("ContentEditableControl.getText");ie.__classPrivateFieldGet(this,e,"m",C).call(this);let t=ie.__classPrivateFieldGet(this,e,"m",c).call(this,this.htmlElement,this.htmlElement,"");t=oe.replaceAll(t," "," ");return t}catch(e){ne.logger.error("ContentEditableControl.getText",(t=e===null||e===void 0?void 0:e.message)!==null&&t!==void 0?t:"unknown error",e);return null}}setText(t){var i;try{ne.logger.debug("ContentEditableControl.setText");t!==null&&t!==void 0?t:t="";const i=se.getScrollInfo(this.htmlElement);const l=this.getTextLength();ie.__classPrivateFieldGet(this,e,"m",h).call(this,t,0,l);this.adjustScrollPosition(this.htmlElement,i,0,l);if(this.hasFocus){ie.__classPrivateFieldGet(this,e,"m",f).call(this,this.getTextLength(),0)}return true}catch(e){ne.logger.error("ContentEditableControl.setText",(i=e===null||e===void 0?void 0:e.message)!==null&&i!==void 0?i:"unknown error",e);return false}}replaceText(t,i,l){var n;try{ne.logger.debug("ContentEditableControl.replaceText",i,l);const n=se.getScrollInfo(this.htmlElement);i=se.forceNumber(i);l=se.forceNumber(l);ie.__classPrivateFieldGet(this,e,"m",h).call(this,t,i,i+l);this.adjustScrollPosition(this.htmlElement,n,i);return true}catch(e){ne.logger.error("ContentEditableControl.replaceText",(n=e===null||e===void 0?void 0:e.message)!==null&&n!==void 0?n:"unknown error",e);return false}}adjustScrollPosition(e,t,i){if(!se.adjustScrollPosition(e,t)){this._ensureSelectionIsVisible(i)}}getSelection(){var t;try{ne.logger.debug("ContentEditableControl.getSelection");if(this.hasFocus){return this.pendingSelection=ie.__classPrivateFieldGet(this,e,"m",m).call(this)}if(this.pendingSelection){return ie.__classPrivateFieldGet(this,e,"m",d).call(this,this.pendingSelection.start,this.pendingSelection.length)}return{start:this.getTextLength(),length:0}}catch(e){ne.logger.error("ContentEditableControl.getSelection",(t=e===null||e===void 0?void 0:e.message)!==null&&t!==void 0?t:"unknown error",e);return null}}setSelection(t=0,i=0){var l;try{ne.logger.debug("ContentEditableControl.setSelection",t,i);const l=ie.__classPrivateFieldGet(this,e,"m",d).call(this,t,i);if(!this.hasFocus){this.pendingSelection=l;return}ie.__classPrivateFieldGet(this,e,"m",f).call(this,l.start,l.length);const n=se.getScrollInfo(this.htmlElement);this.adjustScrollPosition(this.htmlElement,n,l.start)}catch(e){ne.logger.error("ContentEditableControl.setSelection",(l=e===null||e===void 0?void 0:e.message)!==null&&l!==void 0?l:"unknown error",e)}}getSelectionCoordinates(){var e;try{ne.logger.debug("ContentEditableControl.getSelectionCoordinates");const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).getBoundingClientRect();return{left:t.left,top:t.top,right:t.right,bottom:t.bottom}}catch(t){ne.logger.error("ContentEditableControl.getSelectionCoordinates",(e=t===null||t===void 0?void 0:t.message)!==null&&e!==void 0?e:"unknown error",t);return null}}_ensureSelectionIsVisible(e){var t;try{if(e===undefined){const t=this.getSelection();if(!t)return;e=t.start}const t=this.htmlElement;if(e===0){t.scrollTop=t.scrollLeft=0;return}const i=this.getSelectionCoordinates();if(!i||i.top===0&&i.bottom===0&&i.left===0&&i.right===0)return;const l=t.getBoundingClientRect();const n=l.top;const s=l.bottom;const o=l.left;const r=l.right;const a=i.top>=n&&i.bottom<=s;const d=i.left>=o&&i.right<=r;if(!a){const e=(i.top+i.bottom)/2;const l=(n+s)/2;const o=e-l;t.scrollTop+=o}if(!d){const e=(i.left+i.right)/2;const l=(o+r)/2;const n=e-l;t.scrollLeft+=n}}catch(e){ne.logger.error("ContentEditableControl._ensureSelectionIsVisible",(t=e===null||e===void 0?void 0:e.message)!==null&&t!==void 0?t:"unknown error",e)}}}exports.ContentEditableControl=ce;te=new WeakMap,e=new WeakSet,t=function e(t,i){while(i.indexOf(t)>=0)t+="]";return t},i=function e(t){var i;let l,n;if(!re.isTextNode(t.anchorNode)){l=(i=t.anchorNode.childNodes[t.anchorOffset-1])!==null&&i!==void 0?i:t.anchorNode;n=0}else{l=t.anchorNode;n=t.anchorOffset}return{anchorNode:l,anchorOffset:n}},l=function e(t){var i;let l,n;if(!re.isTextNode(t.focusNode)){l=(i=t.focusNode.childNodes[t.focusOffset-1])!==null&&i!==void 0?i:t.anchorNode;n=0}else{l=t.focusNode;n=t.focusOffset}return{focusNode:l,focusOffset:n}},n=function t(i,l){if(l)re.removeHiddenParagraphs(i);let n=i.getElementsByTagName("p");if(n){for(const t of n)ie.__classPrivateFieldGet(this,e,"m",E).call(this,t)}n=i.getElementsByTagName("div");if(n){for(const t of n)ie.__classPrivateFieldGet(this,e,"m",E).call(this,t)}},s=function n(s){var o,r;const a=ie.__classPrivateFieldGet(this,e,"m",t).call(this,re.selectionMarker,s.innerHTML);const d=re.getWindow(s).getSelection();const{anchorNode:c,anchorOffset:h}=ie.__classPrivateFieldGet(this,e,"m",i).call(this,d);const{focusNode:u,focusOffset:f}=ie.__classPrivateFieldGet(this,e,"m",l).call(this,d);(o=c.id)!==null&&o!==void 0?o:c.id=se.Instance.createGuid(true);(r=u.id)!==null&&r!==void 0?r:u.id=se.Instance.createGuid(true);if(c===u&&re.isTextNode(c)){let e,t;if(h<=f){e=h;t=f+a.length}else{e=f;t=h+a.length}c.textContent=c.textContent.substring(0,e)+a+c.textContent.substring(e);c.textContent=c.textContent.substring(0,t)+a+c.textContent.substring(t)}else{if(re.isTextNode(c))c.textContent=c.textContent.substring(0,h)+a+c.textContent.substring(h);if(re.isTextNode(u))u.textContent=u.textContent.substring(0,f)+a+u.textContent.substring(f)}return{anchorNodeId:c.id,focusNodeId:u.id}},o=function e(t,i,l){if(i.nodeType===3)t.setStart(i,l);else t.setStartBefore(i)},r=function e(t,i,l){if(i.nodeType===3)t.setEnd(i,l);else t.setEndBefore(i)},a=function t(i,l,n,s){var a,d,c;let h=i.ownerDocument.getElementById(n);h!==null&&h!==void 0?h:h=re.findTextNodeContainingText(i,null,l);let u=n===s?h:i.ownerDocument.getElementById(s);u!==null&&u!==void 0?u:u=re.findTextNodeContainingText(i,h,l);if(h!==u&&!(Node.DOCUMENT_POSITION_FOLLOWING&h.compareDocumentPosition(u))){const e=h;h=u;u=e}let f,m;if(re.isTextNode(h)){f=h.textContent.indexOf(l);if(f<0)f=0;else h.textContent=h.textContent.substring(0,f)+h.textContent.substring(f+l.length)}else f=0;if(re.isTextNode(u)){m=u.textContent.indexOf(l);if(m<0)m=0;else u.textContent=u.textContent.substring(0,m)+u.textContent.substring(m+l.length)}else m=0;const g=re.getWindow(i).getSelection();g.removeAllRanges();const _=i.ownerDocument.createRange();if(h)ie.__classPrivateFieldGet(this,e,"m",o).call(this,_,h,f);else _.setStart((a=i.firstChild)!==null&&a!==void 0?a:i,0);if(!u){u=(d=re.getVeryLastNodeOf(i))!==null&&d!==void 0?d:i;m=(c=u.textContent.length)!==null&&c!==void 0?c:0}ie.__classPrivateFieldGet(this,e,"m",r).call(this,_,u,m);g.addRange(_)},d=function e(t,i){t=Math.max(0,se.forceNumber(t));i=Math.max(0,se.forceNumber(i));const l=this.getTextLength();t=Math.min(t,l);if(t+i>l){i=l-t}ne.logger.debug("ContentEditableControl.#ensureValidSelection",`returning start: ${t}, length: ${i}`);return{start:t,length:i}},c=function t(i,l,n){let s,o;const r=re.isIgnoreNode(l)||re.isCommentNode(l);if(!r){if(re.isTextNode(l)&&l.nodeValue.length>0){n+=l.nodeValue}else if(ie.__classPrivateFieldGet(this,e,"m",D).call(this,i,l)){n+=this.getLineBreakText()}else if(ie.__classPrivateFieldGet(this,e,"m",R).call(this,l)){n+=ie.__classPrivateFieldGet(this,e,"m",W).call(this)}if(l.childNodes&&l.childNodes.length>0){for(const s of l.childNodes){n=ie.__classPrivateFieldGet(this,e,"m",t).call(this,i,s,n)}}}if(i!==l){s=re.getNextValidSibling(l);if(s&&!re.isIgnoreNode(s)&&!re.isCommentNode(s)){o=re.isEmptyTextNode(s);while(o){s=re.getNextValidSibling(s);if(!s)break;o=re.isEmptyTextNode(s)}const t=r?0:ie.__classPrivateFieldGet(this,e,"m",D).call(this,i,l);if(ie.__classPrivateFieldGet(this,e,"m",L).call(this,l)){if(ie.__classPrivateFieldGet(this,e,"m",w).call(this,n))return n;if(!o)n+=this.getLineBreakText(l)}else if(!t&&!re.isEmptyTextNode(l)){if(ie.__classPrivateFieldGet(this,e,"m",L).call(this,s))n+=this.getLineBreakText(s)}}}return n},h=function t(i,l,n){const s=this.htmlElement;const o=s.ownerDocument;let r=null;let a=null;const d=this.getTextLength();if(l!==n){a=ie.__classPrivateFieldGet(this,e,"m",G).call(this,s,l,n)}if(!i||i.length===0){if(d!==this.getTextLength()){this.htmlElement.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}))}return}a!==null&&a!==void 0?a:a=ie.__classPrivateFieldGet(this,e,"m",P).call(this,s,l);r=a.node;if(!r)return;if(re.isTextNode(r)){l-=a.start;re.splitTextNode(r,l)}if(!re.isTextAllowed(r)){const e=o.createTextNode(i);if(r.nextSibling){r.parentNode.insertBefore(e,r.nextSibling)}else{r.parentNode.appendChild(e)}}else{ie.__classPrivateFieldGet(this,e,"m",b).call(this,s,r,i)}this.htmlElement.dispatchEvent(new Event("input",{bubbles:true,cancelable:true}))},u=function e(t){if(re.nodeNameEquals(t,"strong")||re.nodeNameEquals(t,"em")||re.nodeNameEquals(t,"span")||re.nodeNameEquals(t,"b")||re.nodeNameEquals(t,"i")||re.nodeNameEquals(t,"u")){return false}return true},f=function t(i,l){const n=this.htmlElement;const s=re.getWindow(n).getSelection();s.removeAllRanges();const o=n.ownerDocument;const r=o.createRange();const a=ie.__classPrivateFieldGet(this,e,"m",P).call(this,n,i);let d=i;d=d-a.start;if(re.nodeNameEquals(a.node,"br")&&d>0){const t=a.node;if(l===0&&!t.nextSibling&&!ie.__classPrivateFieldGet(this,e,"m",u).call(this,t.parentNode)){const e=n.ownerDocument;const i=e.createTextNode("");t.parentNode.appendChild(i);this.keepEmptyTextNode=true}r.setStartAfter(a.node)}else{r.setStart(a.node,d);this.keepEmptyTextNode=false}if(l===0){if(a.node.nodeName.toLowerCase()==="br"&&d>0)r.setEndAfter(a.node);else r.setEnd(a.node,d)}else{let t=Number(i)+Number(l);const s=ie.__classPrivateFieldGet(this,e,"m",P).call(this,n,t);t=Number(t)-Number(s.start);if(s.node.nodeName.toLowerCase()==="br")r.setEndAfter(s.node);else r.setEnd(s.node,t)}s.addRange(r);this.pendingSelection={start:i,length:l}},m=function t(){const i=this.htmlElement;const l=re.getWindow(i).getSelection();let n=l.anchorNode;let s=l.anchorOffset;if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,n)&&n.hasChildNodes()){if(s>=n.childNodes.length){n=n.childNodes[n.childNodes.length-1];s=ie.__classPrivateFieldGet(this,e,"m",g).call(this,n)}else{n=n.childNodes[s];s=0}}let o=ie.__classPrivateFieldGet(this,e,"m",P).call(this,i,0,n);let r=o.textBefore.length;r+=s;const a=r;let d=l.focusNode;let c=l.focusOffset;if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,d)&&d.hasChildNodes()){if(c>=d.childNodes.length){d=d.childNodes[d.childNodes.length-1];c=ie.__classPrivateFieldGet(this,e,"m",g).call(this,d)}else{d=d.childNodes[c];c=0}}o=ie.__classPrivateFieldGet(this,e,"m",P).call(this,i,0,d);let h=o.textBefore.length;h+=c;const u={};if(a>h){u.start=h;u.length=a-h}else{u.start=a;u.length=h-a}return u},g=function t(i){let l=ie.__classPrivateFieldGet(this,e,"m",c).call(this,i,i,"");l=oe.replaceAll(l," "," ");return l.length},_=function t(i){const l=i.ownerDocument.createElement("div");while(i.firstChild&&!ie.__classPrivateFieldGet(this,e,"m",ee).call(this,i.firstChild)){l.appendChild(i.firstChild)}ie.__classPrivateFieldGet(this,e,"m",E).call(this,l);i.insertBefore(l,i.firstChild);return l},v=function t(i,l,n){if(!re.getTrailingBreak(l)||!re.isIgnoreNode(l.lastChild))ie.__classPrivateFieldGet(this,e,"m",z).call(this,l);if(re.nodeNameEquals(n,"br")&&!re.isIgnoreNode(n)){if(re.isIgnoreNode(n.nextSibling))n=n.nextSibling;else{const t=ie.__classPrivateFieldGet(this,e,"m",j).call(this,i);re.insertNodeAfter(n,t);n=t}}return n},N=function t(i){if(!i||i.nextSibling)return;const l=ie.__classPrivateFieldGet(this,e,"m",O).call(this,i);if(l&&re.getVeryLastNodeOf(l)===i){ie.__classPrivateFieldGet(this,e,"m",z).call(this,l)}},p=function t(i,l){if(!ie.__classPrivateFieldGet(this,e,"m",$).call(this,i)){const t=ie.__classPrivateFieldGet(this,e,"m",_).call(this,i);if(l===i){l=t}}return l},b=function t(i,l,n){const s=l;const o=i.ownerDocument;const r=ie.__classPrivateFieldGet(this,e,"m",q).call(this,o,n,l);if(!r||r.length===0)return;l=ie.__classPrivateFieldGet(this,e,"m",p).call(this,i,l);let a;if(i===l){a=ie.__classPrivateFieldGet(this,e,"m",B).call(this,i);const t=ie.__classPrivateFieldGet(this,e,"m",k).call(this,r[r.length-1]);if(!a&&!t){a=ie.__classPrivateFieldGet(this,e,"m",z).call(this,i)}}else if(re.nodeNameEquals(r[r.length-1],"br")){ie.__classPrivateFieldGet(this,e,"m",N).call(this,l)}for(const t of r){let n=t;if(re.nodeNameEquals(n,"p"))l=ie.__classPrivateFieldGet(this,e,"m",v).call(this,o,n,l);if(a){ie.__classPrivateFieldGet(this,e,"m",K).call(this,i,i.firstChild,n);a=null}else{const t=s===l&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,l)&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,n)&&!ie.__classPrivateFieldGet(this,e,"m",Z).call(this,l);const o=t?ie.__classPrivateFieldGet(this,e,"m",K).call(this,i,l,n):ie.__classPrivateFieldGet(this,e,"m",J).call(this,i,n,l);const r=o.container;const a=o.node===o.previousNode&&r!==i&&!re.nodeNameEquals(r,"div")&&ie.__classPrivateFieldGet(this,e,"m",V).call(this,r)&&n===r.lastChild&&re.nodeNameEquals(n,"br");if(a){ie.__classPrivateFieldGet(this,e,"m",z).call(this,r)}if(o.node!==o.previousNode){n=o.previousNode}}i.dispatchEvent(new Event("change",{bubbles:true,cancelable:true}));l=n}},F=function t(i){const l=i.getElementsByTagName("br");if(l&&l.length>0){for(const t of l){const i=ie.__classPrivateFieldGet(this,e,"m",M).call(this,t);if(i){(0,de.setAttributeValue)(t,"internalIgnore","true")}else{(0,de.removeAttribute)(t,"internalIgnore")}}}},C=function t(){const i=this.htmlElement;if(!this.keepEmptyTextNode){re.removeEmptyTextNodes(i)}ie.__classPrivateFieldGet(this,e,"m",F).call(this,i)},P=function t(i,l,n){ie.__classPrivateFieldGet(this,e,"m",C).call(this);let s={start:0,end:0,node:null,textBefore:"",nodeFound:false};s=ie.__classPrivateFieldGet(this,e,"m",x).call(this,i,i,s,l,n);s.textBefore=oe.replaceAll(s.textBefore,ie.__classPrivateFieldGet(this,e,"m",I).call(this),ie.__classPrivateFieldGet(this,e,"m",y).call(this));s.textBefore=oe.replaceAll(s.textBefore,ie.__classPrivateFieldGet(this,e,"m",I).call(this,"div"),this.getNewlineFormatString());return s},x=function t(i,l,n,s,o){if(!l||n.nodeFound){return n}if(re.isCommentNode(l))return n;let r,a=n.end,d=n.end,c="",h,u,f,m;if(l===o||re.isSpanTagContainingOnlyBreakTag(l)&&l.childNodes[0]===o){n.nodeFound=true;return n}if(re.isIgnoreNode(l))return n;if(!o&&s<a){n.nodeFound=true;return n}if(l.nodeValue){c=l.nodeValue;d=a+c.length}else if(ie.__classPrivateFieldGet(this,e,"m",R).call(this,l)){if(!o&&s===a){n.nodeFound=true;return n}c=ie.__classPrivateFieldGet(this,e,"m",W).call(this);d=a+c.length}else{if(!o&&s===a&&l.nodeName==="BR"){n.nodeFound=true;return n}m=!(ie.__classPrivateFieldGet(this,e,"m",w).call(this,n.textBefore)||ie.__classPrivateFieldGet(this,e,"m",L).call(this,l.previousSibling)&&oe.endsWithLineBreak(n.textBefore));h=ie.__classPrivateFieldGet(this,e,"m",L).call(this,l);if(m&&h>0&&n.textBefore.length>0){u=!ie.__classPrivateFieldGet(this,e,"m",w).call(this,n.textBefore);if(u){n.end+=h;n.textBefore+=ie.__classPrivateFieldGet(this,e,"m",I).call(this,l);a=d=n.end}}else if(ie.__classPrivateFieldGet(this,e,"m",D).call(this,i,l)){d+=ie.__classPrivateFieldGet(this,e,"m",D).call(this,i,l);c+=this.getLineBreakText()}}if(!o&&s>=a&&s<=d){n.node=l;n.start=a;n.end=d;if(re.isTextNode(l)){n.nodeFound=true;return n}}n.end=d;n.textBefore+=c;if(l.childNodes&&l.childNodes.length>0){f=n;for(r=0;r<l.childNodes.length;++r){f=ie.__classPrivateFieldGet(this,e,"m",t).call(this,i,l.childNodes[r],f,s,o);if(f.nodeFound){return n}if(!o&&re.isTextNode(f.node)&&s>=f.start&&s<=f.end){return f}n=f}}if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,l)&&ie.__classPrivateFieldGet(this,e,"m",Z).call(this,l))m=true;else{if(ie.__classPrivateFieldGet(this,e,"m",L).call(this,l))m=!ie.__classPrivateFieldGet(this,e,"m",w).call(this,n.textBefore);else m=!(ie.__classPrivateFieldGet(this,e,"m",k).call(this,l)&&ie.__classPrivateFieldGet(this,e,"m",T).call(this,n.textBefore))}if(m&&ie.__classPrivateFieldGet(this,e,"m",L).call(this,l)){n.end+=this.getLineBreakText().length;n.textBefore+=ie.__classPrivateFieldGet(this,e,"m",I).call(this,l)}return n},G=function t(i,l,n){if(l===0){const e=this.getTextLength();if(e===n){while(i.firstChild){i.removeChild(i.firstChild)}return null}}const s=ie.__classPrivateFieldGet(this,e,"m",P).call(this,i,l);const o=ie.__classPrivateFieldGet(this,e,"m",P).call(this,i,n);const r=Number(l)-s.start;const a=Number(n)-o.start;if(s.node===o.node){s.node.nodeValue=oe.remove(s.node.nodeValue,r,a);ie.__classPrivateFieldGet(this,e,"m",S).call(this,s.node.parentNode);return s}if(s.node.nodeValue)s.node.nodeValue=s.node.nodeValue.substring(0,r);let d=[];let c=re.getNextNode(i,s.node);while(c&&c!==o.node){if(!re.isDescendant(c,o.node))d.push(c);c=re.getNextNode(i,c)}for(const e of d){e.parentNode.removeChild(e)}d=[];if(o.node.nodeValue)o.node.nodeValue=o.node.nodeValue.substring(a);else d.push(o.node);let h;if(s.node.parentNode!==o.node.parentNode){let t=ie.__classPrivateFieldGet(this,e,"m",k).call(this,s.node)?s.node:s.node.parentNode,i,l=s.node;h=o.node;while(h){if(h.previousSibling===t){i=h;l=null;break}else if(h.previousSibling===s.node){i=h;break}h=h.parentNode}if(!i){t=null;i=o.node.parentNode;h=s.node;while(h){if(h.nextSibling===i){t=h;break}h=h.parentNode}}while(d.length>0){h=d.pop();h.parentNode.removeChild(h)}if(t&&i&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,t)&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,i)){re.appendToNewParent(i,t,l);ie.__classPrivateFieldGet(this,e,"m",E).call(this,t)}}while(d.length>0){h=d.pop();h.parentNode.removeChild(h)}ie.__classPrivateFieldGet(this,e,"m",E).call(this,s.node);return s},E=function t(i){if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,i)&&!re.nodeNameEquals(i,"li")){if(!i.lastChild||!re.nodeNameEquals(i.lastChild,"br")&&!re.isIgnoreNode(i.lastChild)&&!ie.__classPrivateFieldGet(this,e,"m",L).call(this,i.lastChild)){ie.__classPrivateFieldGet(this,e,"m",z).call(this,i)}}},S=function t(i){if(!re.nodeNameEquals(i,"li"))return;if(i.textContent===""&&!re.nodeNameEquals(i.lastChild,"br")){ie.__classPrivateFieldGet(this,e,"m",z).call(this,i)}else if(i.textContent!==""&&re.nodeNameEquals(i.lastChild,"br")){i.removeChild(i.lastChild)}},T=function t(i){return ie.__classPrivateFieldGet(this,e,"m",w).call(this,i)||oe.endsWithLineBreak(i)},w=function e(t){return oe.endsWith(t,"\t")||oe.endsWith(t,"\v")},B=function e(t){if(!(t===null||t===void 0?void 0:t.hasChildNodes()))return null;let i=t;while(i.lastChild){i=i.lastChild}return i.nodeName==="BR"?i:null},q=function t(i,l,n){l=oe.replaceAll(l," "," ");l=l.replace(/^\x20|\x20$/g," ");const s=[];const o=l.split("\n");let r=null;for(let t=0;t<o.length;++t){const l=o[t].split("\f");for(let e=0;e<l.length;++e){if(l[e].length>0){const t=i.createTextNode(l[e]);if(r)r.appendChild(t);else s.push(t)}if(e<l.length-1){const e=i.createElement("P");s.push(e);r=e}}if(t<o.length-1){let t;if(re.nodeNameEquals(n.parentNode,"li")||re.nodeNameEquals(n,"li")){t=i.createElement("li");ie.__classPrivateFieldGet(this,e,"m",z).call(this,t)}else{t=i.createElement("BR")}if(r)r.appendChild(t);else s.push(t)}}return s},I=function e(t){if(se.Instance.isChromeOrEdge()){if(t&&(oe.isEqual(t,"div")||re.nodeNameEquals(t,"div")))return"\v"}return"\t"},y=function e(){return"\f"},L=function e(t){if(!t)return 0;const i=t.nodeName.toLowerCase();if(i==="div"||i==="p"||i.match("h.")||i==="table"||i==="li")return 1;if(i==="ul"||i==="ol"){if(t.parentNode&&re.nodeNameEquals(t.parentNode,"li")&&t.previousSibling)return 1}return 0},k=function e(t){if(!t)return false;return!re.isTextNode(t)&&!re.nodeNameEquals(t,"br")&&!re.nodeNameEquals(t,"img")&&!re.isCommentNode(t)},V=function t(i){if(!i)return false;const l=i.nodeName.toLowerCase();if(l==="div"||l==="p"||l==="li"||l.match("h."))return true;if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,i)&&i.nextSibling)return ie.__classPrivateFieldGet(this,e,"m",L).call(this,i.nextSibling)>0;return false},O=function t(i){if(!i)return null;let l=i.parentNode;while(l){if(ie.__classPrivateFieldGet(this,e,"m",V).call(this,l))return l;if(l===this.htmlElement)return null;l=l.parentNode}return null},A=function t(i){if(!i||i.nextSibling)return false;if(!re.nodeNameEquals(i,"br"))return false;let l=i.parentNode;while(l){if(ie.__classPrivateFieldGet(this,e,"m",V).call(this,l))return true;if(l===this.htmlElement)return false;if(l.nextSibling)return false;l=l.parentNode}return false},M=function t(i){if(se.Instance.browserBrand[ae.BrowserBrand.Mozilla]){if(re.nodeNameEquals(i.nextSibling,"p")&&!ie.__classPrivateFieldGet(this,e,"m",k).call(this,i.previousSibling))return true}if(re.nodeNameEquals(i.parentNode,"li")&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,i.nextSibling))return true;return ie.__classPrivateFieldGet(this,e,"m",A).call(this,i)},D=function t(i,l){if(!l)return 0;if(ie.__classPrivateFieldGet(this,e,"m",H).call(this,i,l))return 1;if(re.nodeNameEquals(l,"td"))return 1;return 0},R=function e(t){return re.nodeNameEquals(t,"img")},W=function e(){return String.fromCharCode(127)},H=function e(t,i){if(!i||!re.nodeNameEquals(i,"br"))return false;return!re.isIgnoreNode(i)},j=function e(t){const i=t.createElement("BR");(0,de.setAttributeValue)(i,"internalIgnore","true");return i},z=function e(t){const i=t.ownerDocument;const l=i.createElement("BR");(0,de.setAttributeValue)(l,"internalIgnore","true");t.appendChild(l);return l},$=function t(i){if(!i.firstChild)return false;let l=i.firstChild;if(re.isCommentNode(l))l=re.getNextValidSibling(l);return l&&ie.__classPrivateFieldGet(this,e,"m",k).call(this,l)},U=function t(i,l){if(!ie.__classPrivateFieldGet(this,e,"m",k).call(this,i))return false;if(re.nodeNameEquals(i,"body"))return true;if(re.nodeNameEquals(i,"div"))return true;if(re.nodeNameEquals(i,"p"))return!re.nodeNameEquals(l,"p")&&!re.nodeNameEquals(l,"div");if(re.nodeNameEquals(i,"li")){return!re.nodeNameEquals(l,"li")&&!re.nodeNameEquals(l,"p")}if(re.nodeNameEquals(i,"ul")||re.nodeNameEquals(i,"ol")){return!re.nodeNameEquals(l,"p")}return!re.nodeNameEquals(l,"p")},J=function t(i,l,n){const s=i.ownerDocument,o={};let r,a,d;o.container=i;o.node=l;o.previousNode=l;if(i===n){i.appendChild(l);return o}if(ie.__classPrivateFieldGet(this,e,"m",k).call(this,n)&&!ie.__classPrivateFieldGet(this,e,"m",k).call(this,l)){r=n;n=null}else r=n.parentNode;while(!ie.__classPrivateFieldGet(this,e,"m",U).call(this,r,l)){if(r.lastChild===n||n&&r.lastChild===n.nextSibling&&re.isIgnoreNode(n.nextSibling)){n=r;r=r.parentNode;continue}a=ie.__classPrivateFieldGet(this,e,"m",Q).call(this,r,n);n=r;r=r.parentNode}o.node=l;o.previousNode=l;let c;if(n===null||n===void 0?void 0:n.nextSibling){c=n.nextSibling;if(re.nodeNameEquals(l,"li")&&a===c&&re.nodeNameEquals(c,"li")){o.previousNode=a}else{r.insertBefore(l,n.nextSibling)}}else if(!n&&r.hasChildNodes()){c=r.firstChild;r.insertBefore(l,r.firstChild)}else{c=null;r.appendChild(l)}if(re.nodeNameEquals(l,"p")){if(a===c&&re.nodeNameEquals(c,"p")){o.previousNode=re.moveToNewParent(s,l,c);o.node=c}else if(!ie.__classPrivateFieldGet(this,e,"m",k).call(this,c)){d=ie.__classPrivateFieldGet(this,e,"m",Y).call(this,s,l,c);o.node=l;if(d)o.previousNode=d}}ie.__classPrivateFieldGet(this,e,"m",S).call(this,r);o.container=r;return o},K=function t(i,l,n){const s={};let o=l.parentNode;s.node=n;s.previousNode=n;s.container=i;if(i===l||!l){i.appendChild(n);return s}while(!ie.__classPrivateFieldGet(this,e,"m",U).call(this,o,n)){l=ie.__classPrivateFieldGet(this,e,"m",X).call(this,o,l);o=o.parentNode}if(l){o.insertBefore(n,l)}else{o.appendChild(n)}s.node=n;s.previousNode=n;s.container=o;return s},Q=function t(i,l){const n=i.ownerDocument;const s=i.nodeName;const o=n.createElement(s);if(s.toLowerCase()==="li"&&!re.isTextNode(l===null||l===void 0?void 0:l.nextSibling)){o.appendChild(n.createTextNode(" "))}if(l){let e=l.nextSibling;while(e){const t=e.nextSibling;if(!re.isEmptyTextNode(e))o.appendChild(e);e=t}}if(i.nextSibling)i.parentNode.insertBefore(o,i.nextSibling);else i.parentNode.appendChild(o);ie.__classPrivateFieldGet(this,e,"m",E).call(this,i);ie.__classPrivateFieldGet(this,e,"m",E).call(this,o);ie.__classPrivateFieldGet(this,e,"m",E).call(this,l.parentNode);ie.__classPrivateFieldGet(this,e,"m",S).call(this,i);return o},X=function t(i,l){const n=i.ownerDocument;const s=n.createElement(i.nodeName);if(l){s.appendChild(l);let e=l.nextSibling;while(e){if(!re.isEmptyTextNode(e))s.appendChild(e);e=e.nextSibling}}if(i.nextSibling)i.parentNode.insertBefore(s,i.nextSibling);else i.parentNode.appendChild(s);ie.__classPrivateFieldGet(this,e,"m",E).call(this,i);ie.__classPrivateFieldGet(this,e,"m",E).call(this,s);return s},Y=function t(i,l,n){let s=false,o=false,r,a,d;const c=[];if(l===l.parentNode.firstChild)return null;r=l.previousSibling;while(r){if(!re.isEmptyTextNode(r)){o=true;break}r=r.previousSibling}if(!o)return null;r=null;if(n&&re.nodeNameEquals(l,"p")){if(re.isIgnoreNode(l.lastChild)&&re.nodeNameEquals(l.lastChild,"br")){a=l.lastChild}while(n&&ie.__classPrivateFieldGet(this,e,"m",U).call(this,l,n)){d=n;n=n.nextSibling;if(a){if(re.isIgnoreNode(d)&&re.nodeNameEquals(d,"br"))c.push(d);else l.insertBefore(d,a)}else{l.appendChild(d)}s=true;r!==null&&r!==void 0?r:r=d.previousSibling}for(const e of c)e.parentNode.removeChild(e)}if(s){if(!r){const e=i.createTextNode("");l.insertBefore(e,l.firstChild);r=e}}return r},Z=function e(t){if(!t.hasChildNodes())return true;if(t.childNodes.length===1&&re.isIgnoreNode(t.childNodes[0]))return true;for(const e of t.childNodes){if(re.isEmptyTextNode(e)||re.isIgnoreNode(e))continue;return false}return true},ee=function e(t){return ie.__classPrivateFieldGet(this,te,"f").has(t.nodeName.toLowerCase())};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
import type { CustomControlInitializer } from "../webtcl";
|
|
3
|
+
import type { Capabilities, TextControl } from "./text-control";
|
|
4
|
+
import type { ProcessingStatus } from "./processing-status";
|
|
5
|
+
import type { CustomControlState } from "../webtcl/custom-controls";
|
|
6
|
+
import type { AdditionalReplaceTextParameters } from "../webtcl/types";
|
|
7
|
+
export declare class CustomControl implements TextControl {
|
|
8
|
+
#private;
|
|
9
|
+
readonly state$: Observable<CustomControlState>;
|
|
10
|
+
readonly processingStatus$: Observable<ProcessingStatus>;
|
|
11
|
+
readonly type: string;
|
|
12
|
+
htmlElement: HTMLElement;
|
|
13
|
+
constructor(htmlElement: HTMLElement, initializer: CustomControlInitializer);
|
|
14
|
+
get newlineFormat(): string;
|
|
15
|
+
get paragraphFormat(): string;
|
|
16
|
+
get isMultiline(): boolean;
|
|
17
|
+
get capabilities(): Capabilities | undefined;
|
|
18
|
+
onFocus(): void;
|
|
19
|
+
onBlur(): void;
|
|
20
|
+
onElementFocus(_e: Event | null): void;
|
|
21
|
+
cleanup(): void;
|
|
22
|
+
invalidate(): void;
|
|
23
|
+
isValid(): boolean;
|
|
24
|
+
get guid(): string | null;
|
|
25
|
+
setGuid(guid: string): void;
|
|
26
|
+
get conceptName(): string | undefined;
|
|
27
|
+
get dictationMode(): string | undefined;
|
|
28
|
+
get documentFieldId(): string | undefined;
|
|
29
|
+
getProcessingStatus(): ProcessingStatus;
|
|
30
|
+
setProcessingStatus(status: ProcessingStatus): void;
|
|
31
|
+
getText(): string;
|
|
32
|
+
setText(text: string): void;
|
|
33
|
+
replaceText(text: string, start: number, length: number, additionalParameters?: AdditionalReplaceTextParameters): boolean;
|
|
34
|
+
getSelection(): {
|
|
35
|
+
start: number;
|
|
36
|
+
length: number;
|
|
37
|
+
};
|
|
38
|
+
setSelection(start: number, length: number): void;
|
|
39
|
+
undo(): void;
|
|
40
|
+
redo(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,s,i,l;Object.defineProperty(exports,"__esModule",{value:true});exports.CustomControl=void 0;const a=require("tslib");const n=require("rxjs");const r=require("../webtcl/webtcl-attributes");class u{constructor(r,u){e.set(this,new n.BehaviorSubject({text:"",selection:{start:0,end:0},focus:false}));this.state$=a.__classPrivateFieldGet(this,e,"f").pipe((0,n.skip)(1));t.set(this,new n.BehaviorSubject("idle"));this.processingStatus$=a.__classPrivateFieldGet(this,t,"f").asObservable();this.type="custom";s.set(this,void 0);i.set(this,void 0);l.set(this,new n.Subject);const d=new n.Subject;const o=[];a.__classPrivateFieldSet(this,s,{newline:"\n",paragraph:"\n\n",isMultiline:false,handle:(e,t)=>{o.push(a.__classPrivateFieldGet(this,l,"f").subscribe(s=>{if(s.type===e){t(s.payload)}}))},update:e=>{d.next(e)}},"f");const c=d.pipe((0,n.withLatestFrom)(a.__classPrivateFieldGet(this,e,"f"))).subscribe(([t,s])=>a.__classPrivateFieldGet(this,e,"f").next(Object.assign(Object.assign({},s),t)));const h=u(r,a.__classPrivateFieldGet(this,s,"f"));a.__classPrivateFieldSet(this,i,()=>{h();c.unsubscribe();o.forEach(e=>e.unsubscribe())},"f");this.htmlElement=r}get newlineFormat(){return a.__classPrivateFieldGet(this,s,"f").newline}get paragraphFormat(){return a.__classPrivateFieldGet(this,s,"f").paragraph}get isMultiline(){return a.__classPrivateFieldGet(this,s,"f").isMultiline}get capabilities(){return a.__classPrivateFieldGet(this,s,"f").capabilities}onFocus(){a.__classPrivateFieldGet(this,l,"f").next({type:"focus",payload:true})}onBlur(){a.__classPrivateFieldGet(this,l,"f").next({type:"focus",payload:false})}onElementFocus(e){}cleanup(){}invalidate(){var e;(e=a.__classPrivateFieldGet(this,i,"f"))===null||e===void 0?void 0:e.call(this);this.htmlElement=null}isValid(){return!!this.htmlElement}get guid(){return(0,r.getAttributeValue)(this.htmlElement,"controlId")}setGuid(e){(0,r.setAttributeValue)(this.htmlElement,"controlId",e)}get conceptName(){var e;return(e=(0,r.getAttributeValue)(this.htmlElement,"conceptName"))!==null&&e!==void 0?e:undefined}get dictationMode(){var e;return(e=(0,r.getAttributeValue)(this.htmlElement,"dictationMode"))!==null&&e!==void 0?e:undefined}get documentFieldId(){var e;return(e=(0,r.getAttributeValue)(this.htmlElement,"documentFieldId"))!==null&&e!==void 0?e:undefined}getProcessingStatus(){return a.__classPrivateFieldGet(this,t,"f").value}setProcessingStatus(e){if(e!==this.getProcessingStatus()){a.__classPrivateFieldGet(this,t,"f").next(e)}}getText(){return a.__classPrivateFieldGet(this,e,"f").value.text}setText(e){a.__classPrivateFieldGet(this,l,"f").next({type:"text",payload:{value:e,start:0,length:e.length}})}replaceText(e,t,s,i){a.__classPrivateFieldGet(this,l,"f").next({type:"text",payload:{value:e,start:t,length:s,additionalParameters:i}});return true}getSelection(){var t,s,i,l;const n=(s=(t=a.__classPrivateFieldGet(this,e,"f").value.selection)===null||t===void 0?void 0:t.start)!==null&&s!==void 0?s:0;const r=(l=(i=a.__classPrivateFieldGet(this,e,"f").value.selection)===null||i===void 0?void 0:i.end)!==null&&l!==void 0?l:0;return{start:n,length:r-n}}setSelection(e,t){a.__classPrivateFieldGet(this,l,"f").next({type:"selection",payload:{start:e,end:e+t}})}undo(){a.__classPrivateFieldGet(this,l,"f").next({type:"undo",payload:undefined})}redo(){a.__classPrivateFieldGet(this,l,"f").next({type:"redo",payload:undefined})}}exports.CustomControl=u;e=new WeakMap,t=new WeakMap,s=new WeakMap,i=new WeakMap,l=new WeakMap;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextControl } from "./text-control";
|
|
2
|
+
import type { CustomControlCollection } from "../webtcl/custom-controls";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a text control based on the given element.
|
|
5
|
+
*
|
|
6
|
+
* @param element - The HTML element to create the text control from.
|
|
7
|
+
* @returns The created text control, or null if the element is invalid or unsupported.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTextControl(element: HTMLElement, customControls?: CustomControlCollection): TextControl | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createTextControl=c;const t=require("./input-control");const e=require("./textarea-control");const n=require("./contenteditable-control");const r=require("./tinymce-control");const o=require("./helpers");const i=require("../webtcl/validation");const u=require("./custom-control");function c(c,l={}){if(!c){return null}const s=(0,o.getCustomControlType)(c);if(s){const t=l[s];if(t&&typeof t==="function"){return new u.CustomControl(c,t)}}if(c instanceof HTMLInputElement&&(0,i.isSupportedHtmlInputElement)(c)){return new t.InputControl(c)}if(c instanceof HTMLTextAreaElement){return new e.TextAreaControl(c)}const a=(0,o.getTinyMceEditor)(c);if(a){return new r.TinyMceControl(a)}if(c.contentEditable==="true"){return new n.ContentEditableControl(c)}return null}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param element
|
|
3
|
+
* @return {?string}
|
|
4
|
+
* @function
|
|
5
|
+
*/
|
|
6
|
+
export function getCustomContainerType(element: any): string | null;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param element
|
|
10
|
+
* @return {?string}
|
|
11
|
+
* @function
|
|
12
|
+
*/
|
|
13
|
+
export function getCustomControlType(element: any): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* get the container id of the customControl
|
|
16
|
+
* @param {HTMLElement} element
|
|
17
|
+
* @returns {string|null}
|
|
18
|
+
*/
|
|
19
|
+
export function getCustomContainerId(element: HTMLElement): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* get the container of the customControl
|
|
22
|
+
* @param element
|
|
23
|
+
* @return {HTMLElement|null}
|
|
24
|
+
* @function
|
|
25
|
+
*/
|
|
26
|
+
export function getCustomControlContainer(element: any): HTMLElement | null;
|
|
27
|
+
/**
|
|
28
|
+
* get the tinymce editor if element is a tinymce control
|
|
29
|
+
* @param element
|
|
30
|
+
* @return {unknown | null} returns tinymce editor if element is a tinymce control, otherwise null.
|
|
31
|
+
* @function
|
|
32
|
+
*/
|
|
33
|
+
export function getTinyMceEditor(element: any): unknown | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCustomContainerType=o;exports.getCustomControlType=r;exports.getCustomContainerId=u;exports.getCustomControlContainer=i;exports.getTinyMceEditor=l;const t=require("../logger/logging");const e=require("../shared-data");const n=require("../webtcl/webtcl-attributes");function o(t){const n=t===null||t===void 0?void 0:t.getAttribute(e.Attr_CustomContainerType);return n!==null&&n!==void 0?n:null}function r(t){if(!t){return null}return(0,n.getAttributeValue)(t,"customControlType")}function u(t){const n=t===null||t===void 0?void 0:t.getAttribute(e.Attr_CustomContainerId);return n!==null&&n!==void 0?n:null}function i(t){const n=u(t);return n?e.SharedData.activeDocument.getElementById(n):null}function l(e){if(typeof tinymce==="undefined")return null;for(const n of tinymce.get()){if(e.nodeName=="IFRAME"&&n.getContentAreaContainer().contains(e)){t.logger.debug("helpers:getTinyMceEditor","TinyMCE control found:",e.tagName,e.id);return n}if(n.getBody()===e){t.logger.debug("helpers:getTinyMceEditor","TinyMCE control found:",e.tagName,e.id);return n}}return null}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { TextControl } from "./text-control";
|
|
2
|
+
export { createTextControl } from "./factory";
|
|
3
|
+
export { getTinyMceEditor, getCustomControlType, getCustomContainerType, getCustomControlContainer } from "./helpers";
|
|
4
|
+
export type { ProcessingStatus } from "./processing-status";
|
|
5
|
+
export { TextControlManager, textControlManager } from "./text-control-manager";
|
|
6
|
+
export { CustomControl } from "./custom-control";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CustomControl=exports.textControlManager=exports.TextControlManager=exports.getCustomControlContainer=exports.getCustomContainerType=exports.getCustomControlType=exports.getTinyMceEditor=exports.createTextControl=void 0;var e=require("./factory");Object.defineProperty(exports,"createTextControl",{enumerable:true,get:function(){return e.createTextControl}});var t=require("./helpers");Object.defineProperty(exports,"getTinyMceEditor",{enumerable:true,get:function(){return t.getTinyMceEditor}});Object.defineProperty(exports,"getCustomControlType",{enumerable:true,get:function(){return t.getCustomControlType}});Object.defineProperty(exports,"getCustomContainerType",{enumerable:true,get:function(){return t.getCustomContainerType}});Object.defineProperty(exports,"getCustomControlContainer",{enumerable:true,get:function(){return t.getCustomControlContainer}});var r=require("./text-control-manager");Object.defineProperty(exports,"TextControlManager",{enumerable:true,get:function(){return r.TextControlManager}});Object.defineProperty(exports,"textControlManager",{enumerable:true,get:function(){return r.textControlManager}});var o=require("./custom-control");Object.defineProperty(exports,"CustomControl",{enumerable:true,get:function(){return o.CustomControl}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.InputControl=void 0;const t=require("./base-control");class e extends t.BaseControl{constructor(t){super(t);this.type="Input";this.isMultiline=false}}exports.InputControl=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProcessingStatus = "pending" | "idle";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TextControl } from "./text-control";
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export declare class TextControlManager {
|
|
6
|
+
#private;
|
|
7
|
+
get textControlCount(): number;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {TextControl} textControl
|
|
11
|
+
* @param {string|null} controlId
|
|
12
|
+
* @return {string} the controlId
|
|
13
|
+
*/
|
|
14
|
+
addTextControl(textControl: TextControl, controlId?: string, containerId?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* returns a copy of the textControls
|
|
17
|
+
* @return {TextControl[]}
|
|
18
|
+
*/
|
|
19
|
+
getTextControls(): TextControl[];
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param controlId
|
|
23
|
+
* @return {TextControl|null}
|
|
24
|
+
*/
|
|
25
|
+
getTextControl(controlId: string): TextControl | null;
|
|
26
|
+
/** @returns {TextControl|null} */
|
|
27
|
+
getFirstTextControl(): TextControl | null;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param element
|
|
31
|
+
* @return {TextControl|null}
|
|
32
|
+
*/
|
|
33
|
+
getTextControlByElement(element: HTMLElement): TextControl | null;
|
|
34
|
+
removeTextControl(controlId: string): boolean;
|
|
35
|
+
removeAll(): void;
|
|
36
|
+
getContainers(): Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
export declare const textControlManager: TextControlManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t;Object.defineProperty(exports,"__esModule",{value:true});exports.textControlManager=exports.TextControlManager=void 0;const r=require("tslib");const s=r.__importStar(require("../common/util"));const i=r.__importStar(require("../common/string"));const l=require("../webtcl/webtcl-attributes");class a{constructor(){e.set(this,new Map);t.set(this,new Map)}get textControlCount(){return r.__classPrivateFieldGet(this,e,"f").size}addTextControl(l,a="",n=""){if(i.isEmpty(a))a=s.Instance.createGuid();l.setGuid(a);r.__classPrivateFieldGet(this,t,"f").set(a,n);r.__classPrivateFieldGet(this,e,"f").set(a,l);return a}getTextControls(){return Array.from(r.__classPrivateFieldGet(this,e,"f").values())}getTextControl(t){var s;return(s=r.__classPrivateFieldGet(this,e,"f").get(t))!==null&&s!==void 0?s:null}getFirstTextControl(){const t=r.__classPrivateFieldGet(this,e,"f").values().next();return!t.done?t.value:null}getTextControlByElement(t){var s;const i=(0,l.getAttributeValue)(t,"controlId");if(!i){return null}return(s=r.__classPrivateFieldGet(this,e,"f").get(i))!==null&&s!==void 0?s:null}removeTextControl(s){var i;(i=r.__classPrivateFieldGet(this,e,"f").get(s))===null||i===void 0?void 0:i.invalidate();r.__classPrivateFieldGet(this,t,"f").delete(s);return r.__classPrivateFieldGet(this,e,"f").delete(s)}removeAll(){r.__classPrivateFieldGet(this,t,"f").clear();r.__classPrivateFieldGet(this,e,"f").forEach(e=>e.invalidate());r.__classPrivateFieldGet(this,e,"f").clear()}getContainers(){const e={};for(const[s,i]of r.__classPrivateFieldGet(this,t,"f").entries()){e[s]=i}return e}}exports.TextControlManager=a;e=new WeakMap,t=new WeakMap;exports.textControlManager=new a;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ProcessingStatus } from "./processing-status";
|
|
2
|
+
import type { AdditionalReplaceTextParameters } from "../webtcl/types";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the set of additional capabilities supported by some text-controls.
|
|
5
|
+
*
|
|
6
|
+
* @property undoRedo - Indicates whether undo and redo operations are supported.
|
|
7
|
+
*/
|
|
8
|
+
export type UndoableControl = {
|
|
9
|
+
undo(): void;
|
|
10
|
+
redo(): void;
|
|
11
|
+
} & TextControl;
|
|
12
|
+
/**
|
|
13
|
+
* Represents the set of additional/custom features supported by a text control.
|
|
14
|
+
*
|
|
15
|
+
* @property undoRedo - Indicates whether undo and redo functionality is available.
|
|
16
|
+
*/
|
|
17
|
+
export type Capabilities = {
|
|
18
|
+
undoRedo: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* TextControl interface.
|
|
22
|
+
* Contains all public members used in SpeechDocument.
|
|
23
|
+
* DO NOT extend this type!
|
|
24
|
+
*/
|
|
25
|
+
export type TextControl = {
|
|
26
|
+
readonly type: string;
|
|
27
|
+
readonly guid: string | null;
|
|
28
|
+
readonly htmlElement: HTMLElement;
|
|
29
|
+
readonly newlineFormat: string;
|
|
30
|
+
readonly paragraphFormat: string;
|
|
31
|
+
readonly conceptName: string | undefined;
|
|
32
|
+
readonly dictationMode: string | undefined;
|
|
33
|
+
readonly documentFieldId: string | undefined;
|
|
34
|
+
readonly isMultiline: boolean;
|
|
35
|
+
readonly capabilities?: Capabilities;
|
|
36
|
+
onFocus: ((e: FocusEvent) => void) | null;
|
|
37
|
+
onBlur: ((e: FocusEvent) => void) | null;
|
|
38
|
+
onElementFocus(e: Event | null): void;
|
|
39
|
+
invalidate(): void;
|
|
40
|
+
isValid(): boolean;
|
|
41
|
+
cleanup(initial: boolean): void;
|
|
42
|
+
setGuid(guid: string): void;
|
|
43
|
+
getText(): string;
|
|
44
|
+
replaceText(text: string, start: number, length: number, additionalParameters?: AdditionalReplaceTextParameters): boolean;
|
|
45
|
+
setText(text: string): void;
|
|
46
|
+
getSelection(): {
|
|
47
|
+
start: number;
|
|
48
|
+
length: number;
|
|
49
|
+
};
|
|
50
|
+
setSelection(start: number, length: number): void;
|
|
51
|
+
getProcessingStatus(): ProcessingStatus;
|
|
52
|
+
setProcessingStatus(status: ProcessingStatus): void;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Determines whether the given `TextControl` implements the `UndoableControl` interface.
|
|
56
|
+
*
|
|
57
|
+
* This function checks if the control has the `undoRedo` capability enabled and
|
|
58
|
+
* verifies that both `undo` and `redo` methods are present and are functions.
|
|
59
|
+
* If the capability or methods are missing, a warning is logged.
|
|
60
|
+
*
|
|
61
|
+
* @param control - The `TextControl` instance to check.
|
|
62
|
+
* @returns `true` if the control implements `UndoableControl`, otherwise `false`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isUndoableControl(control: TextControl): control is UndoableControl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isUndoableControl=n;const o=require("../logger/logging");function n(n){var e;if(!((e=n.capabilities)===null||e===void 0?void 0:e.undoRedo)){o.logger.warning("isUndoableControl","undoReo capability not set");return false}const r="undo"in n&&typeof n.undo==="function"&&"redo"in n&&typeof n.redo==="function";if(!r){o.logger.warning("isUndoableControl","undo or redo function not provided by control")}return r}
|