@antscorp/antsomi-ui 2.0.112 → 2.0.114
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/es/components/icons/QRCodeManagementIcon.d.ts +3 -0
- package/es/components/icons/QRCodeManagementIcon.js +7 -0
- package/es/components/icons/QRSetDashboardIcon.d.ts +3 -0
- package/es/components/icons/QRSetDashboardIcon.js +7 -0
- package/es/components/icons/index.d.ts +2 -0
- package/es/components/icons/index.js +2 -0
- package/es/components/molecules/ColorPicker/index.d.ts +2 -0
- package/es/components/molecules/ColorPicker/index.js +8 -3
- package/es/components/organism/TextEditor/TextEditor.js +17 -1
- package/es/components/organism/TextEditor/types.d.ts +6 -2
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +11 -6
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
4
|
+
export const QRCodeManagementIcon = forwardRef((props, ref) => {
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, ref: ref, width: width, height: height, children: _jsx("g", { children: _jsx("path", { d: "M2.604 7.3118V2.60425H7.31156V4.16675H4.1665V7.3118H2.604ZM2.604 22.3959V17.6884H4.1665V20.8334H7.31156V22.3959H2.604ZM17.6881 22.3959V20.8334H20.8332V17.6884H22.3957V22.3959H17.6881ZM20.8332 7.3118V4.16675H17.6881V2.60425H22.3957V7.3118H20.8332ZM17.9386 17.9389H19.3509V19.3511H17.9386V17.9389ZM17.9386 15.1141H19.3509V16.5264H17.9386V15.1141ZM16.5261 16.5264H17.9386V17.9389H16.5261V16.5264ZM15.1139 17.9389H16.5261V19.3511H15.1139V17.9389ZM13.7017 16.5264H15.1139V17.9389H13.7017V16.5264ZM16.5261 13.7019H17.9386V15.1141H16.5261V13.7019ZM15.1139 15.1141H16.5261V16.5264H15.1139V15.1141ZM13.7017 13.7019H15.1139V15.1141H13.7017V13.7019ZM19.3509 5.64904V11.2983H13.7017V5.64904H19.3509ZM11.298 13.7019V19.3511H5.6488V13.7019H11.298ZM11.298 5.64904V11.2983H5.6488V5.64904H11.298ZM10.0558 18.1089V14.9441H6.89098V18.1089H10.0558ZM10.0558 10.0561V6.89123H6.89098V10.0561H10.0558ZM18.1087 10.0561V6.89123H14.9438V10.0561H18.1087Z", fill: "currentColor" }) }) }));
|
|
7
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useIcon } from './hooks/useIcon';
|
|
4
|
+
export const QRSetDashboardIcon = forwardRef((props, ref) => {
|
|
5
|
+
const { width, height } = useIcon(props);
|
|
6
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 18 18", width: width, height: height, ref: ref, ...props, children: _jsx("path", { fill: "currentColor", d: "M10 18v-2h2v2zm-2-2v-5h2v5zm8-3V9h2v4zm-2-4V7h2v2zM2 11V9h2v2zM0 9V7h2v2zm9-7V0h2v2zM1.5 4.5h3v-3h-3zM0 6V0h6v6zm1.5 10.5h3v-3h-3zM0 18v-6h6v6zM13.5 4.5h3v-3h-3zM12 6V0h6v6zm2 12v-3h-2v-2h4v3h2v2zm-4-7V9h4v2zm-4 0V9H4V7h6v2H8v2zm1-5V2h2v2h2v2zM2.25 3.75v-1.5h1.5v1.5zm0 12v-1.5h1.5v1.5zm12-12v-1.5h1.5v1.5z" }) }));
|
|
7
|
+
});
|
|
@@ -401,3 +401,5 @@ export { WebIcon } from './WebIcon';
|
|
|
401
401
|
export { WebPersonalizationIcon } from './WebPersonalizationIcon';
|
|
402
402
|
export { WidgetIcon } from './WidgetIcon';
|
|
403
403
|
export { WritingAIAssitantIcon } from './WritingAIAssitantIcon';
|
|
404
|
+
export { QRCodeManagementIcon } from './QRCodeManagementIcon';
|
|
405
|
+
export { QRSetDashboardIcon } from './QRSetDashboardIcon';
|
|
@@ -401,3 +401,5 @@ export { WebIcon } from './WebIcon';
|
|
|
401
401
|
export { WebPersonalizationIcon } from './WebPersonalizationIcon';
|
|
402
402
|
export { WidgetIcon } from './WidgetIcon';
|
|
403
403
|
export { WritingAIAssitantIcon } from './WritingAIAssitantIcon';
|
|
404
|
+
export { QRCodeManagementIcon } from './QRCodeManagementIcon';
|
|
405
|
+
export { QRSetDashboardIcon } from './QRSetDashboardIcon';
|
|
@@ -6,8 +6,10 @@ export interface ColorPickerProps {
|
|
|
6
6
|
defaultColor?: string;
|
|
7
7
|
icon?: React.ReactNode | string;
|
|
8
8
|
onChange?: (color: string) => void;
|
|
9
|
+
onAfterClosePicker?: (color: string) => void;
|
|
9
10
|
showInput?: boolean;
|
|
10
11
|
positionInput?: 'right' | 'left';
|
|
11
12
|
style?: React.CSSProperties;
|
|
13
|
+
inputProps?: any;
|
|
12
14
|
}
|
|
13
15
|
export declare const ColorPicker: React.FC<ColorPickerProps>;
|
|
@@ -22,8 +22,8 @@ const styleBtnColor = {
|
|
|
22
22
|
};
|
|
23
23
|
export const ColorPicker = props => {
|
|
24
24
|
// Props
|
|
25
|
-
const { className = '', defaultColor = '#000000', presetColors, positionInput = 'left', icon, showInput = true, style = {}, } = props;
|
|
26
|
-
const { onChange = () => { } } = props;
|
|
25
|
+
const { className = '', defaultColor = '#000000', presetColors, positionInput = 'left', icon, showInput = true, style = {}, inputProps = {}, } = props;
|
|
26
|
+
const { onChange = () => { }, onAfterClosePicker = () => { } } = props;
|
|
27
27
|
// States
|
|
28
28
|
const [color, setColor] = useState(defaultColor);
|
|
29
29
|
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
@@ -71,7 +71,12 @@ export const ColorPicker = props => {
|
|
|
71
71
|
const onPopoverVisibleChange = visible => {
|
|
72
72
|
setPopoverVisible(visible);
|
|
73
73
|
};
|
|
74
|
-
|
|
74
|
+
const handleAfterOpenChange = (visible) => {
|
|
75
|
+
if (!visible && typeof onAfterClosePicker === 'function') {
|
|
76
|
+
onAfterClosePicker(color);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return (_jsxs(ColorPickerWrapper, { className: `antsomi-color-picker ${className || ''}`, style: style, children: [showInput && positionInput === 'left' && (_jsx(Input, { style: { textTransform: 'uppercase' }, value: color, onChange: onChangeColorInput, ...inputProps })), _jsx(Popover, { arrow: true, content: _jsx(CustomPicker, { color: color, presetColors: presetColors, onChange: onChangeColorPicker, onChangeComplete: onChangeComplete }), trigger: "click", open: popoverVisible, getPopupContainer: triggerNode => triggerNode, onOpenChange: onPopoverVisibleChange, afterOpenChange: handleAfterOpenChange, children: _jsx("div", { className: "antsomi-popover-button", style: styleBtnColor, children: iconNode || (_jsx("span", { style: {
|
|
75
80
|
backgroundColor: color,
|
|
76
81
|
display: 'block',
|
|
77
82
|
width: 20,
|
|
@@ -70,6 +70,7 @@ const TextEditorInternal = memo(forwardRef((props, ref) => {
|
|
|
70
70
|
const text = editor.getText();
|
|
71
71
|
const json = editor.getJSON();
|
|
72
72
|
const html = editor.getHTML();
|
|
73
|
+
// console.log(id, { text });
|
|
73
74
|
onUpdate?.({
|
|
74
75
|
html: htmlSerializerForOutput(html),
|
|
75
76
|
text,
|
|
@@ -106,7 +107,7 @@ const TextEditorInternal = memo(forwardRef((props, ref) => {
|
|
|
106
107
|
bulletList: false,
|
|
107
108
|
orderedList: false,
|
|
108
109
|
listItem: false,
|
|
109
|
-
undoRedo: config?.UndoRedo
|
|
110
|
+
undoRedo: config?.UndoRedo && {
|
|
110
111
|
depth: 100,
|
|
111
112
|
},
|
|
112
113
|
}),
|
|
@@ -186,7 +187,12 @@ const TextEditorInternal = memo(forwardRef((props, ref) => {
|
|
|
186
187
|
wrapperElement: contentRef.current.parentElement,
|
|
187
188
|
defaultStyle: defaultTextStyle,
|
|
188
189
|
});
|
|
190
|
+
// console.log(
|
|
191
|
+
// '[ONCREATE] safeParseContent !== initialContent:',
|
|
192
|
+
// safeParseContent !== initialContent,
|
|
193
|
+
// );
|
|
189
194
|
if (safeParseContent !== initialContent) {
|
|
195
|
+
// console.log('[ONCREATE] Calling setContent - this RESETS editor content!');
|
|
190
196
|
editor.commands.setContent(safeParseContent);
|
|
191
197
|
}
|
|
192
198
|
const text = editor.getText();
|
|
@@ -282,6 +288,7 @@ const TextEditorInternal = memo(forwardRef((props, ref) => {
|
|
|
282
288
|
});
|
|
283
289
|
}, [editor]);
|
|
284
290
|
useImperativeHandle(ref, () => ({
|
|
291
|
+
editor,
|
|
285
292
|
setLink: params => {
|
|
286
293
|
editor?.chain().setCustomLink(params).run();
|
|
287
294
|
},
|
|
@@ -308,6 +315,9 @@ const TextEditorInternal = memo(forwardRef((props, ref) => {
|
|
|
308
315
|
deleteSmartTag: handleDeleteSmartTag,
|
|
309
316
|
updateSmartTagAttrs: handleUpdateSmartTagAttrs,
|
|
310
317
|
blur: handleBlur,
|
|
318
|
+
focus() {
|
|
319
|
+
editor.chain().focus().run();
|
|
320
|
+
},
|
|
311
321
|
setContent: editor.commands.setContent,
|
|
312
322
|
style: contentRef.current?.style,
|
|
313
323
|
}));
|
|
@@ -352,6 +362,9 @@ const TextEditorWithProvider = forwardRef((props, ref) => {
|
|
|
352
362
|
}, [colors]);
|
|
353
363
|
useImperativeHandle(ref, () => ({
|
|
354
364
|
// Forward TextEditorRef methods - accessed at call time
|
|
365
|
+
get editor() {
|
|
366
|
+
return editorRef.current?.editor;
|
|
367
|
+
},
|
|
355
368
|
get style() {
|
|
356
369
|
return editorRef.current?.style;
|
|
357
370
|
},
|
|
@@ -388,6 +401,9 @@ const TextEditorWithProvider = forwardRef((props, ref) => {
|
|
|
388
401
|
get blur() {
|
|
389
402
|
return editorRef.current.blur;
|
|
390
403
|
},
|
|
404
|
+
get focus() {
|
|
405
|
+
return editorRef.current.focus;
|
|
406
|
+
},
|
|
391
407
|
get setContent() {
|
|
392
408
|
return editorRef.current.setContent;
|
|
393
409
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { JSONContent, MarkRange } from '@tiptap/core';
|
|
2
|
+
import type { Editor, JSONContent, MarkRange } from '@tiptap/core';
|
|
3
3
|
import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
|
|
4
4
|
import type { Mark, Node } from '@tiptap/pm/model';
|
|
5
5
|
import { ORDERED_LIST_STYLE_TYPE, UNORDERED_LIST_STYLE_TYPE } from './constants';
|
|
@@ -29,9 +29,13 @@ export type HandleLinkRef = {
|
|
|
29
29
|
};
|
|
30
30
|
export type TextEditorRef = HandleSmartTagRef & HandleLinkRef & {
|
|
31
31
|
blur: (perserveSelection?: boolean) => void;
|
|
32
|
+
focus: () => void;
|
|
32
33
|
style?: CSSStyleDeclaration;
|
|
33
34
|
getHTML?: () => string;
|
|
34
|
-
setContent?: (text: string
|
|
35
|
+
setContent?: (text: string, options?: Partial<{
|
|
36
|
+
emitUpdate: boolean;
|
|
37
|
+
}>) => void;
|
|
38
|
+
readonly editor: Editor;
|
|
35
39
|
};
|
|
36
40
|
export type SmartTagHandler = Partial<{
|
|
37
41
|
edit: (id: string, event: React.MouseEvent) => void;
|
|
@@ -46,15 +46,20 @@ export const FormattingToolbar = (props) => {
|
|
|
46
46
|
letterSpacing: _jsx(LetterSpacingAction, { editor: editor }, "letterSpacing"),
|
|
47
47
|
indent: _jsx(IndentAction, { editor: editor }, "indent"),
|
|
48
48
|
outdent: _jsx(OutdentAction, { editor: editor }, "outdent"),
|
|
49
|
-
history: _jsx(HistoryAction, { editor: editor }, "history"),
|
|
49
|
+
history: config?.UndoRedo !== false ? _jsx(HistoryAction, { editor: editor }, "history") : null,
|
|
50
50
|
clearFormatting: _jsx(ClearFormattingAction, { editor: editor }, "clearFormatting"),
|
|
51
51
|
}), [
|
|
52
52
|
editor,
|
|
53
|
-
config?.FontFamily,
|
|
54
|
-
config?.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
config?.FontFamily?.fonts,
|
|
54
|
+
config?.FontFamily?.fontGroupingFn,
|
|
55
|
+
config?.FontFamily?.groupOrder,
|
|
56
|
+
config?.UnorderedList?.useCustomBullet,
|
|
57
|
+
config?.UndoRedo,
|
|
58
|
+
defaultTextStyle.fontFamily,
|
|
59
|
+
defaultTextStyle.fontSize,
|
|
60
|
+
defaultTextStyle?.lineHeight,
|
|
61
|
+
linkHanlder?.onUpsert,
|
|
62
|
+
smartTagHandler?.onUpsert,
|
|
58
63
|
onChangeFont,
|
|
59
64
|
]);
|
|
60
65
|
// Group actions into rows
|