@kopexa/tiptap 17.3.0 → 17.4.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/dist/chunk-4HO7BWDC.mjs +89 -0
- package/dist/chunk-552JLRNB.mjs +35 -0
- package/dist/chunk-5SMDMQDF.mjs +34 -0
- package/dist/{chunk-XKWTI3MA.mjs → chunk-DQK6PA4U.mjs} +11 -2
- package/dist/{chunk-LWU4F64F.mjs → chunk-GDDWW2IQ.mjs} +37 -12
- package/dist/{chunk-NSYSECKW.mjs → chunk-GL3RTIER.mjs} +1 -0
- package/dist/chunk-H7MS2UMO.mjs +168 -0
- package/dist/chunk-JVSH5T4B.mjs +72 -0
- package/dist/chunk-Q5FK7SFY.mjs +75 -0
- package/dist/chunk-QIELBKP3.mjs +104 -0
- package/dist/extensions/variable/extract-variables.d.mts +16 -0
- package/dist/extensions/variable/extract-variables.d.ts +16 -0
- package/dist/extensions/variable/extract-variables.js +58 -0
- package/dist/extensions/variable/extract-variables.mjs +7 -0
- package/dist/extensions/variable/index.d.mts +38 -0
- package/dist/extensions/variable/index.d.ts +38 -0
- package/dist/extensions/variable/index.js +190 -0
- package/dist/extensions/variable/index.mjs +11 -0
- package/dist/extensions/variable/messages.d.mts +69 -0
- package/dist/extensions/variable/messages.d.ts +69 -0
- package/dist/extensions/variable/messages.js +98 -0
- package/dist/extensions/variable/messages.mjs +7 -0
- package/dist/extensions/variable/variable-context.d.mts +56 -0
- package/dist/extensions/variable/variable-context.d.ts +56 -0
- package/dist/extensions/variable/variable-context.js +70 -0
- package/dist/extensions/variable/variable-context.mjs +12 -0
- package/dist/extensions/variable/variable-filler-dialog.d.mts +43 -0
- package/dist/extensions/variable/variable-filler-dialog.d.ts +43 -0
- package/dist/extensions/variable/variable-filler-dialog.js +207 -0
- package/dist/extensions/variable/variable-filler-dialog.mjs +9 -0
- package/dist/extensions/variable/variable-suggestion.d.mts +31 -0
- package/dist/extensions/variable/variable-suggestion.d.ts +31 -0
- package/dist/extensions/variable/variable-suggestion.js +615 -0
- package/dist/extensions/variable/variable-suggestion.mjs +14 -0
- package/dist/extensions/variable/variable-view.d.mts +13 -0
- package/dist/extensions/variable/variable-view.d.ts +13 -0
- package/dist/extensions/variable/variable-view.js +110 -0
- package/dist/extensions/variable/variable-view.mjs +11 -0
- package/dist/hooks/use-create-editor.d.mts +8 -2
- package/dist/hooks/use-create-editor.d.ts +8 -2
- package/dist/hooks/use-create-editor.js +163 -7
- package/dist/hooks/use-create-editor.mjs +4 -1
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1829 -1260
- package/dist/index.mjs +35 -9
- package/dist/presets/basic/editor-header.mjs +3 -3
- package/dist/presets/basic/index.d.mts +12 -1
- package/dist/presets/basic/index.d.ts +12 -1
- package/dist/presets/basic/index.js +4209 -3859
- package/dist/presets/basic/index.mjs +12 -8
- package/dist/ui/bubble-menu/index.js +1 -0
- package/dist/ui/bubble-menu/index.mjs +1 -1
- package/package.json +24 -24
- package/dist/{chunk-FDPXD6VC.mjs → chunk-RFWNKE7D.mjs} +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
messages
|
|
4
|
+
} from "./chunk-Q5FK7SFY.mjs";
|
|
5
|
+
|
|
6
|
+
// src/extensions/variable/variable-filler-dialog.tsx
|
|
7
|
+
import { Button } from "@kopexa/button";
|
|
8
|
+
import { Dialog } from "@kopexa/dialog";
|
|
9
|
+
import { Input } from "@kopexa/input";
|
|
10
|
+
import { Label } from "@kopexa/label";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { useIntl } from "react-intl";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
function VariableFillerDialog({
|
|
15
|
+
open,
|
|
16
|
+
onOpenChange,
|
|
17
|
+
variables,
|
|
18
|
+
values,
|
|
19
|
+
onSave,
|
|
20
|
+
title,
|
|
21
|
+
description
|
|
22
|
+
}) {
|
|
23
|
+
const intl = useIntl();
|
|
24
|
+
const [localValues, setLocalValues] = React.useState(
|
|
25
|
+
{}
|
|
26
|
+
);
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (open) {
|
|
29
|
+
setLocalValues({ ...values });
|
|
30
|
+
}
|
|
31
|
+
}, [open, values]);
|
|
32
|
+
const handleChange = React.useCallback((name, value) => {
|
|
33
|
+
setLocalValues((prev) => ({
|
|
34
|
+
...prev,
|
|
35
|
+
[name]: value
|
|
36
|
+
}));
|
|
37
|
+
}, []);
|
|
38
|
+
const handleSave = React.useCallback(() => {
|
|
39
|
+
onSave(localValues);
|
|
40
|
+
onOpenChange(false);
|
|
41
|
+
}, [localValues, onSave, onOpenChange]);
|
|
42
|
+
const handleCancel = React.useCallback(() => {
|
|
43
|
+
setLocalValues({ ...values });
|
|
44
|
+
onOpenChange(false);
|
|
45
|
+
}, [values, onOpenChange]);
|
|
46
|
+
const groupedVariables = React.useMemo(() => {
|
|
47
|
+
return variables.reduce(
|
|
48
|
+
(acc, v) => {
|
|
49
|
+
const cat = v.category || intl.formatMessage(messages.category_other);
|
|
50
|
+
if (!acc[cat]) acc[cat] = [];
|
|
51
|
+
acc[cat].push(v);
|
|
52
|
+
return acc;
|
|
53
|
+
},
|
|
54
|
+
{}
|
|
55
|
+
);
|
|
56
|
+
}, [variables, intl]);
|
|
57
|
+
const filledCount = React.useMemo(() => {
|
|
58
|
+
return variables.filter((v) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return (_a = localValues[v.name]) == null ? void 0 : _a.trim();
|
|
61
|
+
}).length;
|
|
62
|
+
}, [variables, localValues]);
|
|
63
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange, size: "md", children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
|
64
|
+
/* @__PURE__ */ jsxs(Dialog.Header, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Dialog.Title, { children: title || intl.formatMessage(messages.filler_title) }),
|
|
66
|
+
description && /* @__PURE__ */ jsx(Dialog.Description, { children: description })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsx("div", { className: "space-y-6", children: Object.entries(groupedVariables).map(([category, vars]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
69
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3", children: category }),
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: vars.map((v) => /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: `var-${v.name}`, className: "text-sm", children: [
|
|
72
|
+
v.label,
|
|
73
|
+
v.description && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-muted-foreground font-normal", children: v.description })
|
|
74
|
+
] }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Input,
|
|
77
|
+
{
|
|
78
|
+
id: `var-${v.name}`,
|
|
79
|
+
placeholder: v.fallback || `{{${v.name}}}`,
|
|
80
|
+
value: localValues[v.name] || "",
|
|
81
|
+
onChange: (e) => handleChange(v.name, e.target.value)
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }, v.name)) })
|
|
85
|
+
] }, category)) }) }),
|
|
86
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { className: "flex items-center justify-between", children: [
|
|
87
|
+
/* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
88
|
+
filledCount,
|
|
89
|
+
" / ",
|
|
90
|
+
variables.length,
|
|
91
|
+
" ",
|
|
92
|
+
intl.formatMessage(messages.filler_filled)
|
|
93
|
+
] }),
|
|
94
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: handleCancel, children: intl.formatMessage(messages.cancel) }),
|
|
96
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleSave, children: intl.formatMessage(messages.save) })
|
|
97
|
+
] })
|
|
98
|
+
] })
|
|
99
|
+
] }) });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
VariableFillerDialog
|
|
104
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
|
+
import { VariableDefinition } from './variable-suggestion.mjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import '@tiptap/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extracts all variable nodes from a TipTap document.
|
|
8
|
+
*
|
|
9
|
+
* Recursively scans the document content and returns unique variables.
|
|
10
|
+
*
|
|
11
|
+
* @param content - The TipTap JSONContent to scan
|
|
12
|
+
* @returns Array of unique variable definitions found in the document
|
|
13
|
+
*/
|
|
14
|
+
declare function extractVariablesFromContent(content: JSONContent | undefined): VariableDefinition[];
|
|
15
|
+
|
|
16
|
+
export { extractVariablesFromContent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
|
+
import { VariableDefinition } from './variable-suggestion.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import '@tiptap/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extracts all variable nodes from a TipTap document.
|
|
8
|
+
*
|
|
9
|
+
* Recursively scans the document content and returns unique variables.
|
|
10
|
+
*
|
|
11
|
+
* @param content - The TipTap JSONContent to scan
|
|
12
|
+
* @returns Array of unique variable definitions found in the document
|
|
13
|
+
*/
|
|
14
|
+
declare function extractVariablesFromContent(content: JSONContent | undefined): VariableDefinition[];
|
|
15
|
+
|
|
16
|
+
export { extractVariablesFromContent };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/extensions/variable/extract-variables.ts
|
|
22
|
+
var extract_variables_exports = {};
|
|
23
|
+
__export(extract_variables_exports, {
|
|
24
|
+
extractVariablesFromContent: () => extractVariablesFromContent
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(extract_variables_exports);
|
|
27
|
+
function extractVariablesFromContent(content) {
|
|
28
|
+
if (!content) return [];
|
|
29
|
+
const variables = /* @__PURE__ */ new Map();
|
|
30
|
+
function scan(node) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (node.type === "variable" && ((_a = node.attrs) == null ? void 0 : _a.name)) {
|
|
33
|
+
const name = node.attrs.name;
|
|
34
|
+
if (!variables.has(name)) {
|
|
35
|
+
variables.set(name, {
|
|
36
|
+
name,
|
|
37
|
+
label: formatVariableName(name),
|
|
38
|
+
category: node.attrs.category || void 0,
|
|
39
|
+
fallback: node.attrs.fallback || void 0
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (node.content && Array.isArray(node.content)) {
|
|
44
|
+
for (const child of node.content) {
|
|
45
|
+
scan(child);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
scan(content);
|
|
50
|
+
return Array.from(variables.values());
|
|
51
|
+
}
|
|
52
|
+
function formatVariableName(name) {
|
|
53
|
+
return name.replace(/([A-Z])/g, " $1").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).replace(/\s+/g, " ").trim();
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
extractVariablesFromContent
|
|
58
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface VariableNodeAttrs {
|
|
4
|
+
/** The variable name/key (e.g., "companyName") */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Optional fallback value if variable is not resolved */
|
|
7
|
+
fallback?: string;
|
|
8
|
+
/** Optional category for grouping (e.g., "company", "user", "date") */
|
|
9
|
+
category?: string;
|
|
10
|
+
}
|
|
11
|
+
interface VariableOptions {
|
|
12
|
+
/**
|
|
13
|
+
* HTML attributes to add to the variable element.
|
|
14
|
+
*/
|
|
15
|
+
HTMLAttributes: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
declare module "@tiptap/core" {
|
|
18
|
+
interface Commands<ReturnType> {
|
|
19
|
+
variable: {
|
|
20
|
+
/**
|
|
21
|
+
* Insert a variable node
|
|
22
|
+
*/
|
|
23
|
+
insertVariable: (attrs: VariableNodeAttrs) => ReturnType;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* VariableNode Extension
|
|
29
|
+
*
|
|
30
|
+
* Allows inserting template variables like {{companyName}} into documents.
|
|
31
|
+
* Variables are rendered as inline chips and can be resolved when rendering
|
|
32
|
+
* the final document.
|
|
33
|
+
*
|
|
34
|
+
* Triggered by typing `{{` which opens a suggestion menu.
|
|
35
|
+
*/
|
|
36
|
+
declare const VariableNode: Node<VariableOptions, any>;
|
|
37
|
+
|
|
38
|
+
export { VariableNode, type VariableNodeAttrs, type VariableOptions, VariableNode as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
interface VariableNodeAttrs {
|
|
4
|
+
/** The variable name/key (e.g., "companyName") */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Optional fallback value if variable is not resolved */
|
|
7
|
+
fallback?: string;
|
|
8
|
+
/** Optional category for grouping (e.g., "company", "user", "date") */
|
|
9
|
+
category?: string;
|
|
10
|
+
}
|
|
11
|
+
interface VariableOptions {
|
|
12
|
+
/**
|
|
13
|
+
* HTML attributes to add to the variable element.
|
|
14
|
+
*/
|
|
15
|
+
HTMLAttributes: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
declare module "@tiptap/core" {
|
|
18
|
+
interface Commands<ReturnType> {
|
|
19
|
+
variable: {
|
|
20
|
+
/**
|
|
21
|
+
* Insert a variable node
|
|
22
|
+
*/
|
|
23
|
+
insertVariable: (attrs: VariableNodeAttrs) => ReturnType;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* VariableNode Extension
|
|
29
|
+
*
|
|
30
|
+
* Allows inserting template variables like {{companyName}} into documents.
|
|
31
|
+
* Variables are rendered as inline chips and can be resolved when rendering
|
|
32
|
+
* the final document.
|
|
33
|
+
*
|
|
34
|
+
* Triggered by typing `{{` which opens a suggestion menu.
|
|
35
|
+
*/
|
|
36
|
+
declare const VariableNode: Node<VariableOptions, any>;
|
|
37
|
+
|
|
38
|
+
export { VariableNode, type VariableNodeAttrs, type VariableOptions, VariableNode as default };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/extensions/variable/index.ts
|
|
32
|
+
var variable_exports = {};
|
|
33
|
+
__export(variable_exports, {
|
|
34
|
+
VariableNode: () => VariableNode,
|
|
35
|
+
default: () => variable_default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(variable_exports);
|
|
38
|
+
var import_core = require("@tiptap/core");
|
|
39
|
+
var import_react2 = require("@tiptap/react");
|
|
40
|
+
|
|
41
|
+
// src/extensions/variable/variable-view.tsx
|
|
42
|
+
var import_theme = require("@kopexa/theme");
|
|
43
|
+
var import_react = require("@tiptap/react");
|
|
44
|
+
|
|
45
|
+
// src/extensions/variable/variable-context.tsx
|
|
46
|
+
var React = __toESM(require("react"));
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var VariableContext = React.createContext(null);
|
|
49
|
+
function useVariables() {
|
|
50
|
+
return React.useContext(VariableContext);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/extensions/variable/variable-view.tsx
|
|
54
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
55
|
+
function VariableNodeView({ node, editor }) {
|
|
56
|
+
var _a;
|
|
57
|
+
const attrs = node.attrs;
|
|
58
|
+
const { name, fallback, category } = attrs;
|
|
59
|
+
const context = useVariables();
|
|
60
|
+
const isEditable = (0, import_react.useEditorState)({
|
|
61
|
+
editor,
|
|
62
|
+
selector: ({ editor: e }) => {
|
|
63
|
+
var _a2;
|
|
64
|
+
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : true;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const resolvedValue = (_a = context == null ? void 0 : context.resolveVariable) == null ? void 0 : _a.call(context, name);
|
|
68
|
+
const hasValue = resolvedValue !== void 0 && resolvedValue !== "";
|
|
69
|
+
const displayValue = resolvedValue || fallback;
|
|
70
|
+
const styles = (0, import_theme.variableNode)({ resolved: hasValue });
|
|
71
|
+
if (!isEditable && hasValue) {
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
73
|
+
import_react.NodeViewWrapper,
|
|
74
|
+
{
|
|
75
|
+
as: "span",
|
|
76
|
+
"data-type": "variable",
|
|
77
|
+
"data-name": name,
|
|
78
|
+
style: { userSelect: "text" },
|
|
79
|
+
children: displayValue
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
84
|
+
import_react.NodeViewWrapper,
|
|
85
|
+
{
|
|
86
|
+
as: "span",
|
|
87
|
+
className: styles.wrapper(),
|
|
88
|
+
"data-type": "variable",
|
|
89
|
+
"data-name": name,
|
|
90
|
+
"data-category": category,
|
|
91
|
+
"data-resolved": hasValue ? "true" : "false",
|
|
92
|
+
children: hasValue ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.chip(), title: `{{${name}}}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.value(), children: displayValue }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
className: styles.chip(),
|
|
96
|
+
title: fallback ? `Fallback: ${fallback}` : void 0,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.bracket(), children: "{" }),
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.bracket(), children: "{" }),
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.name(), children: name }),
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.bracket(), children: "}" }),
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.bracket(), children: "}" })
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/extensions/variable/index.ts
|
|
111
|
+
var VariableNode = import_core.Node.create({
|
|
112
|
+
name: "variable",
|
|
113
|
+
group: "inline",
|
|
114
|
+
inline: true,
|
|
115
|
+
atom: true,
|
|
116
|
+
selectable: true,
|
|
117
|
+
draggable: true,
|
|
118
|
+
addOptions() {
|
|
119
|
+
return {
|
|
120
|
+
HTMLAttributes: {}
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
addAttributes() {
|
|
124
|
+
return {
|
|
125
|
+
name: {
|
|
126
|
+
default: "",
|
|
127
|
+
parseHTML: (element) => element.getAttribute("data-name"),
|
|
128
|
+
renderHTML: (attributes) => ({
|
|
129
|
+
"data-name": attributes.name
|
|
130
|
+
})
|
|
131
|
+
},
|
|
132
|
+
fallback: {
|
|
133
|
+
default: void 0,
|
|
134
|
+
parseHTML: (element) => element.getAttribute("data-fallback"),
|
|
135
|
+
renderHTML: (attributes) => {
|
|
136
|
+
if (!attributes.fallback) return {};
|
|
137
|
+
return {
|
|
138
|
+
"data-fallback": attributes.fallback
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
category: {
|
|
143
|
+
default: void 0,
|
|
144
|
+
parseHTML: (element) => element.getAttribute("data-category"),
|
|
145
|
+
renderHTML: (attributes) => {
|
|
146
|
+
if (!attributes.category) return {};
|
|
147
|
+
return {
|
|
148
|
+
"data-category": attributes.category
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
parseHTML() {
|
|
155
|
+
return [
|
|
156
|
+
{
|
|
157
|
+
tag: 'span[data-type="variable"]'
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
},
|
|
161
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
162
|
+
const attrs = node.attrs;
|
|
163
|
+
return [
|
|
164
|
+
"span",
|
|
165
|
+
(0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
|
|
166
|
+
"data-type": "variable",
|
|
167
|
+
class: "variable-node"
|
|
168
|
+
}),
|
|
169
|
+
`{{${attrs.name}}}`
|
|
170
|
+
];
|
|
171
|
+
},
|
|
172
|
+
addNodeView() {
|
|
173
|
+
return (0, import_react2.ReactNodeViewRenderer)(VariableNodeView);
|
|
174
|
+
},
|
|
175
|
+
addCommands() {
|
|
176
|
+
return {
|
|
177
|
+
insertVariable: (attrs) => ({ commands }) => {
|
|
178
|
+
return commands.insertContent({
|
|
179
|
+
type: this.name,
|
|
180
|
+
attrs
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
var variable_default = VariableNode;
|
|
187
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
188
|
+
0 && (module.exports = {
|
|
189
|
+
VariableNode
|
|
190
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
title: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
insert: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
empty_state: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
hint: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
save: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
cancel: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
category_company: {
|
|
33
|
+
id: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
category_user: {
|
|
38
|
+
id: string;
|
|
39
|
+
defaultMessage: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
category_date: {
|
|
43
|
+
id: string;
|
|
44
|
+
defaultMessage: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
category_document: {
|
|
48
|
+
id: string;
|
|
49
|
+
defaultMessage: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
category_other: {
|
|
53
|
+
id: string;
|
|
54
|
+
defaultMessage: string;
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
filler_title: {
|
|
58
|
+
id: string;
|
|
59
|
+
defaultMessage: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
filler_filled: {
|
|
63
|
+
id: string;
|
|
64
|
+
defaultMessage: string;
|
|
65
|
+
description: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { messages };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
title: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
insert: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
empty_state: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
hint: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
save: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
cancel: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
category_company: {
|
|
33
|
+
id: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
category_user: {
|
|
38
|
+
id: string;
|
|
39
|
+
defaultMessage: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
category_date: {
|
|
43
|
+
id: string;
|
|
44
|
+
defaultMessage: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
category_document: {
|
|
48
|
+
id: string;
|
|
49
|
+
defaultMessage: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
category_other: {
|
|
53
|
+
id: string;
|
|
54
|
+
defaultMessage: string;
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
filler_title: {
|
|
58
|
+
id: string;
|
|
59
|
+
defaultMessage: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
filler_filled: {
|
|
63
|
+
id: string;
|
|
64
|
+
defaultMessage: string;
|
|
65
|
+
description: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { messages };
|