@livepreso/react-plugin-textfield 0.0.2
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/.lintstagedrc.js +6 -0
- package/.rush/temp/shrinkwrap-deps.json +311 -0
- package/.vscode/settings.json +22 -0
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +9 -0
- package/components/BubbleMenu.js +181 -0
- package/components/BubbleMenu.module.scss +9 -0
- package/components/LinkEditDialog.js +105 -0
- package/components/LinkEditDialog.module.scss +171 -0
- package/components/Popover.js +43 -0
- package/components/Popover.module.scss +80 -0
- package/components/PrimaryToolbar.js +27 -0
- package/components/Select/Select.js +71 -0
- package/components/Select/Select.module.scss +100 -0
- package/components/Select/SelectGroup.js +37 -0
- package/components/Select/index.js +1 -0
- package/components/TableCellMenu.js +43 -0
- package/components/TableToolbar.js +41 -0
- package/components/Tooltip.js +34 -0
- package/components/Tooltip.module.scss +87 -0
- package/components/VerticalAlignToggle.js +65 -0
- package/components/color-picker/ColorPicker.js +28 -0
- package/components/color-picker/ColorPicker.module.scss +8 -0
- package/components/color-picker/ColorPickerChip.js +22 -0
- package/components/color-picker/ColorPickerChip.module.scss +25 -0
- package/components/color-picker/ColorPickerCombo.js +45 -0
- package/components/color-picker/ColorPickerCombo.module.scss +23 -0
- package/components/color-picker/TextColorIcon.js +18 -0
- package/components/editor-toolbars/EditorMenu.js +104 -0
- package/components/editor-toolbars/EditorMenu.module.scss +96 -0
- package/components/editor-toolbars/EditorToolbar.js +146 -0
- package/components/editor-toolbars/EditorToolbar.module.scss +75 -0
- package/components/editor-toolbars/MenuItem.js +24 -0
- package/components/editor-toolbars/SubMenu.js +50 -0
- package/components/editor-toolbars/ToolbarButton.js +26 -0
- package/components/editor-toolbars/ToolbarToggle.js +35 -0
- package/components/editor-toolbars/ToolbarToggleGroup.js +43 -0
- package/components/editor-toolbars/utils.js +7 -0
- package/components/hooks/use-presenter.js +5 -0
- package/components/style.module.scss +63 -0
- package/components/tiptap/ListItem.js +5 -0
- package/components/tiptap/Table.js +397 -0
- package/components/tiptap/TableCells.js +99 -0
- package/components/utils.js +84 -0
- package/configs/generate-toolbar-configuration.js +130 -0
- package/configs/generate-toolbar-options.js +96 -0
- package/configs/table-toolbar-configuration.js +187 -0
- package/configs/toolbar-configuration.js +330 -0
- package/constants.js +198 -0
- package/eslint.config.mjs +15 -0
- package/icons/AddColumnLeft.js +15 -0
- package/icons/AddColumnRight.js +15 -0
- package/icons/AddRowAbove.js +15 -0
- package/icons/AddRowBelow.js +15 -0
- package/icons/AlignHorizontalCenter.js +13 -0
- package/icons/AlignHorizontalLeft.js +13 -0
- package/icons/AlignHorizontalRight.js +13 -0
- package/icons/AlignVerticalBottom.js +13 -0
- package/icons/AlignVerticalCenter.js +13 -0
- package/icons/AlignVerticalTop.js +13 -0
- package/icons/Backspace.js +13 -0
- package/icons/Bold.js +14 -0
- package/icons/BorderAll.js +13 -0
- package/icons/BorderBottom.js +13 -0
- package/icons/BorderClear.js +13 -0
- package/icons/BorderHorizontal.js +13 -0
- package/icons/BorderInner.js +13 -0
- package/icons/BorderLeft.js +13 -0
- package/icons/BorderOuter.js +13 -0
- package/icons/BorderRight.js +13 -0
- package/icons/BorderTop.js +13 -0
- package/icons/BorderVertical.js +13 -0
- package/icons/Close.js +13 -0
- package/icons/Delete.js +13 -0
- package/icons/EvenlyDistribute.js +14 -0
- package/icons/FitWidth.js +13 -0
- package/icons/FitWidthArrows.js +21 -0
- package/icons/FormatAlignCenter.js +13 -0
- package/icons/FormatAlignJustify.js +13 -0
- package/icons/FormatAlignLeft.js +13 -0
- package/icons/FormatAlignRight.js +13 -0
- package/icons/FormatBold.js +13 -0
- package/icons/FormatClear.js +13 -0
- package/icons/FormatColorFill.js +13 -0
- package/icons/FormatColorText.js +13 -0
- package/icons/FormatItalic.js +13 -0
- package/icons/FormatLineSpacing.js +13 -0
- package/icons/FormatListBulleted.js +13 -0
- package/icons/FormatListNumbered.js +13 -0
- package/icons/FormatStrikethrough.js +13 -0
- package/icons/FormatUnderlined.js +13 -0
- package/icons/HorizontalRule.js +13 -0
- package/icons/Italic.js +14 -0
- package/icons/ItalicIcon.js +18 -0
- package/icons/Link.js +13 -0
- package/icons/LinkOff.js +13 -0
- package/icons/MergeCells.js +14 -0
- package/icons/Redo.js +13 -0
- package/icons/RemoveColumnOutline.js +28 -0
- package/icons/RemoveRowOutline.js +25 -0
- package/icons/SplitCells.js +14 -0
- package/icons/SplitScene.js +13 -0
- package/icons/Subscript.js +13 -0
- package/icons/Superscript.js +13 -0
- package/icons/Underline.js +14 -0
- package/icons/Undo.js +13 -0
- package/icons/VerticalAlignBottom.js +13 -0
- package/icons/VerticalAlignCenter.js +13 -0
- package/icons/VerticalAlignTop.js +13 -0
- package/icons/add_column_left.svg +6 -0
- package/icons/add_column_right.svg +6 -0
- package/icons/add_row_above.svg +6 -0
- package/icons/add_row_below.svg +6 -0
- package/icons/align_horizontal_center.svg +1 -0
- package/icons/align_horizontal_left.svg +1 -0
- package/icons/align_horizontal_right.svg +1 -0
- package/icons/align_vertical_bottom.svg +1 -0
- package/icons/align_vertical_center.svg +1 -0
- package/icons/align_vertical_top.svg +1 -0
- package/icons/backspace.svg +1 -0
- package/icons/bold.svg +1 -0
- package/icons/border_all.svg +1 -0
- package/icons/border_bottom.svg +1 -0
- package/icons/border_clear.svg +1 -0
- package/icons/border_horizontal.svg +1 -0
- package/icons/border_inner.svg +1 -0
- package/icons/border_left.svg +1 -0
- package/icons/border_outer.svg +1 -0
- package/icons/border_right.svg +1 -0
- package/icons/border_top.svg +1 -0
- package/icons/border_vertical.svg +1 -0
- package/icons/close.svg +1 -0
- package/icons/delete.svg +1 -0
- package/icons/evenly_distribute.svg +5 -0
- package/icons/fit_width.svg +1 -0
- package/icons/fit_width_arrows.svg +12 -0
- package/icons/format_align_center.svg +1 -0
- package/icons/format_align_justify.svg +1 -0
- package/icons/format_align_left.svg +1 -0
- package/icons/format_align_right.svg +1 -0
- package/icons/format_bold.svg +1 -0
- package/icons/format_clear.svg +1 -0
- package/icons/format_color_fill.svg +1 -0
- package/icons/format_color_text.svg +5 -0
- package/icons/format_color_text_ungrouped.svg +6 -0
- package/icons/format_italic.svg +1 -0
- package/icons/format_line_spacing.svg +1 -0
- package/icons/format_list_bulleted.svg +1 -0
- package/icons/format_list_numbered.svg +1 -0
- package/icons/format_strikethrough.svg +1 -0
- package/icons/format_underlined.svg +1 -0
- package/icons/horizontal_rule.svg +1 -0
- package/icons/index.js +191 -0
- package/icons/italic.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/link_off.svg +1 -0
- package/icons/merge_cells.svg +5 -0
- package/icons/redo.svg +1 -0
- package/icons/remove_column_outline.svg +20 -0
- package/icons/remove_row_outline.svg +17 -0
- package/icons/split_cells.svg +5 -0
- package/icons/split_scene.svg +1 -0
- package/icons/subscript.svg +1 -0
- package/icons/superscript.svg +1 -0
- package/icons/underline.svg +1 -0
- package/icons/undo.svg +1 -0
- package/icons/vertical_align_bottom.svg +1 -0
- package/icons/vertical_align_center.svg +1 -0
- package/icons/vertical_align_top.svg +1 -0
- package/index.js +334 -0
- package/index.module.scss +106 -0
- package/package.json +63 -0
- package/scripts/extract-svg.js +288 -0
- package/utils/color-utils.js +42 -0
- package/utils/generate-vertical-alignment-icon.js +22 -0
- package/utils/generateCustomExtensions.js +49 -0
package/index.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { renderToString } from "react-dom/server";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
autoUpdate,
|
|
7
|
+
flip,
|
|
8
|
+
inline,
|
|
9
|
+
offset,
|
|
10
|
+
useFloating,
|
|
11
|
+
} from "@floating-ui/react-dom";
|
|
12
|
+
import {
|
|
13
|
+
useCMSVal,
|
|
14
|
+
useModes,
|
|
15
|
+
usePrepEditable,
|
|
16
|
+
useSlide,
|
|
17
|
+
} from "@livepreso/content-react";
|
|
18
|
+
import Document from "@tiptap/extension-document";
|
|
19
|
+
import HardBreak from "@tiptap/extension-hard-break";
|
|
20
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
21
|
+
import Text from "@tiptap/extension-text";
|
|
22
|
+
import {
|
|
23
|
+
EditorContent,
|
|
24
|
+
EditorContext,
|
|
25
|
+
useEditor,
|
|
26
|
+
useEditorState,
|
|
27
|
+
} from "@tiptap/react";
|
|
28
|
+
|
|
29
|
+
import { PrimaryToolbar } from "./components/PrimaryToolbar.js";
|
|
30
|
+
import { TableToolbar } from "./components/TableToolbar.js";
|
|
31
|
+
import { generateToolbarOptions } from "./configs/generate-toolbar-options.js";
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_TOOLBAR_CONFIG,
|
|
34
|
+
DEFAULT_TABLE_TOOLBAR_CONFIG,
|
|
35
|
+
EDITABLE_OUTER_SELECTOR,
|
|
36
|
+
} from "./constants.js";
|
|
37
|
+
import { TableCellMenu } from "./components/TableCellMenu.js";
|
|
38
|
+
import style from "./index.module.scss";
|
|
39
|
+
import { generateExtensionsFromTag } from "./utils/generateCustomExtensions.js";
|
|
40
|
+
import debounce from "lodash.debounce";
|
|
41
|
+
|
|
42
|
+
function EditableTextField({
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
className,
|
|
46
|
+
isEditable,
|
|
47
|
+
textStyles,
|
|
48
|
+
colors,
|
|
49
|
+
toolbarConfig = DEFAULT_TOOLBAR_CONFIG,
|
|
50
|
+
tableToolbarConfig = DEFAULT_TABLE_TOOLBAR_CONFIG,
|
|
51
|
+
maskSelector,
|
|
52
|
+
extensions: customExtensions = {},
|
|
53
|
+
tag,
|
|
54
|
+
autofocus = false,
|
|
55
|
+
disableSpellcheck = false,
|
|
56
|
+
// TODO implement an equivalent to the EditableText handler
|
|
57
|
+
// for editables inside tab handlers / accordion headers etc
|
|
58
|
+
// stopPropagation = false,
|
|
59
|
+
...other
|
|
60
|
+
}) {
|
|
61
|
+
const [textColor, setTextColor] = useState(null);
|
|
62
|
+
const initialValue = useRef(value);
|
|
63
|
+
|
|
64
|
+
// a custom tag can result in a custom Document extension
|
|
65
|
+
// or you can pass custom extensions
|
|
66
|
+
const additionalExtensions = {
|
|
67
|
+
...generateExtensionsFromTag(tag),
|
|
68
|
+
...customExtensions,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const baseExtensions = [Text, Paragraph, HardBreak];
|
|
72
|
+
|
|
73
|
+
// it is your responsibility not to double-specify any extensions you need here
|
|
74
|
+
// vs those derived from the toolbar config
|
|
75
|
+
|
|
76
|
+
const { document: documentExtension = Document, ...restExtensions } =
|
|
77
|
+
additionalExtensions;
|
|
78
|
+
const otherExtensions = Object.values(restExtensions);
|
|
79
|
+
|
|
80
|
+
const {
|
|
81
|
+
primaryOptions = [],
|
|
82
|
+
tableOptions = [],
|
|
83
|
+
tableCellOptions = [],
|
|
84
|
+
extensions: toolbarAddedExtensions = [],
|
|
85
|
+
} = useMemo(
|
|
86
|
+
() =>
|
|
87
|
+
generateToolbarOptions({
|
|
88
|
+
toolbarConfig,
|
|
89
|
+
tableToolbarConfig,
|
|
90
|
+
textStyles,
|
|
91
|
+
colors,
|
|
92
|
+
}),
|
|
93
|
+
[textStyles, colors, toolbarConfig, tableToolbarConfig],
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const groupedOptions = [
|
|
97
|
+
...primaryOptions,
|
|
98
|
+
...tableOptions,
|
|
99
|
+
...tableCellOptions,
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const editor = useEditor({
|
|
103
|
+
content: initialValue.current,
|
|
104
|
+
extensions: [
|
|
105
|
+
documentExtension,
|
|
106
|
+
...baseExtensions,
|
|
107
|
+
...toolbarAddedExtensions,
|
|
108
|
+
...otherExtensions,
|
|
109
|
+
],
|
|
110
|
+
editable: isEditable,
|
|
111
|
+
autofocus: false,
|
|
112
|
+
onUpdate: debounce(({ editor }) => {
|
|
113
|
+
onChange?.(editor.getHTML());
|
|
114
|
+
}, 100),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const { refs } = useFloating({
|
|
118
|
+
whileElementsMounted: autoUpdate,
|
|
119
|
+
placement: "top-start",
|
|
120
|
+
middleware: [inline(), offset(2), flip()],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const preventPropagation = (event) => {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (refs?.reference?.current) {
|
|
129
|
+
if (disableSpellcheck) {
|
|
130
|
+
refs.reference.current.removeEventListener(
|
|
131
|
+
"contextmenu",
|
|
132
|
+
preventPropagation,
|
|
133
|
+
);
|
|
134
|
+
} else {
|
|
135
|
+
refs.reference.current.addEventListener(
|
|
136
|
+
"contextmenu",
|
|
137
|
+
preventPropagation,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return () => {
|
|
142
|
+
if (refs?.reference?.current)
|
|
143
|
+
refs.reference.current.removeEventListener(
|
|
144
|
+
"contextmenu",
|
|
145
|
+
preventPropagation,
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
}, [refs, disableSpellcheck]);
|
|
149
|
+
|
|
150
|
+
const providerArgs = useMemo(() => ({ editor }), [editor]);
|
|
151
|
+
|
|
152
|
+
// // doing this way, rather than a filter, lets us set an arbitrary order for the button groups
|
|
153
|
+
// const selectedControlGroups = toolbarConfig.map((groupId) =>
|
|
154
|
+
// components.find((configGroup) => configGroup.id === groupId)
|
|
155
|
+
// );
|
|
156
|
+
|
|
157
|
+
const items = groupedOptions.flatMap((group) => group.items || []);
|
|
158
|
+
|
|
159
|
+
// thought about adding the focus to the state,
|
|
160
|
+
// to do away with the useState()
|
|
161
|
+
// but probably fine as is
|
|
162
|
+
// items.push({id: 'editor', active: (editor) => editor.isFocused})
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (autofocus && editor) {
|
|
166
|
+
// timeout required as toolbar position is wrong otherwise
|
|
167
|
+
// similar delay with TinyMCE based editor
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
editor.chain().focus().run();
|
|
170
|
+
}, 300);
|
|
171
|
+
}
|
|
172
|
+
}, [autofocus]);
|
|
173
|
+
|
|
174
|
+
const selector = ({ editor }) => {
|
|
175
|
+
return items.reduce(
|
|
176
|
+
(
|
|
177
|
+
acc,
|
|
178
|
+
{ id, active = () => false, enabled = () => true, value = () => null },
|
|
179
|
+
) => {
|
|
180
|
+
return {
|
|
181
|
+
...acc,
|
|
182
|
+
[id]: {
|
|
183
|
+
active: active(editor),
|
|
184
|
+
enabled: enabled(editor),
|
|
185
|
+
value: value(editor),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
{},
|
|
190
|
+
);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const editorState = useEditorState({
|
|
194
|
+
editor,
|
|
195
|
+
selector,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const classes = [
|
|
199
|
+
"interactive",
|
|
200
|
+
EDITABLE_OUTER_SELECTOR,
|
|
201
|
+
className,
|
|
202
|
+
isEditable && style.editable,
|
|
203
|
+
style.textField,
|
|
204
|
+
].filter(Boolean);
|
|
205
|
+
|
|
206
|
+
const toolbarOptions = {
|
|
207
|
+
editor,
|
|
208
|
+
editorState,
|
|
209
|
+
maskSelector,
|
|
210
|
+
// For storing user selections outside of the current selected state of the editor
|
|
211
|
+
// eg. Previous selected color, for easy re-use in the same session.
|
|
212
|
+
userSelections: {
|
|
213
|
+
textColor: { value: textColor, setValue: setTextColor },
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<EditorContext.Provider value={providerArgs}>
|
|
219
|
+
{isEditable && (
|
|
220
|
+
<>
|
|
221
|
+
<PrimaryToolbar configuration={primaryOptions} {...toolbarOptions} />
|
|
222
|
+
<TableCellMenu configuration={tableCellOptions} {...toolbarOptions} />
|
|
223
|
+
<TableToolbar configuration={tableOptions} {...toolbarOptions} />
|
|
224
|
+
</>
|
|
225
|
+
)}
|
|
226
|
+
<div
|
|
227
|
+
data-companywide-interactive={isEditable}
|
|
228
|
+
className={classes.join(" ")}
|
|
229
|
+
ref={refs.setReference}
|
|
230
|
+
{...other}
|
|
231
|
+
>
|
|
232
|
+
<EditorContent editor={editor} />
|
|
233
|
+
</div>
|
|
234
|
+
</EditorContext.Provider>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function PrepEditableField({ id, prepId = id, children, isCompany, ...props }) {
|
|
239
|
+
const { isPresomanager } = useModes();
|
|
240
|
+
const { isUserTemplateLibrary, isUserTemplate } = useSlide();
|
|
241
|
+
|
|
242
|
+
const [defaultCmsValue] = useCMSVal(id, {
|
|
243
|
+
enabled: isCompany && !isPresomanager,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const [prepValue, setPrepValue] = usePrepEditable(prepId);
|
|
247
|
+
|
|
248
|
+
let value = isCompany && prepValue === null ? defaultCmsValue : prepValue;
|
|
249
|
+
|
|
250
|
+
const isEditable =
|
|
251
|
+
props.isEditable &&
|
|
252
|
+
(!isPresomanager || isUserTemplateLibrary || isUserTemplate);
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<EditableTextField
|
|
256
|
+
{...props}
|
|
257
|
+
value={value ?? renderToString(children)}
|
|
258
|
+
onChange={setPrepValue}
|
|
259
|
+
isEditable={isEditable}
|
|
260
|
+
/>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function CMSValField({ id, children, ...props }) {
|
|
265
|
+
const { isPresomanager, isThumbnailScreenshot } = useModes();
|
|
266
|
+
const { isUserTemplateLibrary, isUserTemplate } = useSlide();
|
|
267
|
+
|
|
268
|
+
const [cmsValue, setCMSValue] = useCMSVal(id);
|
|
269
|
+
const value = !isThumbnailScreenshot && cmsValue;
|
|
270
|
+
|
|
271
|
+
const isEditable =
|
|
272
|
+
props.isEditable &&
|
|
273
|
+
(isPresomanager || isUserTemplateLibrary || isUserTemplate);
|
|
274
|
+
return (
|
|
275
|
+
<EditableTextField
|
|
276
|
+
{...props}
|
|
277
|
+
value={value ?? renderToString(children)}
|
|
278
|
+
onChange={setCMSValue}
|
|
279
|
+
isEditable={isEditable}
|
|
280
|
+
/>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function TextField(props) {
|
|
285
|
+
const { value, children, onChange, isReadOnly, ...other } = props;
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<EditableTextField
|
|
289
|
+
value={value ?? renderToString(children)}
|
|
290
|
+
onChange={onChange}
|
|
291
|
+
isEditable={!isReadOnly}
|
|
292
|
+
{...other}
|
|
293
|
+
/>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function ManagedTextField(props) {
|
|
298
|
+
const { isPresomanager, isPreview, isEmptyPreview } = useModes();
|
|
299
|
+
const { isUserTemplateLibrary } = useSlide();
|
|
300
|
+
const {
|
|
301
|
+
isReadOnly = false,
|
|
302
|
+
isPrep = false,
|
|
303
|
+
isCompany = false,
|
|
304
|
+
// we only want to pass this to the PrepEditableField, not the CMSValField
|
|
305
|
+
prepId,
|
|
306
|
+
...other
|
|
307
|
+
} = props;
|
|
308
|
+
|
|
309
|
+
const isEditable = !isReadOnly && (isPresomanager || isPreview);
|
|
310
|
+
const sharedProps = { ...other, isEditable };
|
|
311
|
+
|
|
312
|
+
// occasionally, we want to lock the field and pass a value
|
|
313
|
+
// without it ever being configured to allow updates
|
|
314
|
+
if (!isReadOnly && !isPrep && !isCompany) {
|
|
315
|
+
throw new Error("Must set isPrep or isCompany or both");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const isReallyPresoManager = isPresomanager && !isUserTemplateLibrary;
|
|
319
|
+
|
|
320
|
+
if (
|
|
321
|
+
(isPrep && !isReallyPresoManager && !isEmptyPreview) ||
|
|
322
|
+
(isPrep && isReallyPresoManager && !isCompany)
|
|
323
|
+
) {
|
|
324
|
+
return (
|
|
325
|
+
<PrepEditableField
|
|
326
|
+
isCompany={isCompany}
|
|
327
|
+
prepId={prepId}
|
|
328
|
+
{...sharedProps}
|
|
329
|
+
/>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return <CMSValField {...sharedProps} />;
|
|
334
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
$interactive-color: #3c80f6;
|
|
2
|
+
$button-color: #f0f0f0;
|
|
3
|
+
$button-hover-color: #e0e0e0;
|
|
4
|
+
|
|
5
|
+
:global(.sp-presenter-overlay) {
|
|
6
|
+
* {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
|
|
12
|
+
--sp-toolbar-color-white: #ffffff;
|
|
13
|
+
--sp-toolbar-bg-color: var(--sp-toolbar-color-white);
|
|
14
|
+
--sp-toolbar-color: rgb(34, 47, 62);
|
|
15
|
+
--sp-toolbar-modal-bg-color: rgba(255, 255, 255, 0.75);
|
|
16
|
+
--sp-toolbar-separator-color: rgba(0, 0, 0, 0.12);
|
|
17
|
+
--sp-toolbar-highlight-color: rgba(0, 0, 0, 0.38);
|
|
18
|
+
--sp-toolbar-interactive-color: $interactive-color;
|
|
19
|
+
--sp-toolbar-focus-color: #006ce7;
|
|
20
|
+
--sp-toolbar-active-color: #a6ccf7;
|
|
21
|
+
--sp-toolbar-hover-color: #cce2fa;
|
|
22
|
+
--sp-toolbar-select-trigger: #f7f7f7;
|
|
23
|
+
// Buttons
|
|
24
|
+
--sp-toolbar-button: $button-color;
|
|
25
|
+
--sp-toolbar-button-hover: $button-hover-color;
|
|
26
|
+
--sp-toolbar-button-primary: var(--sp-toolbar-focus-color);
|
|
27
|
+
--sp-toolbar-button-primary-hover: #0060ce;
|
|
28
|
+
|
|
29
|
+
a,
|
|
30
|
+
button,
|
|
31
|
+
fieldset,
|
|
32
|
+
input {
|
|
33
|
+
all: unset;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.toolbar-container {
|
|
37
|
+
position: fixed;
|
|
38
|
+
top: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
right: 0;
|
|
41
|
+
bottom: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.text-field {
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
|
|
48
|
+
table {
|
|
49
|
+
border-collapse: collapse;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.editable {
|
|
54
|
+
outline: 1px solid $interactive-color;
|
|
55
|
+
|
|
56
|
+
> div {
|
|
57
|
+
height: 100%;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:global {
|
|
61
|
+
.tiptap {
|
|
62
|
+
height: 100%;
|
|
63
|
+
white-space: pre-wrap;
|
|
64
|
+
outline: none;
|
|
65
|
+
|
|
66
|
+
&.resize-cursor {
|
|
67
|
+
cursor: ew-resize;
|
|
68
|
+
cursor: col-resize;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tableWrapper {
|
|
73
|
+
th,
|
|
74
|
+
td {
|
|
75
|
+
position: relative;
|
|
76
|
+
|
|
77
|
+
&.selectedCell::after {
|
|
78
|
+
content: "";
|
|
79
|
+
position: absolute;
|
|
80
|
+
left: 0;
|
|
81
|
+
right: 0;
|
|
82
|
+
top: 0;
|
|
83
|
+
bottom: 0;
|
|
84
|
+
background-color: rgba(0, 0, 0, 0.15);
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
z-index: 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.tiptap-table-cell-dark.selectedCell::after {
|
|
90
|
+
background-color: rgba(255, 255, 255, 0.4);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Loz: I think I broke this...
|
|
95
|
+
.column-resize-handle {
|
|
96
|
+
background-color: $interactive-color;
|
|
97
|
+
bottom: -2px;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
position: relative;
|
|
100
|
+
right: -2px;
|
|
101
|
+
top: 0;
|
|
102
|
+
width: 4px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@livepreso/react-plugin-textfield",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"eslint": "~9.15.0",
|
|
14
|
+
"@babel/preset-react": "~7.25.9",
|
|
15
|
+
"react": "18.x",
|
|
16
|
+
"react-dom": "18.x",
|
|
17
|
+
"@babel/parser": "^7.26.10",
|
|
18
|
+
"@babel/traverse": "^7.26.10",
|
|
19
|
+
"@svgr/core": "^8.1.0",
|
|
20
|
+
"@svgr/plugin-jsx": "^8.1.0",
|
|
21
|
+
"@livepreso/eslint-config": "1.0.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "18.x",
|
|
25
|
+
"react-dom": "18.x"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@floating-ui/react-dom": "~2.1.3",
|
|
29
|
+
"use-sync-external-store": "~1.5.0",
|
|
30
|
+
"classnames": "~2.5.1",
|
|
31
|
+
"radix-ui": "~1.4.2",
|
|
32
|
+
"@radix-ui/react-icons": "~1.3.2",
|
|
33
|
+
"@tiptap/core": "~3.0.6",
|
|
34
|
+
"@tiptap/react": "~3.0.6",
|
|
35
|
+
"@tiptap/pm": "~3.0.6",
|
|
36
|
+
"@tiptap/extension-document": "~3.0.6",
|
|
37
|
+
"@tiptap/extension-paragraph": "~3.0.6",
|
|
38
|
+
"@tiptap/extension-text": "~3.0.6",
|
|
39
|
+
"@tiptap/extension-hard-break": "~3.0.6",
|
|
40
|
+
"@tiptap/extension-heading": "~3.0.6",
|
|
41
|
+
"@tiptap/extension-bubble-menu": "~3.0.6",
|
|
42
|
+
"@tiptap/extension-table": "~3.0.6",
|
|
43
|
+
"@tiptap/extension-table-cell": "~3.0.6",
|
|
44
|
+
"@tiptap/extension-table-header": "~3.0.6",
|
|
45
|
+
"@tiptap/extension-table-row": "~3.0.6",
|
|
46
|
+
"@tiptap/extension-image": "~3.0.6",
|
|
47
|
+
"@tiptap/extension-text-align": "~3.0.6",
|
|
48
|
+
"@tiptap/extension-underline": "~3.0.6",
|
|
49
|
+
"@tiptap/extension-link": "~3.0.6",
|
|
50
|
+
"@tiptap/extension-bold": "~3.0.6",
|
|
51
|
+
"@tiptap/extension-italic": "~3.0.6",
|
|
52
|
+
"@tiptap/extension-list": "~3.0.6",
|
|
53
|
+
"@tiptap/extension-text-style": "~3.0.6",
|
|
54
|
+
"@tiptap/extensions": "~3.0.6",
|
|
55
|
+
"@tiptap/extension-subscript": "~3.0.6",
|
|
56
|
+
"@tiptap/extension-superscript": "~3.0.6",
|
|
57
|
+
"lodash.debounce": "~4.0.8",
|
|
58
|
+
"@livepreso/content-react": "2.0.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": ""
|
|
62
|
+
}
|
|
63
|
+
}
|