@lexical/dragon 0.35.1-nightly.20250924.0 → 0.36.0

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.
@@ -8,6 +8,7 @@
8
8
 
9
9
  'use strict';
10
10
 
11
+ var extension = require('@lexical/extension');
11
12
  var lexical = require('lexical');
12
13
 
13
14
  /**
@@ -41,7 +42,7 @@ function registerDragonSupport(editor) {
41
42
  if (payload && payload.functionId === 'makeChanges') {
42
43
  const args = payload.args;
43
44
  if (args) {
44
- const [elementStart, elementLength, text, selStart, selLength, _formatCommand] = args;
45
+ const [elementStart, elementLength, text, selStart, selLength] = args;
45
46
  // TODO: we should probably handle formatCommand somehow?
46
47
  // formatCommand;
47
48
  editor.update(() => {
@@ -89,5 +90,18 @@ function registerDragonSupport(editor) {
89
90
  window.removeEventListener('message', handler, true);
90
91
  };
91
92
  }
93
+ /**
94
+ * Add Dragon speech to text input support to the editor, via the
95
+ * \@lexical/dragon module.
96
+ */
97
+ const DragonExtension = lexical.defineExtension({
98
+ build: (editor, config, state) => extension.namedSignals(config),
99
+ config: lexical.safeCast({
100
+ disabled: typeof window === 'undefined'
101
+ }),
102
+ name: '@lexical/dragon',
103
+ register: (editor, config, state) => extension.effect(() => state.getOutput().disabled.value ? undefined : registerDragonSupport(editor))
104
+ });
92
105
 
106
+ exports.DragonExtension = DragonExtension;
93
107
  exports.registerDragonSupport = registerDragonSupport;
@@ -6,7 +6,8 @@
6
6
  *
7
7
  */
8
8
 
9
- import { $getSelection, $isRangeSelection, $isTextNode } from 'lexical';
9
+ import { effect, namedSignals } from '@lexical/extension';
10
+ import { defineExtension, safeCast, $getSelection, $isRangeSelection, $isTextNode } from 'lexical';
10
11
 
11
12
  /**
12
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -39,7 +40,7 @@ function registerDragonSupport(editor) {
39
40
  if (payload && payload.functionId === 'makeChanges') {
40
41
  const args = payload.args;
41
42
  if (args) {
42
- const [elementStart, elementLength, text, selStart, selLength, _formatCommand] = args;
43
+ const [elementStart, elementLength, text, selStart, selLength] = args;
43
44
  // TODO: we should probably handle formatCommand somehow?
44
45
  // formatCommand;
45
46
  editor.update(() => {
@@ -87,5 +88,17 @@ function registerDragonSupport(editor) {
87
88
  window.removeEventListener('message', handler, true);
88
89
  };
89
90
  }
91
+ /**
92
+ * Add Dragon speech to text input support to the editor, via the
93
+ * \@lexical/dragon module.
94
+ */
95
+ const DragonExtension = defineExtension({
96
+ build: (editor, config, state) => namedSignals(config),
97
+ config: safeCast({
98
+ disabled: typeof window === 'undefined'
99
+ }),
100
+ name: '@lexical/dragon',
101
+ register: (editor, config, state) => effect(() => state.getOutput().disabled.value ? undefined : registerDragonSupport(editor))
102
+ });
90
103
 
91
- export { registerDragonSupport };
104
+ export { DragonExtension, registerDragonSupport };
@@ -6,8 +6,13 @@
6
6
  *
7
7
  * @flow strict
8
8
  */
9
- import type {LexicalEditor} from 'lexical';
9
+ import type {LexicalEditor, LexicalExtension} from 'lexical';
10
+ import type {NamedSignalsOutput} from '@lexical/extension';
10
11
  import {$getSelection, $isRangeSelection, $isTextNode} from 'lexical';
11
12
  declare export function registerDragonSupport(
12
13
  editor: LexicalEditor,
13
14
  ): () => void;
15
+ export type DragonConfig = {
16
+ disabled: boolean;
17
+ };
18
+ declare export var DragonExtension: LexicalExtension<DragonConfig, "@lexical/dragon", NamedSignalsOutput<DragonConfig>, void>;
package/LexicalDragon.mjs CHANGED
@@ -9,4 +9,5 @@
9
9
  import * as modDev from './LexicalDragon.dev.mjs';
10
10
  import * as modProd from './LexicalDragon.prod.mjs';
11
11
  const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
+ export const DragonExtension = mod.DragonExtension;
12
13
  export const registerDragonSupport = mod.registerDragonSupport;
@@ -7,4 +7,5 @@
7
7
  */
8
8
 
9
9
  const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalDragon.dev.mjs') : import('./LexicalDragon.prod.mjs'));
