@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.
- package/LexicalDragon.dev.js +15 -1
- package/LexicalDragon.dev.mjs +16 -3
- package/LexicalDragon.js.flow +6 -1
- package/LexicalDragon.mjs +1 -0
- package/LexicalDragon.node.mjs +1 -0
- package/LexicalDragon.prod.js +1 -1
- package/LexicalDragon.prod.mjs +1 -1
- package/index.d.ts +8 -0
- package/package.json +3 -2
package/LexicalDragon.dev.js
CHANGED
|
@@ -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
|
|
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;
|
package/LexicalDragon.dev.mjs
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
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
|
|
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 };
|
package/LexicalDragon.js.flow
CHANGED
|
@@ -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;
|
package/LexicalDragon.node.mjs
CHANGED
package/LexicalDragon.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("lexical");
|
|
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;
|
package/LexicalDragon.prod.mjs
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{
|
|
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.
|
|
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.
|
|
40
|
+
"@lexical/extension": "0.36.0",
|
|
41
|
+
"lexical": "0.36.0"
|
|
41
42
|
}
|
|
42
43
|
}
|