@uniformdev/uniform-mcp 20.14.2-alpha.35 → 20.14.2-alpha.50
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/README.md +5 -5
- package/dist/LexicalComposer.dev-YZLZHPHB.mjs +104 -0
- package/dist/LexicalComposer.prod-GQ6E4XLB.mjs +59 -0
- package/dist/LexicalComposerContext.dev-OXMYTAIK.mjs +39 -0
- package/dist/LexicalComposerContext.prod-B6MGULHP.mjs +34 -0
- package/dist/LexicalContentEditable.dev-HSZEZVX6.mjs +176 -0
- package/dist/LexicalContentEditable.prod-MA4E5ZUO.mjs +70 -0
- package/dist/LexicalDragon.dev-FLAESERJ.mjs +70 -0
- package/dist/LexicalDragon.prod-WGTSU75T.mjs +48 -0
- package/dist/LexicalErrorBoundary.dev-S5FJXLET.mjs +123 -0
- package/dist/LexicalErrorBoundary.prod-KUDTD55W.mjs +61 -0
- package/dist/LexicalHistory.dev-274ERACX.mjs +257 -0
- package/dist/LexicalHistory.prod-N2ZDY5JE.mjs +105 -0
- package/dist/LexicalHistoryPlugin.dev-ZJ4AV6QF.mjs +34 -0
- package/dist/LexicalHistoryPlugin.prod-R2OQB46L.mjs +27 -0
- package/dist/LexicalHorizontalRuleNode.dev-I4JMU4IP.mjs +129 -0
- package/dist/LexicalHorizontalRuleNode.prod-UQDJRHLM.mjs +89 -0
- package/dist/LexicalListPlugin.dev-OIY4J2H7.mjs +31 -0
- package/dist/LexicalListPlugin.prod-O7PRJFLG.mjs +24 -0
- package/dist/LexicalMarkdownShortcutPlugin.dev-W4VA6LZA.mjs +49 -0
- package/dist/LexicalMarkdownShortcutPlugin.prod-IDCKLD5Z.mjs +30 -0
- package/dist/LexicalNodeEventPlugin.dev-OSGD7K2U.mjs +53 -0
- package/dist/LexicalNodeEventPlugin.prod-5QSOWVC6.mjs +37 -0
- package/dist/LexicalRichTextPlugin.dev-QRMY3V74.mjs +123 -0
- package/dist/LexicalRichTextPlugin.prod-SLEAYAVI.mjs +77 -0
- package/dist/LexicalSelection.dev-C5LJOPCC.mjs +672 -0
- package/dist/LexicalSelection.prod-IZLG4ROB.mjs +385 -0
- package/dist/LexicalTablePlugin.dev-XZSTX57S.mjs +45 -0
- package/dist/LexicalTablePlugin.prod-LHCFJ6XO.mjs +28 -0
- package/dist/LexicalText.dev-RMYTEK72.mjs +229 -0
- package/dist/LexicalText.prod-7NH3UIYD.mjs +146 -0
- package/dist/LexicalUtils.dev-UF7FC3KJ.mjs +725 -0
- package/dist/LexicalUtils.prod-NNSCH4VF.mjs +405 -0
- package/dist/chunk-3UUF6GA6.mjs +59 -0
- package/dist/chunk-BPEABKCT.mjs +13 -0
- package/dist/chunk-E2J5KZ6E.mjs +41 -0
- package/dist/chunk-F7XI6FEU.mjs +9 -0
- package/dist/chunk-JAKLC22G.mjs +2190 -0
- package/dist/chunk-MA3K3FSR.mjs +7 -0
- package/dist/chunk-RZQMXA2I.mjs +12 -0
- package/dist/chunk-UVIE4BL2.mjs +674 -0
- package/dist/chunk-WKV5LY3V.mjs +28 -0
- package/dist/chunk-Y4J6XIOX.mjs +7 -0
- package/dist/chunk-YFQVGPKN.mjs +28590 -0
- package/dist/chunk-YYOZYEGT.mjs +11 -0
- package/dist/chunk-ZX6ALARP.mjs +964 -0
- package/dist/importedIcons-NFIA4IOK-RQYUFFEW.mjs +8260 -0
- package/dist/index.mjs +32484 -0
- package/dist/useLexicalEditable.dev-GG4JWFC2.mjs +51 -0
- package/dist/useLexicalEditable.prod-ST34SOEG.mjs +31 -0
- package/dist/useLexicalNodeSelection.dev-VJGFXM7C.mjs +66 -0
- package/dist/useLexicalNodeSelection.prod-AAICLEMR.mjs +45 -0
- package/package.json +14 -10
- package/dist/index.js +0 -618
- /package/dist/{index.d.ts → index.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@ A stdio-transport MCP server which allows you to manipulate Uniform entities.
|
|
|
4
4
|
|
|
5
5
|
Part of the [Uniform Platform](https://uniform.app). See our [documentation](https://docs.uniform.app) for more details.
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
### Setup
|
|
9
8
|
|
|
10
9
|
#### Uniform Context
|
|
@@ -14,7 +13,7 @@ For Cursor, this belongs in `.cursor/rules/*.mdc`.
|
|
|
14
13
|
|
|
15
14
|
#### Register MCP server
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
- Add the following to `.cursor/mcp.json` (for other editors, this should be easily convertible)
|
|
18
17
|
|
|
19
18
|
```
|
|
20
19
|
{
|
|
@@ -26,8 +25,9 @@ For Cursor, this belongs in `.cursor/rules/*.mdc`.
|
|
|
26
25
|
"env": {
|
|
27
26
|
"UNIFORM_API_KEY": "your-api-key",
|
|
28
27
|
"UNIFORM_PROJECT_ID": "your-project-id",
|
|
29
|
-
// optional, only needed if your host is not
|
|
28
|
+
// optional, only needed if your API host is not the default (e.g. EU users, developers)
|
|
30
29
|
"UNIFORM_API_HOST": "https://uniform.app",
|
|
30
|
+
"UNIFORM_AI_API_HOST": "https://ai.uniform.global"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -35,7 +35,7 @@ For Cursor, this belongs in `.cursor/rules/*.mdc`.
|
|
|
35
35
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
- Enable the MCP server if necessary.
|
|
39
39
|
|
|
40
40
|
Note: if you are developing against this mcp server, you must use `node` with args `../path/to/this-package-source/dist/index.js` - npx does not support local packages. If your Uniform API host is self-signed, `NODE_TLS_REJECT_UNAUTHORIZED: 0` env var works, but do not use in production.
|
|
41
41
|
|
|
@@ -46,4 +46,4 @@ Pattern editing supports a limited subset of patterns. Specifically:
|
|
|
46
46
|
- Locale support is rudimentary (cannot enable or disable locales, but can change existing localized param values)
|
|
47
47
|
- Conditional values are not supported
|
|
48
48
|
- Inserting other nested patterns is not supported
|
|
49
|
-
- Editing overrides is not supported
|
|
49
|
+
- Editing overrides is not supported
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LexicalComposerContext,
|
|
3
|
+
createLexicalComposerContext
|
|
4
|
+
} from "./chunk-YYOZYEGT.mjs";
|
|
5
|
+
import {
|
|
6
|
+
require_jsx_runtime
|
|
7
|
+
} from "./chunk-ZX6ALARP.mjs";
|
|
8
|
+
import {
|
|
9
|
+
require_react
|
|
10
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__toESM
|
|
13
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalComposer.dev.mjs
|
|
16
|
+
var import_react = __toESM(require_react(), 1);
|
|
17
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
18
|
+
import { createEditor, $getRoot, $createParagraphNode, $getSelection } from "lexical";
|
|
19
|
+
var CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
20
|
+
var useLayoutEffectImpl = CAN_USE_DOM ? import_react.useLayoutEffect : import_react.useEffect;
|
|
21
|
+
var HISTORY_MERGE_OPTIONS = {
|
|
22
|
+
tag: "history-merge"
|
|
23
|
+
};
|
|
24
|
+
function LexicalComposer({
|
|
25
|
+
initialConfig,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
const composerContext = (0, import_react.useMemo)(
|
|
29
|
+
() => {
|
|
30
|
+
const {
|
|
31
|
+
theme,
|
|
32
|
+
namespace,
|
|
33
|
+
nodes,
|
|
34
|
+
onError,
|
|
35
|
+
editorState: initialEditorState,
|
|
36
|
+
html
|
|
37
|
+
} = initialConfig;
|
|
38
|
+
const context = createLexicalComposerContext(null, theme);
|
|
39
|
+
const editor = createEditor({
|
|
40
|
+
editable: initialConfig.editable,
|
|
41
|
+
html,
|
|
42
|
+
namespace,
|
|
43
|
+
nodes,
|
|
44
|
+
onError: (error) => onError(error, editor),
|
|
45
|
+
theme
|
|
46
|
+
});
|
|
47
|
+
initializeEditor(editor, initialEditorState);
|
|
48
|
+
return [editor, context];
|
|
49
|
+
},
|
|
50
|
+
// We only do this for init
|
|
51
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
+
[]
|
|
53
|
+
);
|
|
54
|
+
useLayoutEffectImpl(() => {
|
|
55
|
+
const isEditable = initialConfig.editable;
|
|
56
|
+
const [editor] = composerContext;
|
|
57
|
+
editor.setEditable(isEditable !== void 0 ? isEditable : true);
|
|
58
|
+
}, []);
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LexicalComposerContext.Provider, {
|
|
60
|
+
value: composerContext,
|
|
61
|
+
children
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function initializeEditor(editor, initialEditorState) {
|
|
65
|
+
if (initialEditorState === null) {
|
|
66
|
+
return;
|
|
67
|
+
} else if (initialEditorState === void 0) {
|
|
68
|
+
editor.update(() => {
|
|
69
|
+
const root = $getRoot();
|
|
70
|
+
if (root.isEmpty()) {
|
|
71
|
+
const paragraph = $createParagraphNode();
|
|
72
|
+
root.append(paragraph);
|
|
73
|
+
const activeElement = CAN_USE_DOM ? document.activeElement : null;
|
|
74
|
+
if ($getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement()) {
|
|
75
|
+
paragraph.select();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, HISTORY_MERGE_OPTIONS);
|
|
79
|
+
} else if (initialEditorState !== null) {
|
|
80
|
+
switch (typeof initialEditorState) {
|
|
81
|
+
case "string": {
|
|
82
|
+
const parsedEditorState = editor.parseEditorState(initialEditorState);
|
|
83
|
+
editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case "object": {
|
|
87
|
+
editor.setEditorState(initialEditorState, HISTORY_MERGE_OPTIONS);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "function": {
|
|
91
|
+
editor.update(() => {
|
|
92
|
+
const root = $getRoot();
|
|
93
|
+
if (root.isEmpty()) {
|
|
94
|
+
initialEditorState(editor);
|
|
95
|
+
}
|
|
96
|
+
}, HISTORY_MERGE_OPTIONS);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
LexicalComposer
|
|
104
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LexicalComposerContext,
|
|
3
|
+
createLexicalComposerContext
|
|
4
|
+
} from "./chunk-YYOZYEGT.mjs";
|
|
5
|
+
import {
|
|
6
|
+
require_jsx_runtime
|
|
7
|
+
} from "./chunk-ZX6ALARP.mjs";
|
|
8
|
+
import {
|
|
9
|
+
require_react
|
|
10
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__toESM
|
|
13
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalComposer.prod.mjs
|
|
16
|
+
var import_react = __toESM(require_react(), 1);
|
|
17
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
18
|
+
import { createEditor as o, $getRoot as n, $createParagraphNode as i, $getSelection as r } from "lexical";
|
|
19
|
+
var s = "undefined" != typeof window && void 0 !== window.document && void 0 !== window.document.createElement;
|
|
20
|
+
var m = s ? import_react.useLayoutEffect : import_react.useEffect;
|
|
21
|
+
var u = { tag: "history-merge" };
|
|
22
|
+
function p({ initialConfig: a2, children: c2 }) {
|
|
23
|
+
const p2 = (0, import_react.useMemo)(() => {
|
|
24
|
+
const { theme: t, namespace: c3, nodes: l2, onError: d2, editorState: m2, html: p3 } = a2, f = createLexicalComposerContext(null, t), E = o({ editable: a2.editable, html: p3, namespace: c3, nodes: l2, onError: (e) => d2(e, E), theme: t });
|
|
25
|
+
return function(e, t2) {
|
|
26
|
+
if (null === t2) return;
|
|
27
|
+
if (void 0 === t2) e.update(() => {
|
|
28
|
+
const t3 = n();
|
|
29
|
+
if (t3.isEmpty()) {
|
|
30
|
+
const o2 = i();
|
|
31
|
+
t3.append(o2);
|
|
32
|
+
const n2 = s ? document.activeElement : null;
|
|
33
|
+
(null !== r() || null !== n2 && n2 === e.getRootElement()) && o2.select();
|
|
34
|
+
}
|
|
35
|
+
}, u);
|
|
36
|
+
else if (null !== t2) switch (typeof t2) {
|
|
37
|
+
case "string": {
|
|
38
|
+
const o2 = e.parseEditorState(t2);
|
|
39
|
+
e.setEditorState(o2, u);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "object":
|
|
43
|
+
e.setEditorState(t2, u);
|
|
44
|
+
break;
|
|
45
|
+
case "function":
|
|
46
|
+
e.update(() => {
|
|
47
|
+
n().isEmpty() && t2(e);
|
|
48
|
+
}, u);
|
|
49
|
+
}
|
|
50
|
+
}(E, m2), [E, f];
|
|
51
|
+
}, []);
|
|
52
|
+
return m(() => {
|
|
53
|
+
const e = a2.editable, [t] = p2;
|
|
54
|
+
t.setEditable(void 0 === e || e);
|
|
55
|
+
}, []), (0, import_jsx_runtime.jsx)(LexicalComposerContext.Provider, { value: p2, children: c2 });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
p as LexicalComposer
|
|
59
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_react
|
|
3
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalComposerContext.dev.mjs
|
|
9
|
+
var import_react = __toESM(require_react(), 1);
|
|
10
|
+
var LexicalComposerContext = /* @__PURE__ */ (0, import_react.createContext)(null);
|
|
11
|
+
function createLexicalComposerContext(parent, theme) {
|
|
12
|
+
let parentContext = null;
|
|
13
|
+
if (parent != null) {
|
|
14
|
+
parentContext = parent[1];
|
|
15
|
+
}
|
|
16
|
+
function getTheme() {
|
|
17
|
+
if (theme != null) {
|
|
18
|
+
return theme;
|
|
19
|
+
}
|
|
20
|
+
return parentContext != null ? parentContext.getTheme() : null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
getTheme
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function useLexicalComposerContext() {
|
|
27
|
+
const composerContext = (0, import_react.useContext)(LexicalComposerContext);
|
|
28
|
+
if (composerContext == null) {
|
|
29
|
+
{
|
|
30
|
+
throw Error(`LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return composerContext;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
LexicalComposerContext,
|
|
37
|
+
createLexicalComposerContext,
|
|
38
|
+
useLexicalComposerContext
|
|
39
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_react
|
|
3
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalComposerContext.prod.mjs
|
|
9
|
+
var import_react = __toESM(require_react(), 1);
|
|
10
|
+
function r(e2) {
|
|
11
|
+
return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
|
|
12
|
+
}
|
|
13
|
+
var t = r(function(e2) {
|
|
14
|
+
const n2 = new URL("https://lexical.dev/docs/error"), r2 = new URLSearchParams();
|
|
15
|
+
r2.append("code", e2);
|
|
16
|
+
for (let e3 = 1; e3 < arguments.length; e3++) r2.append("v", arguments[e3]);
|
|
17
|
+
throw n2.search = r2.toString(), Error(`Minified Lexical error #${e2}; visit ${n2.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
18
|
+
});
|
|
19
|
+
var l = (0, import_react.createContext)(null);
|
|
20
|
+
function o(e2, n2) {
|
|
21
|
+
let r2 = null;
|
|
22
|
+
return null != e2 && (r2 = e2[1]), { getTheme: function() {
|
|
23
|
+
return null != n2 ? n2 : null != r2 ? r2.getTheme() : null;
|
|
24
|
+
} };
|
|
25
|
+
}
|
|
26
|
+
function u() {
|
|
27
|
+
const e2 = (0, import_react.useContext)(l);
|
|
28
|
+
return null == e2 && t(8), e2;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
l as LexicalComposerContext,
|
|
32
|
+
o as createLexicalComposerContext,
|
|
33
|
+
u as useLexicalComposerContext
|
|
34
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$canShowPlaceholderCurry
|
|
3
|
+
} from "./chunk-BPEABKCT.mjs";
|
|
4
|
+
import {
|
|
5
|
+
mergeRegister
|
|
6
|
+
} from "./chunk-3UUF6GA6.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useLexicalComposerContext
|
|
9
|
+
} from "./chunk-YYOZYEGT.mjs";
|
|
10
|
+
import {
|
|
11
|
+
require_jsx_runtime
|
|
12
|
+
} from "./chunk-ZX6ALARP.mjs";
|
|
13
|
+
import {
|
|
14
|
+
require_react
|
|
15
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
16
|
+
import {
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalContentEditable.dev.mjs
|
|
21
|
+
var import_react = __toESM(require_react(), 1);
|
|
22
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
23
|
+
var CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
24
|
+
var useLayoutEffectImpl = CAN_USE_DOM ? import_react.useLayoutEffect : import_react.useEffect;
|
|
25
|
+
function mergeRefs(...refs) {
|
|
26
|
+
return (value) => {
|
|
27
|
+
refs.forEach((ref) => {
|
|
28
|
+
if (typeof ref === "function") {
|
|
29
|
+
ref(value);
|
|
30
|
+
} else if (ref != null) {
|
|
31
|
+
ref.current = value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function ContentEditableElementImpl({
|
|
37
|
+
editor,
|
|
38
|
+
ariaActiveDescendant,
|
|
39
|
+
ariaAutoComplete,
|
|
40
|
+
ariaControls,
|
|
41
|
+
ariaDescribedBy,
|
|
42
|
+
ariaErrorMessage,
|
|
43
|
+
ariaExpanded,
|
|
44
|
+
ariaInvalid,
|
|
45
|
+
ariaLabel,
|
|
46
|
+
ariaLabelledBy,
|
|
47
|
+
ariaMultiline,
|
|
48
|
+
ariaOwns,
|
|
49
|
+
ariaRequired,
|
|
50
|
+
autoCapitalize,
|
|
51
|
+
className,
|
|
52
|
+
id,
|
|
53
|
+
role = "textbox",
|
|
54
|
+
spellCheck = true,
|
|
55
|
+
style,
|
|
56
|
+
tabIndex,
|
|
57
|
+
"data-testid": testid,
|
|
58
|
+
...rest
|
|
59
|
+
}, ref) {
|
|
60
|
+
const [isEditable, setEditable] = (0, import_react.useState)(editor.isEditable());
|
|
61
|
+
const handleRef = (0, import_react.useCallback)((rootElement) => {
|
|
62
|
+
if (rootElement && rootElement.ownerDocument && rootElement.ownerDocument.defaultView) {
|
|
63
|
+
editor.setRootElement(rootElement);
|
|
64
|
+
} else {
|
|
65
|
+
editor.setRootElement(null);
|
|
66
|
+
}
|
|
67
|
+
}, [editor]);
|
|
68
|
+
const mergedRefs = (0, import_react.useMemo)(() => mergeRefs(ref, handleRef), [handleRef, ref]);
|
|
69
|
+
useLayoutEffectImpl(() => {
|
|
70
|
+
setEditable(editor.isEditable());
|
|
71
|
+
return editor.registerEditableListener((currentIsEditable) => {
|
|
72
|
+
setEditable(currentIsEditable);
|
|
73
|
+
});
|
|
74
|
+
}, [editor]);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
76
|
+
"aria-activedescendant": isEditable ? ariaActiveDescendant : void 0,
|
|
77
|
+
"aria-autocomplete": isEditable ? ariaAutoComplete : "none",
|
|
78
|
+
"aria-controls": isEditable ? ariaControls : void 0,
|
|
79
|
+
"aria-describedby": ariaDescribedBy,
|
|
80
|
+
...ariaErrorMessage != null ? {
|
|
81
|
+
"aria-errormessage": ariaErrorMessage
|
|
82
|
+
} : {},
|
|
83
|
+
"aria-expanded": isEditable && role === "combobox" ? !!ariaExpanded : void 0,
|
|
84
|
+
...ariaInvalid != null ? {
|
|
85
|
+
"aria-invalid": ariaInvalid
|
|
86
|
+
} : {},
|
|
87
|
+
"aria-label": ariaLabel,
|
|
88
|
+
"aria-labelledby": ariaLabelledBy,
|
|
89
|
+
"aria-multiline": ariaMultiline,
|
|
90
|
+
"aria-owns": isEditable ? ariaOwns : void 0,
|
|
91
|
+
"aria-readonly": isEditable ? void 0 : true,
|
|
92
|
+
"aria-required": ariaRequired,
|
|
93
|
+
autoCapitalize,
|
|
94
|
+
className,
|
|
95
|
+
contentEditable: isEditable,
|
|
96
|
+
"data-testid": testid,
|
|
97
|
+
id,
|
|
98
|
+
ref: mergedRefs,
|
|
99
|
+
role: isEditable ? role : void 0,
|
|
100
|
+
spellCheck,
|
|
101
|
+
style,
|
|
102
|
+
tabIndex,
|
|
103
|
+
...rest
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
var ContentEditableElement = /* @__PURE__ */ (0, import_react.forwardRef)(ContentEditableElementImpl);
|
|
107
|
+
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
108
|
+
const currentCanShowPlaceholder = editor.getEditorState().read($canShowPlaceholderCurry(editor.isComposing()));
|
|
109
|
+
return currentCanShowPlaceholder;
|
|
110
|
+
}
|
|
111
|
+
function useCanShowPlaceholder(editor) {
|
|
112
|
+
const [canShowPlaceholder, setCanShowPlaceholder] = (0, import_react.useState)(() => canShowPlaceholderFromCurrentEditorState(editor));
|
|
113
|
+
useLayoutEffectImpl(() => {
|
|
114
|
+
function resetCanShowPlaceholder() {
|
|
115
|
+
const currentCanShowPlaceholder = canShowPlaceholderFromCurrentEditorState(editor);
|
|
116
|
+
setCanShowPlaceholder(currentCanShowPlaceholder);
|
|
117
|
+
}
|
|
118
|
+
resetCanShowPlaceholder();
|
|
119
|
+
return mergeRegister(editor.registerUpdateListener(() => {
|
|
120
|
+
resetCanShowPlaceholder();
|
|
121
|
+
}), editor.registerEditableListener(() => {
|
|
122
|
+
resetCanShowPlaceholder();
|
|
123
|
+
}));
|
|
124
|
+
}, [editor]);
|
|
125
|
+
return canShowPlaceholder;
|
|
126
|
+
}
|
|
127
|
+
var ContentEditable = /* @__PURE__ */ (0, import_react.forwardRef)(ContentEditableImpl);
|
|
128
|
+
function ContentEditableImpl(props, ref) {
|
|
129
|
+
const {
|
|
130
|
+
placeholder,
|
|
131
|
+
...rest
|
|
132
|
+
} = props;
|
|
133
|
+
const [editor] = useLexicalComposerContext();
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
135
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentEditableElement, {
|
|
136
|
+
editor,
|
|
137
|
+
...rest,
|
|
138
|
+
ref
|
|
139
|
+
}), placeholder != null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Placeholder, {
|
|
140
|
+
editor,
|
|
141
|
+
content: placeholder
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function Placeholder({
|
|
146
|
+
content,
|
|
147
|
+
editor
|
|
148
|
+
}) {
|
|
149
|
+
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
150
|
+
const [isEditable, setEditable] = (0, import_react.useState)(editor.isEditable());
|
|
151
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
152
|
+
setEditable(editor.isEditable());
|
|
153
|
+
return editor.registerEditableListener((currentIsEditable) => {
|
|
154
|
+
setEditable(currentIsEditable);
|
|
155
|
+
});
|
|
156
|
+
}, [editor]);
|
|
157
|
+
if (!showPlaceholder) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
let placeholder = null;
|
|
161
|
+
if (typeof content === "function") {
|
|
162
|
+
placeholder = content(isEditable);
|
|
163
|
+
} else if (content !== null) {
|
|
164
|
+
placeholder = content;
|
|
165
|
+
}
|
|
166
|
+
if (placeholder === null) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
170
|
+
"aria-hidden": true,
|
|
171
|
+
children: placeholder
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
ContentEditable
|
|
176
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$canShowPlaceholderCurry
|
|
3
|
+
} from "./chunk-BPEABKCT.mjs";
|
|
4
|
+
import {
|
|
5
|
+
mergeRegister
|
|
6
|
+
} from "./chunk-3UUF6GA6.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useLexicalComposerContext
|
|
9
|
+
} from "./chunk-YYOZYEGT.mjs";
|
|
10
|
+
import {
|
|
11
|
+
require_jsx_runtime
|
|
12
|
+
} from "./chunk-ZX6ALARP.mjs";
|
|
13
|
+
import {
|
|
14
|
+
require_react
|
|
15
|
+
} from "./chunk-JAKLC22G.mjs";
|
|
16
|
+
import {
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-E2J5KZ6E.mjs";
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/.pnpm/@lexical+react@0.25.0_react-dom@18.3.1_react@18.3.1_yjs@13.6.24/node_modules/@lexical/react/LexicalContentEditable.prod.mjs
|
|
21
|
+
var import_react = __toESM(require_react(), 1);
|
|
22
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
23
|
+
var m = "undefined" != typeof window && void 0 !== window.document && void 0 !== window.document.createElement ? import_react.useLayoutEffect : import_react.useEffect;
|
|
24
|
+
function f({ editor: e, ariaActiveDescendant: t2, ariaAutoComplete: i2, ariaControls: a2, ariaDescribedBy: d2, ariaErrorMessage: c2, ariaExpanded: s, ariaInvalid: u, ariaLabel: f2, ariaLabelledBy: b2, ariaMultiline: p2, ariaOwns: x2, ariaRequired: E2, autoCapitalize: v2, className: w, id: y, role: C = "textbox", spellCheck: g = true, style: h, tabIndex: L, "data-testid": D, ...I }, R) {
|
|
25
|
+
const [k, q] = (0, import_react.useState)(e.isEditable()), z = (0, import_react.useCallback)((t3) => {
|
|
26
|
+
t3 && t3.ownerDocument && t3.ownerDocument.defaultView ? e.setRootElement(t3) : e.setRootElement(null);
|
|
27
|
+
}, [e]), A = (0, import_react.useMemo)(() => /* @__PURE__ */ function(...e2) {
|
|
28
|
+
return (t3) => {
|
|
29
|
+
e2.forEach((e3) => {
|
|
30
|
+
"function" == typeof e3 ? e3(t3) : null != e3 && (e3.current = t3);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}(R, z), [z, R]);
|
|
34
|
+
return m(() => (q(e.isEditable()), e.registerEditableListener((e2) => {
|
|
35
|
+
q(e2);
|
|
36
|
+
})), [e]), (0, import_jsx_runtime.jsx)("div", { "aria-activedescendant": k ? t2 : void 0, "aria-autocomplete": k ? i2 : "none", "aria-controls": k ? a2 : void 0, "aria-describedby": d2, ...null != c2 ? { "aria-errormessage": c2 } : {}, "aria-expanded": k && "combobox" === C ? !!s : void 0, ...null != u ? { "aria-invalid": u } : {}, "aria-label": f2, "aria-labelledby": b2, "aria-multiline": p2, "aria-owns": k ? x2 : void 0, "aria-readonly": !k || void 0, "aria-required": E2, autoCapitalize: v2, className: w, contentEditable: k, "data-testid": D, id: y, ref: A, role: k ? C : void 0, spellCheck: g, style: h, tabIndex: L, ...I });
|
|
37
|
+
}
|
|
38
|
+
var b = (0, import_react.forwardRef)(f);
|
|
39
|
+
function p(e) {
|
|
40
|
+
return e.getEditorState().read($canShowPlaceholderCurry(e.isComposing()));
|
|
41
|
+
}
|
|
42
|
+
var x = (0, import_react.forwardRef)(E);
|
|
43
|
+
function E(t2, i2) {
|
|
44
|
+
const { placeholder: a2, ...r2 } = t2, [n2] = useLexicalComposerContext();
|
|
45
|
+
return (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [(0, import_jsx_runtime.jsx)(b, { editor: n2, ...r2, ref: i2 }), null != a2 && (0, import_jsx_runtime.jsx)(v, { editor: n2, content: a2 })] });
|
|
46
|
+
}
|
|
47
|
+
function v({ content: e, editor: i2 }) {
|
|
48
|
+
const a2 = function(e2) {
|
|
49
|
+
const [t2, i3] = (0, import_react.useState)(() => p(e2));
|
|
50
|
+
return m(() => {
|
|
51
|
+
function t3() {
|
|
52
|
+
const t4 = p(e2);
|
|
53
|
+
i3(t4);
|
|
54
|
+
}
|
|
55
|
+
return t3(), mergeRegister(e2.registerUpdateListener(() => {
|
|
56
|
+
t3();
|
|
57
|
+
}), e2.registerEditableListener(() => {
|
|
58
|
+
t3();
|
|
59
|
+
}));
|
|
60
|
+
}, [e2]), t2;
|
|
61
|
+
}(i2), [n2, o2] = (0, import_react.useState)(i2.isEditable());
|
|
62
|
+
if ((0, import_react.useLayoutEffect)(() => (o2(i2.isEditable()), i2.registerEditableListener((e2) => {
|
|
63
|
+
o2(e2);
|
|
64
|
+
})), [i2]), !a2) return null;
|
|
65
|
+
let d2 = null;
|
|
66
|
+
return "function" == typeof e ? d2 = e(n2) : null !== e && (d2 = e), null === d2 ? null : (0, import_jsx_runtime.jsx)("div", { "aria-hidden": true, children: d2 });
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
x as ContentEditable
|
|
70
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import "./chunk-E2J5KZ6E.mjs";
|
|
2
|
+
|
|
3
|
+
// ../../node_modules/.pnpm/@lexical+dragon@0.25.0/node_modules/@lexical/dragon/LexicalDragon.dev.mjs
|
|
4
|
+
import { $getSelection, $isRangeSelection, $isTextNode } from "lexical";
|
|
5
|
+
function registerDragonSupport(editor) {
|
|
6
|
+
const origin = window.location.origin;
|
|
7
|
+
const handler = (event) => {
|
|
8
|
+
if (event.origin !== origin) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const rootElement = editor.getRootElement();
|
|
12
|
+
if (document.activeElement !== rootElement) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const data = event.data;
|
|
16
|
+
if (typeof data === "string") {
|
|
17
|
+
let parsedData;
|
|
18
|
+
try {
|
|
19
|
+
parsedData = JSON.parse(data);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (parsedData && parsedData.protocol === "nuanria_messaging" && parsedData.type === "request") {
|
|
24
|
+
const payload = parsedData.payload;
|
|
25
|
+
if (payload && payload.functionId === "makeChanges") {
|
|
26
|
+
const args = payload.args;
|
|
27
|
+
if (args) {
|
|
28
|
+
const [elementStart, elementLength, text, selStart, selLength, formatCommand] = args;
|
|
29
|
+
editor.update(() => {
|
|
30
|
+
const selection = $getSelection();
|
|
31
|
+
if ($isRangeSelection(selection)) {
|
|
32
|
+
const anchor = selection.anchor;
|
|
33
|
+
let anchorNode = anchor.getNode();
|
|
34
|
+
let setSelStart = 0;
|
|
35
|
+
let setSelEnd = 0;
|
|
36
|
+
if ($isTextNode(anchorNode)) {
|
|
37
|
+
if (elementStart >= 0 && elementLength >= 0) {
|
|
38
|
+
setSelStart = elementStart;
|
|
39
|
+
setSelEnd = elementStart + elementLength;
|
|
40
|
+
selection.setTextNodeRange(anchorNode, setSelStart, anchorNode, setSelEnd);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (setSelStart !== setSelEnd || text !== "") {
|
|
44
|
+
selection.insertRawText(text);
|
|
45
|
+
anchorNode = anchor.getNode();
|
|
46
|
+
}
|
|
47
|
+
if ($isTextNode(anchorNode)) {
|
|
48
|
+
setSelStart = selStart;
|
|
49
|
+
setSelEnd = selStart + selLength;
|
|
50
|
+
const anchorNodeTextLength = anchorNode.getTextContentSize();
|
|
51
|
+
setSelStart = setSelStart > anchorNodeTextLength ? anchorNodeTextLength : setSelStart;
|
|
52
|
+
setSelEnd = setSelEnd > anchorNodeTextLength ? anchorNodeTextLength : setSelEnd;
|
|
53
|
+
selection.setTextNodeRange(anchorNode, setSelStart, anchorNode, setSelEnd);
|
|
54
|
+
}
|
|
55
|
+
event.stopImmediatePropagation();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("message", handler, true);
|
|
64
|
+
return () => {
|
|
65
|
+
window.removeEventListener("message", handler, true);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
registerDragonSupport
|
|
70
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "./chunk-E2J5KZ6E.mjs";
|
|
2
|
+
|
|
3
|
+
// ../../node_modules/.pnpm/@lexical+dragon@0.25.0/node_modules/@lexical/dragon/LexicalDragon.prod.mjs
|
|
4
|
+
import { $getSelection as e, $isRangeSelection as t, $isTextNode as n } from "lexical";
|
|
5
|
+
function o(o2) {
|
|
6
|
+
const i = window.location.origin, a = (a2) => {
|
|
7
|
+
if (a2.origin !== i) return;
|
|
8
|
+
const r = o2.getRootElement();
|
|
9
|
+
if (document.activeElement !== r) return;
|
|
10
|
+
const s = a2.data;
|
|
11
|
+
if ("string" == typeof s) {
|
|
12
|
+
let i2;
|
|
13
|
+
try {
|
|
14
|
+
i2 = JSON.parse(s);
|
|
15
|
+
} catch (e2) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (i2 && "nuanria_messaging" === i2.protocol && "request" === i2.type) {
|
|
19
|
+
const r2 = i2.payload;
|
|
20
|
+
if (r2 && "makeChanges" === r2.functionId) {
|
|
21
|
+
const i3 = r2.args;
|
|
22
|
+
if (i3) {
|
|
23
|
+
const [r3, s2, c, g, d, f] = i3;
|
|
24
|
+
o2.update(() => {
|
|
25
|
+
const o3 = e();
|
|
26
|
+
if (t(o3)) {
|
|
27
|
+
const e2 = o3.anchor;
|
|
28
|
+
let t2 = e2.getNode(), i4 = 0, f2 = 0;
|
|
29
|
+
if (n(t2) && r3 >= 0 && s2 >= 0 && (i4 = r3, f2 = r3 + s2, o3.setTextNodeRange(t2, i4, t2, f2)), i4 === f2 && "" === c || (o3.insertRawText(c), t2 = e2.getNode()), n(t2)) {
|
|
30
|
+
i4 = g, f2 = g + d;
|
|
31
|
+
const e3 = t2.getTextContentSize();
|
|
32
|
+
i4 = i4 > e3 ? e3 : i4, f2 = f2 > e3 ? e3 : f2, o3.setTextNodeRange(t2, i4, t2, f2);
|
|
33
|
+
}
|
|
34
|
+
a2.stopImmediatePropagation();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return window.addEventListener("message", a, true), () => {
|
|
43
|
+
window.removeEventListener("message", a, true);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
o as registerDragonSupport
|
|
48
|
+
};
|