10
+ export const DragonExtension = mod.DragonExtension;
10
11
  export const registerDragonSupport = mod.registerDragonSupport;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("lexical");exports.registerDragonSupport=function(t){const n=window.location.origin,o=o=>{if(o.origin!==n)return;const i=t.getRootElement();if(document.activeElement!==i)return;const s=o.data;if("string"==typeof s){let n;try{n=JSON.parse(s)}catch(e){return}if(n&&"nuanria_messaging"===n.protocol&&"request"===n.type){const i=n.payload;if(i&&"makeChanges"===i.functionId){const n=i.args;if(n){const[i,s,r,a,c,g]=n;t.update((()=>{const t=e.$getSelection();if(e.$isRangeSelection(t)){const n=t.anchor;let g=n.getNode(),d=0,u=0;if(e.$isTextNode(g)&&i>=0&&s>=0&&(d=i,u=i+s,t.setTextNodeRange(g,d,g,u)),d===u&&""===r||(t.insertRawText(r),g=n.getNode()),e.$isTextNode(g)){d=a,u=a+c;const e=g.getTextContentSize();d=d>e?e:d,u=u>e?e:u,t.setTextNodeRange(g,d,g,u)}o.stopImmediatePropagation()}}))}}}}};return window.addEventListener("message",o,!0),()=>{window.removeEventListener("message",o,!0)}};
9
+ "use strict";var e=require("@lexical/extension"),t=require("lexical");function n(e){const n=window.location.origin,o=o=>{if(o.origin!==n)return;const i=e.getRootElement();if(document.activeElement!==i)return;const s=o.data;if("string"==typeof s){let n;try{n=JSON.parse(s)}catch(e){return}if(n&&"nuanria_messaging"===n.protocol&&"request"===n.type){const i=n.payload;if(i&&"makeChanges"===i.functionId){const n=i.args;if(n){const[i,s,a,r,d]=n;e.update((()=>{const e=t.$getSelection();if(t.$isRangeSelection(e)){const n=e.anchor;let c=n.getNode(),g=0,l=0;if(t.$isTextNode(c)&&i>=0&&s>=0&&(g=i,l=i+s,e.setTextNodeRange(c,g,c,l)),g===l&&""===a||(e.insertRawText(a),c=n.getNode()),t.$isTextNode(c)){g=r,l=r+d;const t=c.getTextContentSize();g=g>t?t:g,l=l>t?t:l,e.setTextNodeRange(c,g,c,l)}o.stopImmediatePropagation()}}))}}}}};return window.addEventListener("message",o,!0),()=>{window.removeEventListener("message",o,!0)}}const o=t.defineExtension({build:(t,n,o)=>e.namedSignals(n),config:t.safeCast({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,o,i)=>e.effect((()=>i.getOutput().disabled.value?void 0:n(t)))});exports.DragonExtension=o,exports.registerDragonSupport=n;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{$getSelection as e,$isRangeSelection as t,$isTextNode as n}from"lexical";function o(o){const i=window.location.origin,a=a=>{if(a.origin!==i)return;const r=o.getRootElement();if(document.activeElement!==r)return;const s=a.data;if("string"==typeof s){let i;try{i=JSON.parse(s)}catch(e){return}if(i&&"nuanria_messaging"===i.protocol&&"request"===i.type){const r=i.payload;if(r&&"makeChanges"===r.functionId){const i=r.args;if(i){const[r,s,c,g,d,f]=i;o.update((()=>{const o=e();if(t(o)){const e=o.anchor;let t=e.getNode(),i=0,f=0;if(n(t)&&r>=0&&s>=0&&(i=r,f=r+s,o.setTextNodeRange(t,i,t,f)),i===f&&""===c||(o.insertRawText(c),t=e.getNode()),n(t)){i=g,f=g+d;const e=t.getTextContentSize();i=i>e?e:i,f=f>e?e:f,o.setTextNodeRange(t,i,t,f)}a.stopImmediatePropagation()}}))}}}}};return window.addEventListener("message",a,!0),()=>{window.removeEventListener("message",a,!0)}}export{o as registerDragonSupport};
9
+ import{effect as e,namedSignals as t}from"@lexical/extension";import{defineExtension as n,safeCast as o,$getSelection as i,$isRangeSelection as a,$isTextNode as r}from"lexical";function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s)}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update((()=>{const e=i();if(a(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if(r(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),r(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l)}n.stopImmediatePropagation()}}))}}}}};return window.addEventListener("message",n,!0),()=>{window.removeEventListener("message",n,!0)}}const d=n({build:(e,n,o)=>t(n),config:o({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>e((()=>o.getOutput().disabled.value?void 0:s(t)))});export{d as DragonExtension,s as registerDragonSupport};
package/index.d.ts CHANGED
@@ -7,3 +7,11 @@
7
7
  */
8
8
  import { LexicalEditor } from 'lexical';
9
9
  export declare function registerDragonSupport(editor: LexicalEditor): () => void;
10
+ export interface DragonConfig {
11
+ disabled: boolean;
12
+ }
13
+ /**
14
+ * Add Dragon speech to text input support to the editor, via the
15
+ * \@lexical/dragon module.
16
+ */
17
+ export declare const DragonExtension: import("lexical").LexicalExtension<DragonConfig, "@lexical/dragon", import("@lexical/extension").NamedSignalsOutput<DragonConfig>, unknown>;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "accessibility"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.35.1-nightly.20250924.0",
12
+ "version": "0.36.0",
13
13
  "main": "LexicalDragon.js",
14
14
  "types": "index.d.ts",
15
15
  "repository": {
@@ -37,6 +37,7 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "lexical": "0.35.1-nightly.20250924.0"
40
+ "@lexical/extension": "0.36.0",
41
+ "lexical": "0.36.0"
41
42
  }
42
43
  }