@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 @@
|
|
|
1
|
+
import{logger as t}from"../logger/logging";import{Attr_CustomContainerId as e,Attr_CustomContainerType as n,SharedData as o}from"../shared-data";import{getAttributeValue as r}from"../webtcl/webtcl-attributes";export function getCustomContainerType(t){const e=t===null||t===void 0?void 0:t.getAttribute(n);return e!==null&&e!==void 0?e:null}export function getCustomControlType(t){if(!t){return null}return r(t,"customControlType")}export function getCustomContainerId(t){const n=t===null||t===void 0?void 0:t.getAttribute(e);return n!==null&&n!==void 0?n:null}export function getCustomControlContainer(t){const e=getCustomContainerId(t);return e?o.activeDocument.getElementById(e):null}export function getTinyMceEditor(e){if(typeof tinymce==="undefined")return null;for(const n of tinymce.get()){if(e.nodeName=="IFRAME"&&n.getContentAreaContainer().contains(e)){t.debug("helpers:getTinyMceEditor","TinyMCE control found:",e.tagName,e.id);return n}if(n.getBody()===e){t.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
|
+
export{createTextControl}from"./factory";export{getTinyMceEditor,getCustomControlType,getCustomContainerType,getCustomControlContainer}from"./helpers";export{TextControlManager,textControlManager}from"./text-control-manager";export{CustomControl}from"./custom-control";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BaseControl as t}from"./base-control";export class InputControl extends t{constructor(t){super(t);this.type="Input";this.isMultiline=false}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProcessingStatus = "pending" | "idle";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -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
|
+
var t,e;import{__classPrivateFieldGet as r}from"tslib";import*as o from"../common/util";import*as n from"../common/string";import{getAttributeValue as s}from"../webtcl/webtcl-attributes";export class TextControlManager{constructor(){t.set(this,new Map);e.set(this,new Map)}get textControlCount(){return r(this,t,"f").size}addTextControl(s,l="",i=""){if(n.isEmpty(l))l=o.Instance.createGuid();s.setGuid(l);r(this,e,"f").set(l,i);r(this,t,"f").set(l,s);return l}getTextControls(){return Array.from(r(this,t,"f").values())}getTextControl(e){var o;return(o=r(this,t,"f").get(e))!==null&&o!==void 0?o:null}getFirstTextControl(){const e=r(this,t,"f").values().next();return!e.done?e.value:null}getTextControlByElement(e){var o;const n=s(e,"controlId");if(!n){return null}return(o=r(this,t,"f").get(n))!==null&&o!==void 0?o:null}removeTextControl(o){var n;(n=r(this,t,"f").get(o))===null||n===void 0?void 0:n.invalidate();r(this,e,"f").delete(o);return r(this,t,"f").delete(o)}removeAll(){r(this,e,"f").clear();r(this,t,"f").forEach(t=>t.invalidate());r(this,t,"f").clear()}getContainers(){const t={};for(const[o,n]of r(this,e,"f").entries()){t[o]=n}return t}}t=new WeakMap,e=new WeakMap;export const textControlManager=new TextControlManager;
|
|
@@ -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
|
+
import{logger as o}from"../logger/logging";export function isUndoableControl(n){var i;if(!((i=n.capabilities)===null||i===void 0?void 0:i.undoRedo)){o.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.warning("isUndoableControl","undo or redo function not provided by control")}return r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BaseControl as t}from"./base-control";export class TextAreaControl extends t{constructor(t){super(t);this.type="TextArea"}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TinyMCE control class
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export class TinyMceControl extends ContentEditableControl {
|
|
6
|
+
tinyMceIframe: any;
|
|
7
|
+
tinyMceEditor: any;
|
|
8
|
+
adjustScrollPosition(): void;
|
|
9
|
+
#private;
|
|
10
|
+
}
|
|
11
|
+
import { ContentEditableControl } from "./contenteditable-control";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t,e,n;import{__classPrivateFieldGet as i}from"tslib";import{ContentEditableControl as o}from"./contenteditable-control";import{logger as c}from"../logger/logging";export class TinyMceControl extends o{constructor(e){super(e.getBody());t.add(this);this.tinyMceIframe=e.iframeElement;this.type="TinyMCE";this.tinyMceEditor=e}replaceText(t,e,n){this.tinyMceEditor.undoManager.beforeChange();const i=super.replaceText(t,e,n);if(this.htmlElement.childElementCount===0){this.htmlElement.innerHTML="<p><br></p>"}return i}setSelection(t=0,e=0){super.setSelection(t,e);this.tinyMceEditor.undoManager.add()}getSelectionCoordinates(){if(this.tinyMceIframe){const t=this.tinyMceIframe.getBoundingClientRect();const e=this.tinyMceIframe.contentWindow.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0).getBoundingClientRect();return{left:t.left+n.left,top:t.top+n.top,right:t.left+n.right,bottom:t.top+n.bottom}}return super.getSelectionCoordinates()}adjustScrollPosition(){try{if(!i(this,t,"m",n).call(this)){this.tinyMceEditor.getContainer().scrollIntoView()}const o=i(this,t,"m",e).call(this);const c=this.tinyMceEditor.getWin();const r=c.document.documentElement;if(!r||!o)return;const s=r.scrollTop;const l=s+r.clientHeight;const d=o.top+s;const g=o.bottom+s;if(d<s){c.scrollTo(0,d)}else if(g>l){const t=g-r.clientHeight;c.scrollTo(0,t)}}catch(t){c.error("TinyMceControl.adjustScrollPosition","Error adjusting scroll position",t)}}}t=new WeakSet,e=function t(){let e=this.tinyMceEditor.selection.getBoundingClientRect();if(!e){if(this.tinyMceEditor.selection.isCollapsed()){c.debug("TinyMceControl.#getBoundingClientRectOfEditor","rect is undefined, expanding selection to get rect");const t=this.tinyMceEditor.selection.getRng();this.tinyMceEditor.selection.expand();e=this.tinyMceEditor.selection.getBoundingClientRect();this.tinyMceEditor.selection.collapse(t.startContainer,t.startOffset)}if(!e){c.debug("TinyMceControl.#getBoundingClientRectOfEditor","Could not adjust scroll position as rect is undefined")}}return e},n=function t(){if(!this.tinyMceEditor)return false;const e=document.getElementById(this.tinyMceEditor.id).clientHeight;const n=this.tinyMceEditor.getContainer();const i=n.getBoundingClientRect();const o=0;const c=window.innerHeight||document.documentElement.clientHeight;const r=i.top>=o&&i.top<=c;const s=i.bottom>=o&&i.bottom<=c;const l=e>window.innerHeight;return r&&s||l};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type NextObserver, type Observable } from "rxjs";
|
|
2
|
+
export type Typed<TMap> = {
|
|
3
|
+
[K in keyof TMap]: {
|
|
4
|
+
type: K;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export type ChannelSender<TMessageMap extends Typed<TMessageMap>> = {
|
|
8
|
+
send(this: void, message: TMessageMap[keyof TMessageMap]): void;
|
|
9
|
+
};
|
|
10
|
+
export type ChannelReceiver<TMessageMap extends Typed<TMessageMap>> = {
|
|
11
|
+
receiveAll(this: void): Observable<TMessageMap[keyof TMessageMap]>;
|
|
12
|
+
receive<K extends keyof TMessageMap>(this: void, type: K): Observable<TMessageMap[K]>;
|
|
13
|
+
};
|
|
14
|
+
export declare function channelSender<TMessageMap extends Typed<TMessageMap>>(value: NextObserver<TMessageMap[keyof TMessageMap]>): ChannelSender<TMessageMap>;
|
|
15
|
+
export declare function channelReceiver<TMessageMap extends Typed<TMessageMap>>(value$: Observable<TMessageMap[keyof TMessageMap]>): ChannelReceiver<TMessageMap>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{filter as e}from"rxjs";export function channelSender(e){return{send(r){e.next(r)}}}export function channelReceiver(r){return{receiveAll(){return r},receive(n){return r.pipe(e(e=>e.type===n))}}}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ProcessingStatus } from "./processing-status";
|
|
2
|
+
import type { AdditionalReplaceTextParameters } from "./types";
|
|
3
|
+
type CommandMap = {
|
|
4
|
+
initialize: {
|
|
5
|
+
isDisabled: boolean;
|
|
6
|
+
useGuiMarkup: boolean;
|
|
7
|
+
};
|
|
8
|
+
dispose: undefined;
|
|
9
|
+
focus: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
activate: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
deactivate: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
selectNode: {
|
|
19
|
+
id: string;
|
|
20
|
+
shouldFocus: boolean;
|
|
21
|
+
};
|
|
22
|
+
setStatus: {
|
|
23
|
+
id: string;
|
|
24
|
+
status: ProcessingStatus;
|
|
25
|
+
};
|
|
26
|
+
replaceText: {
|
|
27
|
+
id: string;
|
|
28
|
+
text: string;
|
|
29
|
+
selection: {
|
|
30
|
+
start: number;
|
|
31
|
+
length: number;
|
|
32
|
+
};
|
|
33
|
+
additionalParameters?: AdditionalReplaceTextParameters;
|
|
34
|
+
};
|
|
35
|
+
setSelection: {
|
|
36
|
+
id: string;
|
|
37
|
+
selection: {
|
|
38
|
+
start: number;
|
|
39
|
+
length: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
setText: {
|
|
43
|
+
id: string;
|
|
44
|
+
text: string;
|
|
45
|
+
};
|
|
46
|
+
setRecordingState: {
|
|
47
|
+
state: "started" | "stopped";
|
|
48
|
+
};
|
|
49
|
+
undo: {
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
redo: {
|
|
53
|
+
id: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export type WebTCLCommands = {
|
|
57
|
+
[K in keyof CommandMap]: CommandMap[K] extends undefined ? {
|
|
58
|
+
type: K;
|
|
59
|
+
} : {
|
|
60
|
+
type: K;
|
|
61
|
+
} & CommandMap[K];
|
|
62
|
+
};
|
|
63
|
+
export type WebTCLCommand = WebTCLCommands[keyof WebTCLCommands];
|
|
64
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { Capabilities } from "../../text-control-lib/text-control";
|
|
2
|
+
import type { AdditionalReplaceTextParameters } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* A command indicates what changed on the custom-control
|
|
5
|
+
*/
|
|
6
|
+
export type CustomControlCommand = {
|
|
7
|
+
/**
|
|
8
|
+
* The text to replace.
|
|
9
|
+
*/
|
|
10
|
+
text: {
|
|
11
|
+
value: string;
|
|
12
|
+
start: number;
|
|
13
|
+
length: number;
|
|
14
|
+
additionalParameters?: AdditionalReplaceTextParameters;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The selection of the text.
|
|
18
|
+
*/
|
|
19
|
+
selection: {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Indicates if the custom-control should be focused or not.
|
|
25
|
+
*/
|
|
26
|
+
focus: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Forwards the undo voice command to the custom control.
|
|
29
|
+
*/
|
|
30
|
+
undo: undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Forwards the redo voice command to the custom control.
|
|
33
|
+
*/
|
|
34
|
+
redo: undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Represents the state of a custom control.
|
|
38
|
+
*/
|
|
39
|
+
export type CustomControlState = {
|
|
40
|
+
/**
|
|
41
|
+
* The text content of the custom-control
|
|
42
|
+
*/
|
|
43
|
+
text: string;
|
|
44
|
+
/**
|
|
45
|
+
* The selection of the text
|
|
46
|
+
*/
|
|
47
|
+
selection: {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Indicates if the custom-control has the focus or not.
|
|
53
|
+
*/
|
|
54
|
+
focus: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Custom Control
|
|
58
|
+
*/
|
|
59
|
+
export interface CustomControl {
|
|
60
|
+
/**
|
|
61
|
+
* Used to synchronize changes from the {@link CustomControl} with the {@link HTMLElement}
|
|
62
|
+
* @param type {@link CustomControlCommand} indicates what changed
|
|
63
|
+
* @param action The function to execute for the given {@param type}
|
|
64
|
+
*/
|
|
65
|
+
handle<K extends keyof CustomControlCommand>(type: K, action: (command: CustomControlCommand[K]) => void): void;
|
|
66
|
+
/**
|
|
67
|
+
* Used to synchronize changes from the {@link HTMLElement} with the {@link CustomControl}
|
|
68
|
+
* @param changes indicates what changed
|
|
69
|
+
*/
|
|
70
|
+
update(changes: Partial<CustomControlState>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Defines new line characters
|
|
73
|
+
* @default "\n"
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* function(element: HTMLElement, control: CustomControl) {
|
|
77
|
+
* control.newline = "\n";
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
newline: string;
|
|
82
|
+
/**
|
|
83
|
+
* Defines paragraph characters
|
|
84
|
+
* @default "\n\n"
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* function (element: HTMLElement, control: CustomControl) {
|
|
88
|
+
* control.paragraph = "\n\n";
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
paragraph: string;
|
|
93
|
+
/**
|
|
94
|
+
* Indicates if the control is multiline or not
|
|
95
|
+
* @default false
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* function (element: HTMLElement, control: CustomControl) {
|
|
99
|
+
* control.isMultiline = true;
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
isMultiline: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Represents the set of additional/custom features supported by a custom control.
|
|
106
|
+
*
|
|
107
|
+
* @property undoRedo - Indicates whether undo and redo functionality is available.
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* function (element: HTMLElement, control: CustomControl) {
|
|
111
|
+
* control.capabilities = {
|
|
112
|
+
* undoRedo: true
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
capabilities?: Capabilities;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Binds {@link HTMLElement} to {@link CustomControl}, synchronizing their state.
|
|
121
|
+
* Changes happened in {@link HTMLElement} are propagate to {@link CustomControl}, and vice-versa.
|
|
122
|
+
* - Initializes {@link CustomControl} with initial state of {@link HTMLElement}
|
|
123
|
+
* - Set event handlers from {@link CustomControl}, applying changes to {@link HTMLElement}
|
|
124
|
+
* - Set event handlers from {@link HTMLElement}, applying changes to {@link CustomControl}
|
|
125
|
+
* - Return a function to disconnect {@link HTMLElement} and {@link CustomControl}.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* const customInput: CustomControlInitializer = (element, control) => {
|
|
130
|
+
* if (!(element instanceof HTMLInputElement)) {
|
|
131
|
+
* throw new Error("Element is not an input element");
|
|
132
|
+
* }
|
|
133
|
+
*
|
|
134
|
+
* // configure the custom control
|
|
135
|
+
* control.update({
|
|
136
|
+
* newline: "\n",
|
|
137
|
+
* paragraph: "\n\n",
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* const updateCustomControl = () => {
|
|
141
|
+
* control.update({
|
|
142
|
+
* text: element.value,
|
|
143
|
+
* selection: {
|
|
144
|
+
* start: element.selectionStart ?? 0,
|
|
145
|
+
* length: (element.selectionEnd ?? 0) - (element.selectionStart ?? 0),
|
|
146
|
+
* },
|
|
147
|
+
* focus: element === element.ownerDocument.activeElement,
|
|
148
|
+
* });
|
|
149
|
+
* };
|
|
150
|
+
*
|
|
151
|
+
* // initial state for web-tcl
|
|
152
|
+
* updateCustomControl();
|
|
153
|
+
*
|
|
154
|
+
* // handle events coming from web-tcl
|
|
155
|
+
* control.handle("selection", ({ start, end }) => {
|
|
156
|
+
* element.setSelectionRange(start, end);
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* control.handle("text", ({ value, start, length }) => {
|
|
160
|
+
* if (!value) {
|
|
161
|
+
* element.value = "";
|
|
162
|
+
* } else {
|
|
163
|
+
* element.value = `${element.value.slice(0, start)}${value}${element.value.slice(start + length)}`;
|
|
164
|
+
* }
|
|
165
|
+
* element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* control.handle("focus", (focus) => {
|
|
169
|
+
* if (focus) {
|
|
170
|
+
* element.focus();
|
|
171
|
+
* } else {
|
|
172
|
+
* element.blur();
|
|
173
|
+
* }
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* // handle events coming from the HTML element
|
|
177
|
+
* element.addEventListener("input", notifyCustomControl);
|
|
178
|
+
* element.addEventListener("change", notifyCustomControl);
|
|
179
|
+
* element.addEventListener("select", notifyCustomControl);
|
|
180
|
+
* element.addEventListener("focusin", notifyCustomControl);
|
|
181
|
+
* element.addEventListener("focusout", notifyCustomControl);
|
|
182
|
+
*
|
|
183
|
+
* return function () {
|
|
184
|
+
* element.removeEventListener("input", notifyCustomControl);
|
|
185
|
+
* element.removeEventListener("change", notifyCustomControl);
|
|
186
|
+
* element.removeEventListener("select", notifyCustomControl);
|
|
187
|
+
* element.removeEventListener("focusin", notifyCustomControl);
|
|
188
|
+
* element.removeEventListener("focusout", notifyCustomControl);
|
|
189
|
+
* };
|
|
190
|
+
* };
|
|
191
|
+
* ```
|
|
192
|
+
* @param element
|
|
193
|
+
* @param control
|
|
194
|
+
* @returns a function to remove event handlers, disconnecting {@link HTMLElement} and {@link CustomControl}.
|
|
195
|
+
*/
|
|
196
|
+
export type CustomControlInitializer = (element: HTMLElement, control: CustomControl) => () => void;
|
|
197
|
+
/**
|
|
198
|
+
* Collection of {@link CustomControl} - key is string, value is {@link CustomControlInitializer}
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const customControls = {
|
|
202
|
+
* "customControlType": function (element: HTMLElement, control: CustomControl) {
|
|
203
|
+
* // implementation
|
|
204
|
+
* },
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export interface CustomControlCollection {
|
|
209
|
+
readonly [name: string]: CustomControlInitializer;
|
|
210
|
+
readonly [name: number]: never;
|
|
211
|
+
readonly [name: symbol]: never;
|
|
212
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomControl, CustomControlInitializer, CustomControlCollection, CustomControlCommand, CustomControlState } from "./custom-control";
|
|
2
|
+
export type { CustomControl, CustomControlInitializer, CustomControlCollection, CustomControlCommand, CustomControlState, };
|
|
3
|
+
export declare const CustomControls: {
|
|
4
|
+
readonly inputCustomControl: CustomControlInitializer;
|
|
5
|
+
readonly textareaCustomControl: CustomControlInitializer;
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inputCustomControl as o}from"./input-custom-control";import{textareaCustomControl as t}from"./textarea-custom-control";export const CustomControls={inputCustomControl:o,textareaCustomControl:t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const inputCustomControl=function(e,n){if(!(e instanceof HTMLInputElement)){throw new Error("Element must be an input")}n.newline="\n";n.paragraph="\n\n";n.isMultiline=false;const t=()=>{var t,s;n.update({text:e.value,selection:{start:(t=e.selectionStart)!==null&&t!==void 0?t:0,end:(s=e.selectionEnd)!==null&&s!==void 0?s:0},focus:e===e.ownerDocument.activeElement})};t();n.handle("text",({value:n,start:t,length:s})=>{e.value=e.value.slice(0,t)+n+e.value.slice(t+s);e.dispatchEvent(new Event("change",{bubbles:true}))});n.handle("selection",({start:n,end:t})=>{e.setSelectionRange(n,t)});n.handle("focus",n=>{if(n){e.focus()}else{e.blur()}});e.addEventListener("input",t);e.addEventListener("change",t);e.addEventListener("select",t);e.addEventListener("focusin",t);e.addEventListener("focusout",t);return function(){e.removeEventListener("input",t);e.removeEventListener("change",t);e.removeEventListener("select",t);e.removeEventListener("focusin",t);e.removeEventListener("focusout",t)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const textareaCustomControl=function(e,t){if(!(e instanceof HTMLTextAreaElement)){throw new Error("Element must be an input")}t.newline="\n";t.paragraph="\n\n";t.isMultiline=true;const n=()=>{var n,s;t.update({text:e.value,selection:{start:(n=e.selectionStart)!==null&&n!==void 0?n:0,end:(s=e.selectionEnd)!==null&&s!==void 0?s:0},focus:e===e.ownerDocument.activeElement})};n();t.handle("text",({value:t,start:n,length:s})=>{e.value=e.value.slice(0,n)+t+e.value.slice(n+s);e.dispatchEvent(new Event("change",{bubbles:true}))});t.handle("selection",({start:t,end:n})=>{e.setSelectionRange(t,n)});t.handle("focus",t=>{if(t){e.focus()}else{e.blur()}});e.addEventListener("input",n);e.addEventListener("change",n);e.addEventListener("select",n);e.addEventListener("focusin",n);e.addEventListener("focusout",n);return function(){e.removeEventListener("input",n);e.removeEventListener("change",n);e.removeEventListener("select",n);e.removeEventListener("focusin",n);e.removeEventListener("focusout",n)}};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WebTCLCommand } from "./commands";
|
|
2
|
+
import { type WebTCLEvent } from "./events";
|
|
3
|
+
import type { WebTCLState } from "./state";
|
|
4
|
+
type Diagnostics = {
|
|
5
|
+
isEnabled: true;
|
|
6
|
+
trace(message: DiagnosticMessage): void;
|
|
7
|
+
} | {
|
|
8
|
+
isEnabled: false;
|
|
9
|
+
};
|
|
10
|
+
export declare function createDiagnostics(): Diagnostics;
|
|
11
|
+
export type DiagnosticMessageMap = {
|
|
12
|
+
"worker-created": object;
|
|
13
|
+
"worker-destroyed": object;
|
|
14
|
+
"command-executing": {
|
|
15
|
+
command: WebTCLCommand;
|
|
16
|
+
};
|
|
17
|
+
"command-executed": {
|
|
18
|
+
command: WebTCLCommand;
|
|
19
|
+
};
|
|
20
|
+
"state-changed": {
|
|
21
|
+
state: WebTCLState;
|
|
22
|
+
newState: WebTCLState;
|
|
23
|
+
trigger: WebTCLEvent;
|
|
24
|
+
};
|
|
25
|
+
"event-dispatching": {
|
|
26
|
+
event: WebTCLEvent;
|
|
27
|
+
};
|
|
28
|
+
"event-dispatched": {
|
|
29
|
+
event: WebTCLEvent;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type DiagnosticMessage = {
|
|
33
|
+
[K in keyof DiagnosticMessageMap]: {
|
|
34
|
+
type: K;
|
|
35
|
+
} & DiagnosticMessageMap[K];
|
|
36
|
+
}[keyof DiagnosticMessageMap];
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{name as e,version as t}from"../package-info";import{currentTimestamp as s}from"./events";let n=0;export function createDiagnostics(){var o;const r=n++;switch((o=sessionStorage.getItem("WEBTCL_ENABLE_DIAGNOSTICS"))!==null&&o!==void 0?o:""){case"console":{let n=0;return{isEnabled:true,trace(o){const a=n++;console.log("%s@%s:[%d][%d]:%s at %f\n%s",e,t,r,a,o.type,s(),JSON.stringify(o,null,2))}}}default:return{isEnabled:false}}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
export type ControlsMutation = {
|
|
3
|
+
type: "childList";
|
|
4
|
+
target: HTMLElement;
|
|
5
|
+
added: HTMLElement[];
|
|
6
|
+
removed: HTMLElement[];
|
|
7
|
+
} | {
|
|
8
|
+
type: "attributes";
|
|
9
|
+
target: HTMLElement;
|
|
10
|
+
attributeName: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const attributesToObserve: ("data-dragon-container" | "data-nusa-container" | "data-dragon-concept-name" | "data-nusa-concept-name" | "data-dragon-enabled" | "data-nusa-enabled")[];
|
|
13
|
+
export declare function createDomObservable(target: Node): Observable<ControlsMutation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Observable as t}from"rxjs";import{DragonAttributesMap as e}from"./webtcl-attributes";export const attributesToObserve=[...e.container,...e.conceptName,...e.isEnabled];export function createDomObservable(e){return new t(t=>{const r=new MutationObserver(e=>{e.forEach(e=>{if(!e.target||e.target.nodeType!==Node.ELEMENT_NODE){return}if(e.type==="childList"){const r=Array.from(e.addedNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE);const o=Array.from(e.removedNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE);if(r.length===0&&o.length===0){return}t.next({type:"childList",target:e.target,added:r,removed:o})}if(e.type==="attributes"&&e.attributeName){t.next({type:"attributes",target:e.target,attributeName:e.attributeName})}})});const o={childList:true,subtree:true,attributes:true,attributeFilter:attributesToObserve};r.observe(e,o);return()=>{r.disconnect()}})}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ProcessingStatus } from "./processing-status";
|
|
2
|
+
import type { WebTCLState } from "./state";
|
|
3
|
+
type EventMap = {
|
|
4
|
+
initialized: Pick<WebTCLState, "isInitialized" | "isDisabled">;
|
|
5
|
+
focusChanged: {
|
|
6
|
+
id: string;
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
};
|
|
9
|
+
disposed: undefined;
|
|
10
|
+
controlChanged: {
|
|
11
|
+
id: string;
|
|
12
|
+
text: string;
|
|
13
|
+
selection: {
|
|
14
|
+
start: number;
|
|
15
|
+
length: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
statusChanged: {
|
|
19
|
+
id: string;
|
|
20
|
+
status: ProcessingStatus;
|
|
21
|
+
};
|
|
22
|
+
controlsChanged: Pick<WebTCLState, "textControls" | "focusedControl">;
|
|
23
|
+
};
|
|
24
|
+
export type WebTCLEvents = {
|
|
25
|
+
[K in keyof EventMap]: EventMap[K] extends undefined ? {
|
|
26
|
+
type: K;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
} : {
|
|
29
|
+
type: K;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
} & EventMap[K];
|
|
32
|
+
};
|
|
33
|
+
export type WebTCLEvent = WebTCLEvents[keyof WebTCLEvents];
|
|
34
|
+
/**
|
|
35
|
+
* Get the current time in high resolution milliseconds
|
|
36
|
+
* @returns the current time in milliseconds
|
|
37
|
+
*/
|
|
38
|
+
export declare const currentTimestamp: () => number;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const currentTimestamp=()=>performance.timeOrigin+performance.now();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CustomControlCollection } from "./custom-controls";
|
|
2
|
+
/**
|
|
3
|
+
* Options for configuring iframe message handling.
|
|
4
|
+
*
|
|
5
|
+
* @property contextWindow - The window context in which the iframe is running.
|
|
6
|
+
* @property customControls - (Optional) A collection of custom controls to be used within the iframe.
|
|
7
|
+
*/
|
|
8
|
+
export type IframeMessagesOptions = {
|
|
9
|
+
contextWindow: Window;
|
|
10
|
+
customControls?: CustomControlCollection;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Subscribes to messages sent to the current window from its parent and forwards them as commmands to the web-tcl client.
|
|
14
|
+
* It also subscribes to events coming from the web-tcl client and fowards them to its parent as messages.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* **IMPORTANT:** This function should only be called when running inside an iframe.
|
|
18
|
+
*
|
|
19
|
+
* - Listens for messages from the parent window and forwards them to the WebTCL client.
|
|
20
|
+
* - Forwards events from the WebTCL client back to the parent window using `postMessage`.
|
|
21
|
+
* - Manages all subscriptions and resources, cleaning them up when the returned unsubscribe function is called.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Configuration options for the subscription.
|
|
24
|
+
* @param options.contextWindow - The window context in which the iframe is running.
|
|
25
|
+
* @param options.customControls - (Optional) A collection of custom control types to be used within the iframe.
|
|
26
|
+
* @returns A cleanup function that unsubscribes from all events and disposes the WebTCL client.
|
|
27
|
+
* @throws Error if called outside of an iframe context.
|
|
28
|
+
*/
|
|
29
|
+
export declare function subscribeToIframeMessages({ contextWindow, customControls }: IframeMessagesOptions): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fromEvent as e,Subscription as r}from"rxjs";import{createClient as s}from"./webtcl-client";import{createController as t}from"./webtcl-controller";import{SpeechDocument as o}from"../speech-document";import{logger as n}from"../logger/logging";export function subscribeToIframeMessages({contextWindow:i,customControls:m}){if(!a(i)){throw Error("Not running inside an iframe")}const u=t({speechdocument:new o({customControls:m})});const c=s({controller:u});const p=new r;let d="";function f(e){try{if(!d){n.warning("iframe-support.sendToParent","originOfSubscriber is not set");return}i.parent.postMessage(e,d)}catch(e){n.error("iframe-support.subscribeToIframeMessages","Failed to send message to parent:",e)}}const g=e(i,"message");p.add(g.subscribe(e=>{if(!e.data){n.debug("iframe-support.messages$.subscribe","message.data is empty");return}if(e.source!==i.parent){n.debug("iframe-support.messages$.subscribe",`message is not from parent`);return}if(!u.isValidCommand(e.data)){n.debug("iframe-support.messages$.subscribe","message.data is not a valid WebTCLCommand");return}if(e.data.type==="initialize"){d=e.origin}c.commands.send(e.data)}));p.add(c.events.receiveAll().subscribe(e=>{f(e)}));i.parent.postMessage({type:"dragon-iframe-support-ready"},"*");return()=>{c.dispose();p.unsubscribe()}}function a(e){try{return e.self!==e.top}catch(e){return true}}
|