payloadcms-dynamic-value-richtext 1.0.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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +10 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +10 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/server.d.ts +2 -0
- package/dist/exports/server.js +4 -0
- package/dist/exports/server.js.map +1 -0
- package/dist/features/DynamicValue/feature.client.d.ts +8 -0
- package/dist/features/DynamicValue/feature.client.d.ts.map +10 -0
- package/dist/features/DynamicValue/feature.client.js +220 -0
- package/dist/features/DynamicValue/feature.client.js.map +1 -0
- package/dist/features/DynamicValue/feature.server.d.ts +5 -0
- package/dist/features/DynamicValue/feature.server.d.ts.map +10 -0
- package/dist/features/DynamicValue/feature.server.js +65 -0
- package/dist/features/DynamicValue/feature.server.js.map +1 -0
- package/dist/features/DynamicValue/index.d.ts +3 -0
- package/dist/features/DynamicValue/index.d.ts.map +10 -0
- package/dist/features/DynamicValue/index.js +2 -0
- package/dist/features/DynamicValue/index.js.map +10 -0
- package/dist/features/DynamicValue/types.d.ts +23 -0
- package/dist/features/DynamicValue/types.d.ts.map +10 -0
- package/dist/features/DynamicValue/types.js +3 -0
- package/dist/features/DynamicValue/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +10 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/DynamicValueNode/index.d.ts +26 -0
- package/dist/nodes/DynamicValueNode/index.d.ts.map +10 -0
- package/dist/nodes/DynamicValueNode/index.js +125 -0
- package/dist/nodes/DynamicValueNode/index.js.map +1 -0
- package/package.json +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OD LABS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Payload Dynamic Value Rich Text Plugin
|
|
2
|
+
|
|
3
|
+
A powerful [Payload CMS](https://payloadcms.com) plugin for the Lexical editor that allows you to designate field values as dynamic variables. These variables can be reused throughout your rich text content and are visually represented as interactive badges.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Inline Autocomplete**: Trigger a searchable list of available dynamic fields using `@` (default) or a custom character (like `#`).
|
|
8
|
+
- **Visual Badges**: Variables appear in the editor as clean, non-editable badges with a "VAR" prefix, making them distinct from regular text.
|
|
9
|
+
- **Automatic Field Resolution**: Pull fields automatically from specified Collections and Globals, or provide manually defined fields.
|
|
10
|
+
- **Unit Tokenization**: Variables are treated as single units—selecting or deleting them happens in a single action.
|
|
11
|
+
- **Clipboard Support**: Copy and paste dynamic values between editors or documents while maintaining their data integrity.
|
|
12
|
+
- **Light & Dark Mode**: Seamlessly integrates with Payload's admin UI theme.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add payloadcms-dynamic-value-richtext
|
|
18
|
+
# or
|
|
19
|
+
npm install payloadcms-dynamic-value-richtext
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Basic Setup
|
|
23
|
+
|
|
24
|
+
Add the plugin to your `payload.config.ts`:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { buildConfig } from 'payload'
|
|
28
|
+
import { dynamicValuePlugin } from 'payloadcms-dynamic-value-richtext'
|
|
29
|
+
|
|
30
|
+
export default buildConfig({
|
|
31
|
+
plugins: [
|
|
32
|
+
dynamicValuePlugin({
|
|
33
|
+
collections: ['company-settings', 'sites'],
|
|
34
|
+
globals: ['contact-info'],
|
|
35
|
+
trigger: '@',
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
// ... rest of config
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
In your Lexical editor configuration, add the `DynamicValueFeature` to your list of features:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { DynamicValueFeature } from 'payloadcms-dynamic-value-richtext'
|
|
48
|
+
|
|
49
|
+
// In your collection/global field definition:
|
|
50
|
+
{
|
|
51
|
+
name: 'content',
|
|
52
|
+
type: 'richText',
|
|
53
|
+
editor: lexicalEditor({
|
|
54
|
+
features: ({ defaultFeatures }) => [
|
|
55
|
+
...defaultFeatures,
|
|
56
|
+
DynamicValueFeature(),
|
|
57
|
+
],
|
|
58
|
+
}),
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Plugin Options
|
|
63
|
+
|
|
64
|
+
| Option | Type | Description |
|
|
65
|
+
| :------------ | :----------------- | :---------------------------------------------------------------------- |
|
|
66
|
+
| `collections` | `CollectionSlug[]` | Automatically extract all text-based fields from these collections. |
|
|
67
|
+
| `globals` | `GlobalSlug[]` | Automatically extract all text-based fields from these globals. |
|
|
68
|
+
| `fields` | `Field[]` | Manually provide a list of Payload fields to be used as dynamic values. |
|
|
69
|
+
| `trigger` | `string` | The character that triggers the autocomplete popup. Defaults to `@`. |
|
|
70
|
+
|
|
71
|
+
## How it Works
|
|
72
|
+
|
|
73
|
+
1. **Resolution**: The plugin recursively flattens the fields of your chosen collections and globals. For example, if you have a Global `contact-info` with a field `email`, it becomes available as `contact-info.email`.
|
|
74
|
+
2. **Injection**: When you type the trigger character in the editor, a popup appears showing all available fields.
|
|
75
|
+
3. **Storage**: The variable is stored as a custom `DecoratorNode` in Lexical, which holds a reference to the field path (`value`) and the display label.
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
To run the development environment:
|
|
80
|
+
|
|
81
|
+
1. Clone the repository
|
|
82
|
+
2. Install dependencies: `pnpm install`
|
|
83
|
+
3. Create a `.env` in the `dev` folder (see `.env.example`)
|
|
84
|
+
4. Run development: `pnpm dev`
|
|
85
|
+
|
|
86
|
+
## Ownership
|
|
87
|
+
|
|
88
|
+
Created & Owned by **OD LABS**. This plugin is open and free for use to all under the MIT License.
|
|
89
|
+
|
|
90
|
+
## Contributions
|
|
91
|
+
|
|
92
|
+
Contributions are welcome! If you have ideas for improvements or find any issues, feel free to open a Pull Request or create an Issue.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DynamicValueFeatureClient } from '../features/DynamicValue/feature.client.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DynamicValueFeatureClient } from '../features/DynamicValue/feature.client.js'\n"],"names":["DynamicValueFeatureClient"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,6CAA4C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/server.ts"],"sourcesContent":["export { DynamicValueFeature } from '../features/DynamicValue/feature.server.js'\r\nexport { dynamicValuePlugin } from '../index.js'\r\n"],"names":["DynamicValueFeature","dynamicValuePlugin"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,6CAA4C;AAChF,SAASC,kBAAkB,QAAQ,cAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DynamicValueOption } from './types.js';
|
|
2
|
+
export declare const DynamicValueFeatureClient: import("@payloadcms/richtext-lexical").FeatureProviderProviderClient<{
|
|
3
|
+
options: DynamicValueOption[];
|
|
4
|
+
trigger: string;
|
|
5
|
+
}, {
|
|
6
|
+
options: DynamicValueOption[];
|
|
7
|
+
trigger: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "feature.client.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/features/DynamicValue/feature.client.tsx"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgJrD,eAAO,MAAM,yBAAyB;aAEzB,kBAAkB,EAAE;EAyC/B,CAAC"
|
|
10
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createClientFeature } from '@payloadcms/richtext-lexical/client';
|
|
4
|
+
import { $insertNodes } from '@payloadcms/richtext-lexical/lexical';
|
|
5
|
+
import { useLexicalComposerContext } from '@payloadcms/richtext-lexical/lexical/react/LexicalComposerContext';
|
|
6
|
+
import { LexicalTypeaheadMenuPlugin } from '@payloadcms/richtext-lexical/lexical/react/LexicalTypeaheadMenuPlugin';
|
|
7
|
+
import { AtSign, Hash, Variable } from 'lucide-react';
|
|
8
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
9
|
+
import * as ReactDOM from 'react-dom';
|
|
10
|
+
import { $createDynamicValueNode, DynamicValueNode } from '../../nodes/DynamicValueNode/index.js';
|
|
11
|
+
function useTriggerMatch(trigger) {
|
|
12
|
+
return useCallback((text)=>{
|
|
13
|
+
const triggerIndex = text.lastIndexOf(trigger);
|
|
14
|
+
if (triggerIndex === -1) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const charBeforeTrigger = triggerIndex > 0 ? text[triggerIndex - 1] : null;
|
|
18
|
+
if (charBeforeTrigger && !/[\s(]/.test(charBeforeTrigger)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const matchingString = text.slice(triggerIndex + 1);
|
|
22
|
+
if (/\s/.test(matchingString)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
leadOffset: triggerIndex,
|
|
27
|
+
matchingString,
|
|
28
|
+
replaceableString: trigger + matchingString
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
trigger
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
const DynamicValuePlugin = ({ anchorElem, options: allOptions, trigger })=>{
|
|
35
|
+
const [editor] = useLexicalComposerContext();
|
|
36
|
+
const [queryString, setQueryString] = useState(null);
|
|
37
|
+
const checkForTriggerMatch = useTriggerMatch(trigger);
|
|
38
|
+
const options = useMemo(()=>{
|
|
39
|
+
const searchString = queryString?.toLowerCase() || '';
|
|
40
|
+
return (allOptions || []).filter((option)=>option.label.toLowerCase().includes(searchString) || option.value.toLowerCase().includes(searchString)).map((opt)=>({
|
|
41
|
+
...opt,
|
|
42
|
+
key: opt.value
|
|
43
|
+
}));
|
|
44
|
+
}, [
|
|
45
|
+
queryString,
|
|
46
|
+
allOptions
|
|
47
|
+
]);
|
|
48
|
+
const TypeaheadMenu = LexicalTypeaheadMenuPlugin;
|
|
49
|
+
const IconToUse = trigger === '@' ? AtSign : trigger === '#' ? Hash : Variable;
|
|
50
|
+
return /*#__PURE__*/ _jsx(TypeaheadMenu, {
|
|
51
|
+
anchorElem: anchorElem || (typeof document !== 'undefined' ? document.body : undefined),
|
|
52
|
+
menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex })=>{
|
|
53
|
+
const anchor = anchorElementRef?.current || anchorElem || (typeof document !== 'undefined' ? document.body : null);
|
|
54
|
+
if (!anchor || !options.length) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/ ReactDOM.createPortal(/*#__PURE__*/ _jsxs("div", {
|
|
58
|
+
className: "dynamic-value-popup",
|
|
59
|
+
style: {
|
|
60
|
+
background: 'var(--theme-elevation-100)',
|
|
61
|
+
border: '1px solid var(--theme-elevation-250)',
|
|
62
|
+
borderRadius: '8px',
|
|
63
|
+
boxShadow: '0 8px 32px rgba(0,0,0,0.2)',
|
|
64
|
+
minWidth: '260px',
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
padding: '4px',
|
|
67
|
+
zIndex: 100000
|
|
68
|
+
},
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ _jsx("div", {
|
|
71
|
+
style: {
|
|
72
|
+
borderBottom: '1px solid var(--theme-elevation-150)',
|
|
73
|
+
color: 'var(--theme-text)',
|
|
74
|
+
fontSize: '10px',
|
|
75
|
+
fontWeight: 700,
|
|
76
|
+
letterSpacing: '0.05em',
|
|
77
|
+
marginBottom: '4px',
|
|
78
|
+
opacity: 0.6,
|
|
79
|
+
padding: '10px 14px 6px',
|
|
80
|
+
textTransform: 'uppercase'
|
|
81
|
+
},
|
|
82
|
+
children: "Merge Fields"
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx("div", {
|
|
85
|
+
style: {
|
|
86
|
+
maxHeight: '300px',
|
|
87
|
+
overflowY: 'auto'
|
|
88
|
+
},
|
|
89
|
+
children: options.map((option, index)=>{
|
|
90
|
+
const isSelected = selectedIndex === index;
|
|
91
|
+
return /*#__PURE__*/ _jsxs("button", {
|
|
92
|
+
onClick: ()=>selectOptionAndCleanUp(option),
|
|
93
|
+
onMouseEnter: ()=>setHighlightedIndex(index),
|
|
94
|
+
style: {
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
background: isSelected ? 'var(--theme-primary)' : 'transparent',
|
|
97
|
+
border: 'none',
|
|
98
|
+
borderRadius: '6px',
|
|
99
|
+
color: isSelected ? 'white' : 'var(--theme-text)',
|
|
100
|
+
cursor: 'pointer',
|
|
101
|
+
display: 'flex',
|
|
102
|
+
gap: '10px',
|
|
103
|
+
padding: '8px 12px',
|
|
104
|
+
textAlign: 'left',
|
|
105
|
+
transition: 'all 0.15s ease',
|
|
106
|
+
width: '100%'
|
|
107
|
+
},
|
|
108
|
+
type: "button",
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ _jsx(IconToUse, {
|
|
111
|
+
size: 14,
|
|
112
|
+
style: {
|
|
113
|
+
opacity: isSelected ? 1 : 0.4
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
117
|
+
style: {
|
|
118
|
+
display: 'flex',
|
|
119
|
+
flexDirection: 'column'
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ _jsx("span", {
|
|
123
|
+
style: {
|
|
124
|
+
fontSize: '13px',
|
|
125
|
+
fontWeight: 500
|
|
126
|
+
},
|
|
127
|
+
children: option.label
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsx("span", {
|
|
130
|
+
style: {
|
|
131
|
+
fontFamily: 'var(--font-mono)',
|
|
132
|
+
fontSize: '11px',
|
|
133
|
+
opacity: 0.5
|
|
134
|
+
},
|
|
135
|
+
children: option.value
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}, option.value);
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}), anchor);
|
|
145
|
+
},
|
|
146
|
+
onQueryChange: setQueryString,
|
|
147
|
+
onSelectOption: (option, textNodeToReplace, closeMenu)=>{
|
|
148
|
+
editor.update(()=>{
|
|
149
|
+
if (textNodeToReplace) {
|
|
150
|
+
textNodeToReplace.remove();
|
|
151
|
+
}
|
|
152
|
+
const node = $createDynamicValueNode(option.value, option.label);
|
|
153
|
+
$insertNodes([
|
|
154
|
+
node
|
|
155
|
+
]);
|
|
156
|
+
closeMenu();
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
options: options,
|
|
160
|
+
triggerFn: checkForTriggerMatch
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
export const DynamicValueFeatureClient = createClientFeature(({ props })=>{
|
|
164
|
+
const options = props?.options || [];
|
|
165
|
+
const trigger = props?.trigger || '@';
|
|
166
|
+
const IconToUse = trigger === '@' ? AtSign : trigger === '#' ? Hash : Variable;
|
|
167
|
+
return {
|
|
168
|
+
nodes: [
|
|
169
|
+
DynamicValueNode
|
|
170
|
+
],
|
|
171
|
+
plugins: [
|
|
172
|
+
{
|
|
173
|
+
Component: (pluginProps)=>/*#__PURE__*/ _jsx(DynamicValuePlugin, {
|
|
174
|
+
...pluginProps,
|
|
175
|
+
options: options,
|
|
176
|
+
trigger: trigger
|
|
177
|
+
}),
|
|
178
|
+
position: 'floatingAnchorElem'
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
sanitizedClientFeatureProps: props,
|
|
182
|
+
toolbarFixed: {
|
|
183
|
+
groups: [
|
|
184
|
+
{
|
|
185
|
+
type: 'dropdown',
|
|
186
|
+
ChildComponent: ()=>/*#__PURE__*/ _jsx("div", {
|
|
187
|
+
style: {
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
display: 'flex',
|
|
190
|
+
gap: '4px'
|
|
191
|
+
},
|
|
192
|
+
children: /*#__PURE__*/ _jsx(IconToUse, {
|
|
193
|
+
size: 14,
|
|
194
|
+
style: {
|
|
195
|
+
color: 'var(--theme-text)',
|
|
196
|
+
opacity: 0.7
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}),
|
|
200
|
+
items: options.map((field)=>({
|
|
201
|
+
key: field.value,
|
|
202
|
+
label: field.label,
|
|
203
|
+
onSelect: ({ editor })=>{
|
|
204
|
+
editor.update(()=>{
|
|
205
|
+
const node = $createDynamicValueNode(field.value, field.label);
|
|
206
|
+
$insertNodes([
|
|
207
|
+
node
|
|
208
|
+
]);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
})),
|
|
212
|
+
key: 'dynamicValue',
|
|
213
|
+
order: 99
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=feature.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/DynamicValue/feature.client.tsx"],"sourcesContent":["'use client'\r\nimport { createClientFeature } from '@payloadcms/richtext-lexical/client'\r\nimport { $insertNodes } from '@payloadcms/richtext-lexical/lexical'\r\nimport { useLexicalComposerContext } from '@payloadcms/richtext-lexical/lexical/react/LexicalComposerContext'\r\nimport { LexicalTypeaheadMenuPlugin } from '@payloadcms/richtext-lexical/lexical/react/LexicalTypeaheadMenuPlugin'\r\nimport { AtSign, Hash, Variable } from 'lucide-react'\r\nimport React, { useCallback, useMemo, useState } from 'react'\r\nimport * as ReactDOM from 'react-dom'\r\n\r\nimport type { DynamicValueOption } from './types.js'\r\n\r\nimport { $createDynamicValueNode, DynamicValueNode } from '../../nodes/DynamicValueNode/index.js'\r\n\r\nfunction useTriggerMatch(trigger: string) {\r\n return useCallback(\r\n (text: string) => {\r\n const triggerIndex = text.lastIndexOf(trigger)\r\n if (triggerIndex === -1) {\r\n return null\r\n }\r\n\r\n const charBeforeTrigger = triggerIndex > 0 ? text[triggerIndex - 1] : null\r\n if (charBeforeTrigger && !/[\\s(]/.test(charBeforeTrigger)) {\r\n return null\r\n }\r\n\r\n const matchingString = text.slice(triggerIndex + 1)\r\n if (/\\s/.test(matchingString)) {\r\n return null\r\n }\r\n\r\n return {\r\n leadOffset: triggerIndex,\r\n matchingString,\r\n replaceableString: trigger + matchingString,\r\n }\r\n },\r\n [trigger],\r\n )\r\n}\r\n\r\nconst DynamicValuePlugin: React.FC<{\r\n anchorElem?: HTMLElement\r\n options: DynamicValueOption[]\r\n trigger: string\r\n}> = ({ anchorElem, options: allOptions, trigger }) => {\r\n const [editor] = useLexicalComposerContext()\r\n const [queryString, setQueryString] = useState<null | string>(null)\r\n\r\n const checkForTriggerMatch = useTriggerMatch(trigger)\r\n\r\n const options = useMemo(() => {\r\n const searchString = queryString?.toLowerCase() || ''\r\n return (allOptions || [])\r\n .filter(\r\n (option: DynamicValueOption) =>\r\n option.label.toLowerCase().includes(searchString) ||\r\n option.value.toLowerCase().includes(searchString),\r\n )\r\n .map((opt: DynamicValueOption) => ({\r\n ...opt,\r\n key: opt.value,\r\n }))\r\n }, [queryString, allOptions])\r\n\r\n const TypeaheadMenu = LexicalTypeaheadMenuPlugin as any\r\n\r\n const IconToUse = trigger === '@' ? AtSign : trigger === '#' ? Hash : Variable\r\n\r\n return (\r\n <TypeaheadMenu\r\n anchorElem={anchorElem || (typeof document !== 'undefined' ? document.body : undefined)}\r\n menuRenderFn={(\r\n anchorElementRef: any,\r\n { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }: any,\r\n ) => {\r\n const anchor =\r\n anchorElementRef?.current ||\r\n anchorElem ||\r\n (typeof document !== 'undefined' ? document.body : null)\r\n if (!anchor || !options.length) {\r\n return null\r\n }\r\n\r\n return ReactDOM.createPortal(\r\n <div\r\n className=\"dynamic-value-popup\"\r\n style={{\r\n background: 'var(--theme-elevation-100)',\r\n border: '1px solid var(--theme-elevation-250)',\r\n borderRadius: '8px',\r\n boxShadow: '0 8px 32px rgba(0,0,0,0.2)',\r\n minWidth: '260px',\r\n overflow: 'hidden',\r\n padding: '4px',\r\n zIndex: 100000,\r\n }}\r\n >\r\n <div\r\n style={{\r\n borderBottom: '1px solid var(--theme-elevation-150)',\r\n color: 'var(--theme-text)',\r\n fontSize: '10px',\r\n fontWeight: 700,\r\n letterSpacing: '0.05em',\r\n marginBottom: '4px',\r\n opacity: 0.6,\r\n padding: '10px 14px 6px',\r\n textTransform: 'uppercase',\r\n }}\r\n >\r\n Merge Fields\r\n </div>\r\n <div style={{ maxHeight: '300px', overflowY: 'auto' }}>\r\n {options.map((option, index) => {\r\n const isSelected = selectedIndex === index\r\n return (\r\n <button\r\n key={option.value}\r\n onClick={() => selectOptionAndCleanUp(option)}\r\n onMouseEnter={() => setHighlightedIndex(index)}\r\n style={{\r\n alignItems: 'center',\r\n background: isSelected ? 'var(--theme-primary)' : 'transparent',\r\n border: 'none',\r\n borderRadius: '6px',\r\n color: isSelected ? 'white' : 'var(--theme-text)',\r\n cursor: 'pointer',\r\n display: 'flex',\r\n gap: '10px',\r\n padding: '8px 12px',\r\n textAlign: 'left',\r\n transition: 'all 0.15s ease',\r\n width: '100%',\r\n }}\r\n type=\"button\"\r\n >\r\n <IconToUse size={14} style={{ opacity: isSelected ? 1 : 0.4 }} />\r\n <div style={{ display: 'flex', flexDirection: 'column' }}>\r\n <span style={{ fontSize: '13px', fontWeight: 500 }}>{option.label}</span>\r\n <span\r\n style={{ fontFamily: 'var(--font-mono)', fontSize: '11px', opacity: 0.5 }}\r\n >\r\n {option.value}\r\n </span>\r\n </div>\r\n </button>\r\n )\r\n })}\r\n </div>\r\n </div>,\r\n anchor,\r\n )\r\n }}\r\n onQueryChange={setQueryString}\r\n onSelectOption={(option: any, textNodeToReplace: any, closeMenu: any) => {\r\n editor.update(() => {\r\n if (textNodeToReplace) {\r\n textNodeToReplace.remove()\r\n }\r\n const node = $createDynamicValueNode(option.value, option.label)\r\n $insertNodes([node])\r\n closeMenu()\r\n })\r\n }}\r\n options={options}\r\n triggerFn={checkForTriggerMatch}\r\n />\r\n )\r\n}\r\n\r\nexport const DynamicValueFeatureClient = createClientFeature<\r\n { options: DynamicValueOption[]; trigger: string },\r\n { options: DynamicValueOption[]; trigger: string }\r\n>(({ props }) => {\r\n const options = props?.options || []\r\n const trigger = props?.trigger || '@'\r\n const IconToUse = trigger === '@' ? AtSign : trigger === '#' ? Hash : Variable\r\n\r\n return {\r\n nodes: [DynamicValueNode],\r\n plugins: [\r\n {\r\n Component: (pluginProps) => (\r\n <DynamicValuePlugin {...pluginProps} options={options} trigger={trigger} />\r\n ),\r\n position: 'floatingAnchorElem',\r\n },\r\n ],\r\n sanitizedClientFeatureProps: props,\r\n toolbarFixed: {\r\n groups: [\r\n {\r\n type: 'dropdown',\r\n ChildComponent: () => (\r\n <div style={{ alignItems: 'center', display: 'flex', gap: '4px' }}>\r\n <IconToUse size={14} style={{ color: 'var(--theme-text)', opacity: 0.7 }} />\r\n </div>\r\n ),\r\n items: options.map((field: DynamicValueOption) => ({\r\n key: field.value,\r\n label: field.label,\r\n onSelect: ({ editor }: { editor: any }) => {\r\n editor.update(() => {\r\n const node = $createDynamicValueNode(field.value, field.label)\r\n $insertNodes([node])\r\n })\r\n },\r\n })),\r\n key: 'dynamicValue',\r\n order: 99,\r\n },\r\n ],\r\n },\r\n }\r\n})\r\n"],"names":["createClientFeature","$insertNodes","useLexicalComposerContext","LexicalTypeaheadMenuPlugin","AtSign","Hash","Variable","React","useCallback","useMemo","useState","ReactDOM","$createDynamicValueNode","DynamicValueNode","useTriggerMatch","trigger","text","triggerIndex","lastIndexOf","charBeforeTrigger","test","matchingString","slice","leadOffset","replaceableString","DynamicValuePlugin","anchorElem","options","allOptions","editor","queryString","setQueryString","checkForTriggerMatch","searchString","toLowerCase","filter","option","label","includes","value","map","opt","key","TypeaheadMenu","IconToUse","document","body","undefined","menuRenderFn","anchorElementRef","selectedIndex","selectOptionAndCleanUp","setHighlightedIndex","anchor","current","length","createPortal","div","className","style","background","border","borderRadius","boxShadow","minWidth","overflow","padding","zIndex","borderBottom","color","fontSize","fontWeight","letterSpacing","marginBottom","opacity","textTransform","maxHeight","overflowY","index","isSelected","button","onClick","onMouseEnter","alignItems","cursor","display","gap","textAlign","transition","width","type","size","flexDirection","span","fontFamily","onQueryChange","onSelectOption","textNodeToReplace","closeMenu","update","remove","node","triggerFn","DynamicValueFeatureClient","props","nodes","plugins","Component","pluginProps","position","sanitizedClientFeatureProps","toolbarFixed","groups","ChildComponent","items","field","onSelect","order"],"mappings":"AAAA;;AACA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,YAAY,QAAQ,uCAAsC;AACnE,SAASC,yBAAyB,QAAQ,oEAAmE;AAC7G,SAASC,0BAA0B,QAAQ,wEAAuE;AAClH,SAASC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,eAAc;AACrD,OAAOC,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAC7D,YAAYC,cAAc,YAAW;AAIrC,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,wCAAuC;AAEjG,SAASC,gBAAgBC,OAAe;IACtC,OAAOP,YACL,CAACQ;QACC,MAAMC,eAAeD,KAAKE,WAAW,CAACH;QACtC,IAAIE,iBAAiB,CAAC,GAAG;YACvB,OAAO;QACT;QAEA,MAAME,oBAAoBF,eAAe,IAAID,IAAI,CAACC,eAAe,EAAE,GAAG;QACtE,IAAIE,qBAAqB,CAAC,QAAQC,IAAI,CAACD,oBAAoB;YACzD,OAAO;QACT;QAEA,MAAME,iBAAiBL,KAAKM,KAAK,CAACL,eAAe;QACjD,IAAI,KAAKG,IAA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icValueConfig, DynamicValueOption } from './types.js';
|
|
2
|
+
export declare const DynamicValueFeature: import("@payloadcms/richtext-lexical").FeatureProviderProviderServer<DynamicValueConfig, object, {
|
|
3
|
+
options: DynamicValueOption[];
|
|
4
|
+
trigger: string;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "feature.server.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/features/DynamicValue/feature.server.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEzE,eAAO,MAAM,mBAAmB;aAGnB,kBAAkB,EAAE;EAiD/B,CAAC"
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createNode, createServerFeature } from '@payloadcms/richtext-lexical';
|
|
2
|
+
import { DynamicValueNode } from '../../nodes/DynamicValueNode/index.js';
|
|
3
|
+
export const DynamicValueFeature = createServerFeature({
|
|
4
|
+
feature: ({ config: payloadConfig, props })=>{
|
|
5
|
+
const options = [];
|
|
6
|
+
const trigger = props?.trigger || '@';
|
|
7
|
+
const flattenFields = (fields, prefix = '')=>{
|
|
8
|
+
fields.forEach((field)=>{
|
|
9
|
+
if ('name' in field && field.name && field.type !== 'array' && field.type !== 'blocks') {
|
|
10
|
+
const name = prefix ? `${prefix}.${field.name}` : field.name;
|
|
11
|
+
options.push({
|
|
12
|
+
label: field.label || field.name,
|
|
13
|
+
value: name
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if ('fields' in field && field.fields && Array.isArray(field.fields)) {
|
|
17
|
+
flattenFields(field.fields, 'name' in field && field.name ? prefix ? `${prefix}.${field.name}` : field.name : prefix);
|
|
18
|
+
}
|
|
19
|
+
if (field.type === 'tabs' && field.tabs) {
|
|
20
|
+
field.tabs.forEach((tab)=>{
|
|
21
|
+
flattenFields(tab.fields, prefix);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// 1. Process directly provided fields
|
|
27
|
+
if (props?.fields) {
|
|
28
|
+
flattenFields(props.fields);
|
|
29
|
+
}
|
|
30
|
+
// 2. Process collections
|
|
31
|
+
if (props?.collections && payloadConfig.collections) {
|
|
32
|
+
props.collections.forEach((slug)=>{
|
|
33
|
+
const collection = payloadConfig.collections?.find((c)=>c.slug === slug);
|
|
34
|
+
if (collection) {
|
|
35
|
+
flattenFields(collection.fields, slug);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// 3. Process globals
|
|
40
|
+
if (props?.globals && payloadConfig.globals) {
|
|
41
|
+
props.globals.forEach((slug)=>{
|
|
42
|
+
const global = payloadConfig.globals?.find((g)=>g.slug === slug);
|
|
43
|
+
if (global) {
|
|
44
|
+
flattenFields(global.fields, slug);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
ClientFeature: 'payloadcms-dynamic-value-richtext/client#DynamicValueFeatureClient',
|
|
50
|
+
clientProps: {
|
|
51
|
+
options,
|
|
52
|
+
trigger
|
|
53
|
+
},
|
|
54
|
+
key: 'dynamicValue',
|
|
55
|
+
nodes: [
|
|
56
|
+
createNode({
|
|
57
|
+
node: DynamicValueNode
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
key: 'dynamicValue'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=feature.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/DynamicValue/feature.server.ts"],"sourcesContent":["import type { CollectionSlug, Field, GlobalSlug } from 'payload'\r\n\r\nimport { createNode, createServerFeature } from '@payloadcms/richtext-lexical'\r\n\r\nimport type { DynamicValueConfig, DynamicValueOption } from './types.js'\r\n\r\nimport { DynamicValueNode } from '../../nodes/DynamicValueNode/index.js'\r\n\r\nexport const DynamicValueFeature = createServerFeature<\r\n DynamicValueConfig,\r\n object,\r\n { options: DynamicValueOption[]; trigger: string }\r\n>({\r\n feature: ({ config: payloadConfig, props }) => {\r\n const options: DynamicValueOption[] = []\r\n const trigger = props?.trigger || '@'\r\n\r\n const flattenFields = (fields: Field[], prefix = '') => {\r\n fields.forEach((field) => {\r\n if ('name' in field && field.name && field.type !== 'array' && field.type !== 'blocks') {\r\n const name = prefix ? `${prefix}.${field.name}` : field.name\r\n options.push({\r\n label: (field.label as string) || field.name,\r\n value: name,\r\n })\r\n }\r\n\r\n if ('fields' in field && field.fields && Array.isArray(field.fields)) {\r\n flattenFields(\r\n field.fields,\r\n 'name' in field && field.name\r\n ? prefix\r\n ? `${prefix}.${field.name}`\r\n : field.name\r\n : prefix,\r\n )\r\n }\r\n\r\n if (field.type === 'tabs' && field.tabs) {\r\n field.tabs.forEach((tab) => {\r\n flattenFields(tab.fields, prefix)\r\n })\r\n }\r\n })\r\n }\r\n\r\n // 1. Process directly provided fields\r\n if (props?.fields) {\r\n flattenFields(props.fields)\r\n }\r\n\r\n // 2. Process collections\r\n if (props?.collections && payloadConfig.collections) {\r\n props.collections.forEach((slug: CollectionSlug) => {\r\n const collection = payloadConfig.collections?.find((c) => c.slug === slug)\r\n if (collection) {\r\n flattenFields(collection.fields, slug)\r\n }\r\n })\r\n }\r\n\r\n // 3. Process globals\r\n if (props?.globals && payloadConfig.globals) {\r\n props.globals.forEach((slug: GlobalSlug) => {\r\n const global = payloadConfig.globals?.find((g) => g.slug === slug)\r\n if (global) {\r\n flattenFields(global.fields, slug)\r\n }\r\n })\r\n }\r\n\r\n return {\r\n ClientFeature: 'payloadcms-dynamic-value-richtext/client#DynamicValueFeatureClient',\r\n clientProps: {\r\n options,\r\n trigger,\r\n },\r\n key: 'dynamicValue',\r\n nodes: [\r\n createNode({\r\n node: DynamicValueNode,\r\n }),\r\n ],\r\n }\r\n },\r\n key: 'dynamicValue',\r\n})\r\n"],"names":["createNode","createServerFeature","DynamicValueNode","DynamicValueFeature","feature","config","payloadConfig","props","options","trigger","flattenFields","fields","prefix","forEach","field","name","type","push","label","value","Array","isArray","tabs","tab","collections","slug","collection","find","c","globals","global","g","ClientFeature","clientProps","key","nodes","node"],"mappings":"AAEA,SAASA,UAAU,EAAEC,mBAAmB,QAAQ,+BAA8B;AAI9E,SAASC,gBAAgB,QAAQ,wCAAuC;AAExE,OAAO,MAAMC,sBAAsBF,oBAIjC;IACAG,SAAS,CAAC,EAAEC,QAAQC,aAAa,EAAEC,KAAK,EAAE;QACxC,MAAMC,UAAgC,EAAE;QACxC,MAAMC,UAAUF,OAAOE,WAAW;QAElC,MAAMC,gBAAgB,CAACC,QAAiBC,SAAS,EAAE;YACjDD,OAAOE,OAAO,CAAC,CAACC;gBACd,IAAI,UAAUA,SAASA,MAAMC,IAAI,IAAID,MAAME,IAAI,KAAK,WAAWF,MAAME,IAAI,KAAK,UAAU;oBACtF,MAAMD,OAAOH,SAAS,GAAGA,OAAO,CAAC,EAAEE,MAAMC,IAAI,EAAE,GAAGD,MAAMC,IAAI;oBAC5DP,QAAQS,IAAI,CAAC;wBACXC,OAAO,AAACJ,MAAMI,KAAK,IAAeJ,MAAMC,IAAI;wBAC5CI,OAAOJ;oBACT;gBACF;gBAEA,IAAI,YAAYD,SAASA,MAAMH,MAAM,IAAIS,MAAMC,OAAO,CAACP,MAAMH,MAAM,GAAG;oBACpED,cACEI,MAAMH,MAAM,EACZ,UAAUG,SAASA,MAAMC,IAAI,GACzBH,SACE,GAAGA,OAAO,CAAC,EAAEE,MAAMC,IAAI,EAAE,GACzBD,MAAMC,IAAI,GACZH;gBAER;gBAEA,IAAIE,MAAME,IAAI,KAAK,UAAUF,MAAMQ,IAAI,EAAE;oBACvCR,MAAMQ,IAAI,CAACT,OAAO,CAAC,CAACU;wBAClBb,cAAca,IAAIZ,MAAM,EAAEC;oBAC5B;gBACF;YACF;QACF;QAEA,sCAAsC;QACtC,IAAIL,OAAOI,QAAQ;YACjBD,cAAcH,MAAMI,MAAM;QAC5B;QAEA,yBAAyB;QACzB,IAAIJ,OAAOiB,eAAelB,cAAckB,WAAW,EAAE;YACnDjB,MAAMiB,WAAW,CAACX,OAAO,CAAC,CAACY;gBACzB,MAAMC,aAAapB,cAAckB,WAAW,EAAEG,KAAK,CAACC,IAAMA,EAAEH,IAAI,KAAKA;gBACrE,IAAIC,YAAY;oBACdhB,cAAcgB,WAAWf,MAAM,EAAEc;gBACnC;YACF;QACF;QAEA,qBAAqB;QACrB,IAAIlB,OAAOsB,WAAWvB,cAAcuB,OAAO,EAAE;YAC3CtB,MAAMsB,OAAO,CAAChB,OAAO,CAAC,CAACY;gBACrB,MAAMK,SAASxB,cAAcuB,OAAO,EAAEF,KAAK,CAACI,IAAMA,EAAEN,IAAI,KAAKA;gBAC7D,IAAIK,QAAQ;oBACVpB,cAAcoB,OAAOnB,MAAM,EAAEc;gBAC/B;YACF;QACF;QAEA,OAAO;YACLO,eAAe;YACfC,aAAa;gBACXzB;gBACAC;YACF;YACAyB,KAAK;YACLC,OAAO;gBACLnC,WAAW;oBACToC,MAAMlC;gBACR;aACD;QACH;IACF;IACAgC,KAAK;AACP,GAAE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/features/DynamicValue/index.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CollectionSlug, Field, GlobalSlug } from 'payload';
|
|
2
|
+
export type DynamicValueOption = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type DynamicValueConfig = {
|
|
7
|
+
/**
|
|
8
|
+
* Directly provided fields for dynamic values
|
|
9
|
+
*/
|
|
10
|
+
fields?: Field[];
|
|
11
|
+
/**
|
|
12
|
+
* Collections to pull fields from
|
|
13
|
+
*/
|
|
14
|
+
collections?: CollectionSlug[];
|
|
15
|
+
/**
|
|
16
|
+
* Globals to pull fields from
|
|
17
|
+
*/
|
|
18
|
+
globals?: GlobalSlug[];
|
|
19
|
+
/**
|
|
20
|
+
* The trigger character to use in the editor. Defaults to '@'
|
|
21
|
+
*/
|
|
22
|
+
trigger?: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "types.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/features/DynamicValue/types.ts"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC"
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/features/DynamicValue/types.ts"],"sourcesContent":["import type { CollectionSlug, Field, GlobalSlug } from 'payload'\r\n\r\nexport type DynamicValueOption = {\r\n label: string\r\n value: string\r\n}\r\n\r\nexport type DynamicValueConfig = {\r\n /**\r\n * Directly provided fields for dynamic values\r\n */\r\n fields?: Field[]\r\n /**\r\n * Collections to pull fields from\r\n */\r\n collections?: CollectionSlug[]\r\n /**\r\n * Globals to pull fields from\r\n */\r\n globals?: GlobalSlug[]\r\n /**\r\n * The trigger character to use in the editor. Defaults to '@'\r\n */\r\n trigger?: string\r\n}\r\n"],"names":[],"mappings":"AAOA,WAiBC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
import type { DynamicValueConfig } from './features/DynamicValue/types.js';
|
|
3
|
+
export type { DynamicValueConfig, DynamicValueOption } from './features/DynamicValue/types.js';
|
|
4
|
+
export declare const dynamicValuePlugin: (pluginOptions: DynamicValueConfig) => (config: Config) => Config;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\nimport type { DynamicValueConfig } from './features/DynamicValue/types.js'\n\nexport type { DynamicValueConfig, DynamicValueOption } from './features/DynamicValue/types.js'\n\nexport const dynamicValuePlugin =\n (pluginOptions: DynamicValueConfig) =>\n (config: Config): Config => {\n // Standard plugin wrapper\n return config\n }\n"],"names":["dynamicValuePlugin","pluginOptions","config"],"mappings":"AAKA,OAAO,MAAMA,qBACX,CAACC,gBACD,CAACC;QACC,0BAA0B;QAC1B,OAAOA;IACT,EAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DecoratorNode, type DOMConversionMap, type DOMExportOutput, type LexicalNode, type NodeKey, type SerializedLexicalNode, type Spread } from '@payloadcms/richtext-lexical/lexical';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type SerializedDynamicValueNode = Spread<{
|
|
4
|
+
field: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
}, SerializedLexicalNode>;
|
|
7
|
+
export declare class DynamicValueNode extends DecoratorNode<React.ReactNode> {
|
|
8
|
+
__field: string;
|
|
9
|
+
__label: string;
|
|
10
|
+
constructor(field: string, label?: string, key?: NodeKey);
|
|
11
|
+
static clone(node: DynamicValueNode): DynamicValueNode;
|
|
12
|
+
static getType(): string;
|
|
13
|
+
static importDOM(): DOMConversionMap | null;
|
|
14
|
+
static importJSON(serializedNode: SerializedDynamicValueNode): DynamicValueNode;
|
|
15
|
+
createDOM(): HTMLElement;
|
|
16
|
+
decorate(): React.ReactNode;
|
|
17
|
+
exportDOM(): DOMExportOutput;
|
|
18
|
+
exportJSON(): SerializedDynamicValueNode;
|
|
19
|
+
getField(): string;
|
|
20
|
+
getTextContent(): string;
|
|
21
|
+
isInline(): boolean;
|
|
22
|
+
isToken(): boolean;
|
|
23
|
+
updateDOM(): boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function $createDynamicValueNode(field: string, label?: string): DynamicValueNode;
|
|
26
|
+
export declare function $isDynamicValueNode(node: LexicalNode | null | undefined): node is DynamicValueNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources": [
|
|
6
|
+
"../../../src/nodes/DynamicValueNode/index.tsx"
|
|
7
|
+
],
|
|
8
|
+
"names": [],
|
|
9
|
+
"mappings": "AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAC7C;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,qBAAqB,CACtB,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;gBAI1C,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO;IAMxD,MAAM,CAAC,UAAU,CACf,cAAc,EAAE,0BAA0B,GACzC,gBAAgB;IAInB,UAAU,IAAI,0BAA0B;IASxC,SAAS,IAAI,WAAW;IAMxB,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,KAAK,CAAC,SAAS;IA4B3B,QAAQ,IAAI,MAAM;CAGnB;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,gBAAgB,CAElB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,gBAAgB,CAE1B"
|
|
10
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DecoratorNode } from '@payloadcms/richtext-lexical/lexical';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export class DynamicValueNode extends DecoratorNode {
|
|
5
|
+
__field;
|
|
6
|
+
__label;
|
|
7
|
+
constructor(field, label, key){
|
|
8
|
+
super(key);
|
|
9
|
+
this.__field = field;
|
|
10
|
+
this.__label = label ?? field;
|
|
11
|
+
}
|
|
12
|
+
static clone(node) {
|
|
13
|
+
return new DynamicValueNode(node.__field, node.__label, node.getKey());
|
|
14
|
+
}
|
|
15
|
+
static getType() {
|
|
16
|
+
return 'dynamic-value';
|
|
17
|
+
}
|
|
18
|
+
static importDOM() {
|
|
19
|
+
return {
|
|
20
|
+
span: (domNode)=>{
|
|
21
|
+
if (!domNode.hasAttribute('data-payload-dynamic-value')) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
conversion: (domNode)=>{
|
|
26
|
+
const field = domNode.getAttribute('data-payload-dynamic-field');
|
|
27
|
+
const label = domNode.textContent || undefined;
|
|
28
|
+
if (field) {
|
|
29
|
+
return {
|
|
30
|
+
node: $createDynamicValueNode(field, label)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
node: null
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
priority: 1
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static importJSON(serializedNode) {
|
|
43
|
+
return $createDynamicValueNode(serializedNode.field, serializedNode.label);
|
|
44
|
+
}
|
|
45
|
+
createDOM() {
|
|
46
|
+
const span = document.createElement('span');
|
|
47
|
+
span.style.display = 'inline-block';
|
|
48
|
+
span.className = 'payload-dynamic-value-node';
|
|
49
|
+
return span;
|
|
50
|
+
}
|
|
51
|
+
decorate() {
|
|
52
|
+
return /*#__PURE__*/ _jsxs("span", {
|
|
53
|
+
contentEditable: false,
|
|
54
|
+
style: {
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
backgroundColor: 'var(--theme-elevation-150)',
|
|
57
|
+
border: '1px solid var(--theme-elevation-300)',
|
|
58
|
+
borderRadius: '4px',
|
|
59
|
+
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
|
|
60
|
+
color: 'var(--theme-text)',
|
|
61
|
+
cursor: 'default',
|
|
62
|
+
display: 'inline-flex',
|
|
63
|
+
fontFamily: 'var(--font-mono, monospace)',
|
|
64
|
+
fontSize: '0.85em',
|
|
65
|
+
fontWeight: 600,
|
|
66
|
+
margin: '0 2px',
|
|
67
|
+
padding: '1px 6px',
|
|
68
|
+
userSelect: 'none',
|
|
69
|
+
verticalAlign: 'middle'
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ _jsx("span", {
|
|
73
|
+
style: {
|
|
74
|
+
color: 'var(--theme-primary)',
|
|
75
|
+
fontSize: '0.8em',
|
|
76
|
+
marginRight: '4px',
|
|
77
|
+
opacity: 0.4
|
|
78
|
+
},
|
|
79
|
+
children: "VAR"
|
|
80
|
+
}),
|
|
81
|
+
this.__label
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exportDOM() {
|
|
86
|
+
const element = document.createElement('span');
|
|
87
|
+
element.setAttribute('data-payload-dynamic-value', 'true');
|
|
88
|
+
element.setAttribute('data-payload-dynamic-field', this.__field);
|
|
89
|
+
element.textContent = this.__label;
|
|
90
|
+
return {
|
|
91
|
+
element
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exportJSON() {
|
|
95
|
+
return {
|
|
96
|
+
type: 'dynamic-value',
|
|
97
|
+
field: this.__field,
|
|
98
|
+
label: this.__label,
|
|
99
|
+
version: 1
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
getField() {
|
|
103
|
+
return this.__field;
|
|
104
|
+
}
|
|
105
|
+
getTextContent() {
|
|
106
|
+
return this.__label;
|
|
107
|
+
}
|
|
108
|
+
isInline() {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
isToken() {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
updateDOM() {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function $createDynamicValueNode(field, label) {
|
|
119
|
+
return new DynamicValueNode(field, label);
|
|
120
|
+
}
|
|
121
|
+
export function $isDynamicValueNode(node) {
|
|
122
|
+
return node?.getType() === 'dynamic-value';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/nodes/DynamicValueNode/index.tsx"],"sourcesContent":["import {\r\n DecoratorNode,\r\n type DOMConversionMap,\r\n type DOMConversionOutput,\r\n type DOMExportOutput,\r\n type LexicalNode,\r\n type NodeKey,\r\n type SerializedLexicalNode,\r\n type Spread,\r\n} from '@payloadcms/richtext-lexical/lexical'\r\nimport React from 'react'\r\n\r\nexport type SerializedDynamicValueNode = Spread<\r\n {\r\n field: string\r\n label?: string\r\n },\r\n SerializedLexicalNode\r\n>\r\n\r\nexport class DynamicValueNode extends DecoratorNode<React.ReactNode> {\r\n __field: string\r\n __label: string\r\n\r\n constructor(field: string, label?: string, key?: NodeKey) {\r\n super(key)\r\n this.__field = field\r\n this.__label = label ?? field\r\n }\r\n\r\n static clone(node: DynamicValueNode): DynamicValueNode {\r\n return new DynamicValueNode(node.__field, node.__label, node.getKey())\r\n }\r\n\r\n static getType(): string {\r\n return 'dynamic-value'\r\n }\r\n\r\n static importDOM(): DOMConversionMap | null {\r\n return {\r\n span: (domNode: HTMLElement) => {\r\n if (!domNode.hasAttribute('data-payload-dynamic-value')) {\r\n return null\r\n }\r\n return {\r\n conversion: (domNode: HTMLElement): DOMConversionOutput => {\r\n const field = domNode.getAttribute('data-payload-dynamic-field')\r\n const label = domNode.textContent || undefined\r\n if (field) {\r\n return { node: $createDynamicValueNode(field, label) }\r\n }\r\n return { node: null }\r\n },\r\n priority: 1,\r\n }\r\n },\r\n }\r\n }\r\n\r\n static importJSON(serializedNode: SerializedDynamicValueNode): DynamicValueNode {\r\n return $createDynamicValueNode(serializedNode.field, serializedNode.label)\r\n }\r\n\r\n createDOM(): HTMLElement {\r\n const span = document.createElement('span')\r\n span.style.display = 'inline-block'\r\n span.className = 'payload-dynamic-value-node'\r\n return span\r\n }\r\n\r\n decorate(): React.ReactNode {\r\n return (\r\n <span\r\n contentEditable={false}\r\n style={{\r\n alignItems: 'center',\r\n backgroundColor: 'var(--theme-elevation-150)',\r\n border: '1px solid var(--theme-elevation-300)',\r\n borderRadius: '4px',\r\n boxShadow: '0 1px 2px rgba(0,0,0,0.05)',\r\n color: 'var(--theme-text)',\r\n cursor: 'default',\r\n display: 'inline-flex',\r\n fontFamily: 'var(--font-mono, monospace)',\r\n fontSize: '0.85em',\r\n fontWeight: 600,\r\n margin: '0 2px',\r\n padding: '1px 6px',\r\n userSelect: 'none',\r\n verticalAlign: 'middle',\r\n }}\r\n >\r\n <span\r\n style={{\r\n color: 'var(--theme-primary)',\r\n fontSize: '0.8em',\r\n marginRight: '4px',\r\n opacity: 0.4,\r\n }}\r\n >\r\n VAR\r\n </span>\r\n {this.__label}\r\n </span>\r\n )\r\n }\r\n\r\n exportDOM(): DOMExportOutput {\r\n const element = document.createElement('span')\r\n element.setAttribute('data-payload-dynamic-value', 'true')\r\n element.setAttribute('data-payload-dynamic-field', this.__field)\r\n element.textContent = this.__label\r\n return { element }\r\n }\r\n\r\n exportJSON(): SerializedDynamicValueNode {\r\n return {\r\n type: 'dynamic-value',\r\n field: this.__field,\r\n label: this.__label,\r\n version: 1,\r\n }\r\n }\r\n\r\n getField(): string {\r\n return this.__field\r\n }\r\n\r\n getTextContent(): string {\r\n return this.__label\r\n }\r\n\r\n isInline(): boolean {\r\n return true\r\n }\r\n\r\n isToken(): boolean {\r\n return true\r\n }\r\n\r\n updateDOM(): boolean {\r\n return false\r\n }\r\n}\r\n\r\nexport function $createDynamicValueNode(field: string, label?: string): DynamicValueNode {\r\n return new DynamicValueNode(field, label)\r\n}\r\n\r\nexport function $isDynamicValueNode(\r\n node: LexicalNode | null | undefined,\r\n): node is DynamicValueNode {\r\n return node?.getType() === 'dynamic-value'\r\n}\r\n"],"names":["DecoratorNode","React","DynamicValueNode","__field","__label","field","label","key","clone","node","getKey","getType","importDOM","span","domNode","hasAttribute","conversion","getAttribute","textContent","undefined","$createDynamicValueNode","priority","importJSON","serializedNode","createDOM","document","createElement","style","display","className","decorate","contentEditable","alignItems","backgroundColor","border","borderRadius","boxShadow","color","cursor","fontFamily","fontSize","fontWeight","margin","padding","userSelect","verticalAlign","marginRight","opacity","exportDOM","element","setAttribute","exportJSON","type","version","getField","getTextContent","isInline","isToken","updateDOM","$isDynamicValueNode"],"mappings":";AAAA,SACEA,aAAa,QAQR,uCAAsC;AAC7C,OAAOC,WAAW,QAAO;AAUzB,OAAO,MAAMC,yBAAyBF;IACpCG,QAAe;I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ChC;oBACCc,OAAO;wBACLU,OAAO;wBACPG,UAAU;wBACVM,aAAa;wBACbC,SAAS;oBACX;8BACD;;gBAGA,IAAI,CAAC3C,OAAO;;;IAGnB;IAEA4C,YAA6B;QAC3B,MAAMC,UAAUxB,SAASC,aAAa,CAAC;QACvCuB,QAAQC,YAAY,CAAC,8BAA8B;QACnDD,QAAQC,YAAY,CAAC,8BAA8B,IAAI,CAAC/C,OAAO;QAC/D8C,QAAQ/B,WAAW,GAAG,IAAI,CAACd,OAAO;QAClC,OAAO;YAAE6C;QAAQ;IACnB;IAEAE,aAAyC;QACvC,OAAO;YACLC,MAAM;YACN/C,OAAO,IAAI,CAACF,OAAO;YACnBG,OAAO,IAAI,CAACF,OAAO;YACnBiD,SAAS;QACX;IACF;IAEAC,WAAmB;QACjB,OAAO,IAAI,CAACnD,OAAO;IACrB;IAEAoD,iBAAyB;QACvB,OAAO,IAAI,CAACnD,OAAO;IACrB;IAEAoD,WAAoB;QAClB,OAAO;IACT;IAEAC,UAAmB;QACjB,OAAO;IACT;IAEAC,YAAqB;QACnB,OAAO;IACT;AACF;AAEA,OAAO,SAAStC,wBAAwBf,KAAa,EAAEC,KAAc;IACnE,OAAO,IAAIJ,iBAAiBG,OAAOC;AACrC;AAEA,OAAO,SAASqD,oBACdlD,IAAoC;IAEpC,OAAOA,MAAME,cAAc;AAC7B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "payloadcms-dynamic-value-richtext",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Dynamic Value Rich Text Plugin for PayloadCMS",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "OD LABS",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./src/index.ts",
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"default": "./src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"./client": {
|
|
15
|
+
"import": "./src/exports/client.ts",
|
|
16
|
+
"types": "./src/exports/client.ts",
|
|
17
|
+
"default": "./src/exports/client.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./src/index.ts",
|
|
21
|
+
"types": "./src/index.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
27
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
28
|
+
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
29
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
30
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
31
|
+
"dev": "next dev dev --turbo",
|
|
32
|
+
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
33
|
+
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
34
|
+
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
35
|
+
"generate:importmap": "pnpm dev:generate-importmap",
|
|
36
|
+
"generate:types": "pnpm dev:generate-types",
|
|
37
|
+
"lint": "eslint",
|
|
38
|
+
"lint:fix": "eslint ./src --fix",
|
|
39
|
+
"test": "pnpm test:int && pnpm test:e2e",
|
|
40
|
+
"test:e2e": "playwright test",
|
|
41
|
+
"test:int": "vitest"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
45
|
+
"@payloadcms/db-mongodb": "3.37.0",
|
|
46
|
+
"@payloadcms/db-postgres": "3.37.0",
|
|
47
|
+
"@payloadcms/db-sqlite": "3.37.0",
|
|
48
|
+
"@payloadcms/eslint-config": "3.9.0",
|
|
49
|
+
"@payloadcms/next": "3.37.0",
|
|
50
|
+
"@payloadcms/richtext-lexical": "3.37.0",
|
|
51
|
+
"@payloadcms/ui": "3.37.0",
|
|
52
|
+
"@playwright/test": "1.58.2",
|
|
53
|
+
"@swc-node/register": "1.10.9",
|
|
54
|
+
"@swc/cli": "0.6.0",
|
|
55
|
+
"@types/node": "22.19.9",
|
|
56
|
+
"@types/react": "19.2.9",
|
|
57
|
+
"@types/react-dom": "19.2.3",
|
|
58
|
+
"copyfiles": "2.4.1",
|
|
59
|
+
"cross-env": "^7.0.3",
|
|
60
|
+
"eslint": "^9.23.0",
|
|
61
|
+
"eslint-config-next": "15.4.11",
|
|
62
|
+
"graphql": "^16.8.1",
|
|
63
|
+
"mongodb-memory-server": "10.1.4",
|
|
64
|
+
"next": "15.4.11",
|
|
65
|
+
"open": "^10.1.0",
|
|
66
|
+
"payload": "3.37.0",
|
|
67
|
+
"prettier": "^3.4.2",
|
|
68
|
+
"qs-esm": "7.0.2",
|
|
69
|
+
"react": "19.2.1",
|
|
70
|
+
"react-dom": "19.2.1",
|
|
71
|
+
"rimraf": "3.0.2",
|
|
72
|
+
"sharp": "0.34.2",
|
|
73
|
+
"sort-package-json": "^2.10.0",
|
|
74
|
+
"typescript": "5.7.3",
|
|
75
|
+
"vite-tsconfig-paths": "6.0.5",
|
|
76
|
+
"vitest": "4.0.18"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"payload": "^3.37.0"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": "^18.20.2 || >=20.9.0",
|
|
83
|
+
"pnpm": "^9 || ^10"
|
|
84
|
+
},
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"exports": {
|
|
87
|
+
".": {
|
|
88
|
+
"import": "./dist/index.js",
|
|
89
|
+
"types": "./dist/index.d.ts",
|
|
90
|
+
"default": "./dist/index.js"
|
|
91
|
+
},
|
|
92
|
+
"./client": {
|
|
93
|
+
"import": "./dist/exports/client.js",
|
|
94
|
+
"types": "./dist/exports/client.d.ts",
|
|
95
|
+
"default": "./dist/exports/client.js"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"main": "./dist/index.js",
|
|
99
|
+
"types": "./dist/index.d.ts"
|
|
100
|
+
},
|
|
101
|
+
"pnpm": {
|
|
102
|
+
"onlyBuiltDependencies": [
|
|
103
|
+
"sharp",
|
|
104
|
+
"esbuild",
|
|
105
|
+
"unrs-resolver"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"registry": "https://registry.npmjs.org/",
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"lucide-react": "^0.575.0"
|
|
111
|
+
}
|
|
112
|
+
}
|