@antscorp/antsomi-ui 2.0.83-text-editor-beta.10 → 2.0.84
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/assets/css/main.scss +2 -4
- package/es/components/molecules/DisplayFormat/constants.js +2 -2
- package/es/components/molecules/DisplayFormat/utils.js +2 -2
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
- package/es/components/molecules/index.d.ts +0 -1
- package/es/components/molecules/index.js +0 -1
- package/es/components/organism/index.d.ts +0 -1
- package/es/components/organism/index.js +0 -1
- package/es/hooks/index.d.ts +0 -1
- package/es/hooks/index.js +0 -1
- package/es/utils/common.d.ts +9 -6
- package/es/utils/common.js +23 -44
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -4
- package/es/utils/web.js +0 -25
- package/package.json +3 -29
- package/es/components/index.scss +0 -2
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -20
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
- package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/constants.js +0 -5
- package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/index.js +0 -1
- package/es/components/molecules/FontSizeInput/styled.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/styled.js +0 -22
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
- package/es/components/molecules/FontSizeInput/types.js +0 -1
- package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/utils.js +0 -9
- package/es/components/molecules/index.scss +0 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
- package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
- package/es/components/organism/TextEditor/TextEditor.js +0 -251
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
- package/es/components/organism/TextEditor/constants.d.ts +0 -135
- package/es/components/organism/TextEditor/constants.js +0 -280
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -130
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
- package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -41
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
- package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -43
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
- package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
- package/es/components/organism/TextEditor/extensions/Highlight.d.ts +0 -1
- package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
- package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
- package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/Link.js +0 -50
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
- package/es/components/organism/TextEditor/extensions/Selection.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
- package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -31
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
- package/es/components/organism/TextEditor/hooks/index.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/index.js +0 -6
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
- package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
- package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
- package/es/components/organism/TextEditor/index.d.ts +0 -14
- package/es/components/organism/TextEditor/index.js +0 -6
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -10
- package/es/components/organism/TextEditor/provider.js +0 -20
- package/es/components/organism/TextEditor/store.d.ts +0 -11
- package/es/components/organism/TextEditor/store.js +0 -12
- package/es/components/organism/TextEditor/styled.d.ts +0 -8
- package/es/components/organism/TextEditor/styled.js +0 -90
- package/es/components/organism/TextEditor/types.d.ts +0 -92
- package/es/components/organism/TextEditor/types.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -120
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
- package/es/components/organism/TextEditor/utils/documentState.js +0 -100
- package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
- package/es/components/organism/TextEditor/utils/font.js +0 -175
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -321
- package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
- package/es/components/organism/TextEditor/utils/index.js +0 -16
- package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
- package/es/components/organism/TextEditor/utils/link.js +0 -149
- package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
- package/es/components/organism/TextEditor/utils/menu.js +0 -317
- package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
- package/es/components/organism/TextEditor/utils/selection.js +0 -57
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
- package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
- package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
- package/es/components/organism/TextEditor/utils/style.js +0 -193
- package/es/components/organism/index.scss +0 -1
- package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
- package/es/hooks/useBroadcastedLocalStorage.js +0 -71
- package/es/hooks/useElementSize.d.ts +0 -7
- package/es/hooks/useElementSize.js +0 -56
- package/es/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Typography } from 'antd';
|
|
3
|
-
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
4
|
-
import { COMPONENT_CLS } from '../../constants';
|
|
5
|
-
import { VirtualizedMenu } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
export const ITEM_SIZE = 28;
|
|
8
|
-
export const EmojiList = forwardRef((props, ref) => {
|
|
9
|
-
const { items = [] } = props;
|
|
10
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
11
|
-
const selectItem = (index) => {
|
|
12
|
-
const item = items[index];
|
|
13
|
-
if (item) {
|
|
14
|
-
props.command({ name: item.name });
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const upHandler = () => {
|
|
18
|
-
setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);
|
|
19
|
-
};
|
|
20
|
-
const downHandler = () => {
|
|
21
|
-
setSelectedIndex((selectedIndex + 1) % props.items.length);
|
|
22
|
-
};
|
|
23
|
-
const enterHandler = () => {
|
|
24
|
-
selectItem(selectedIndex);
|
|
25
|
-
};
|
|
26
|
-
useEffect(() => setSelectedIndex(0), [props.items]);
|
|
27
|
-
useImperativeHandle(ref, () => ({
|
|
28
|
-
onKeyDown: ({ event }) => {
|
|
29
|
-
if (event.key === 'ArrowUp') {
|
|
30
|
-
upHandler();
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (event.key === 'ArrowDown') {
|
|
34
|
-
downHandler();
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (event.key === 'Enter') {
|
|
38
|
-
enterHandler();
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
},
|
|
43
|
-
}));
|
|
44
|
-
if (items.length <= 0) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return (_jsx(VirtualizedMenu, { className: `${COMPONENT_CLS}-emoji-list`, itemSize: ITEM_SIZE, selected: items.at(selectedIndex) ? [items[selectedIndex].slug] : [], onClick: item => {
|
|
48
|
-
const idx = items.findIndex(i => i.slug === item.item.key);
|
|
49
|
-
if (idx !== -1) {
|
|
50
|
-
selectItem(idx);
|
|
51
|
-
}
|
|
52
|
-
}, items: items.map(i => ({
|
|
53
|
-
key: i.slug,
|
|
54
|
-
className: clsx(`${COMPONENT_CLS}-emoji-item`),
|
|
55
|
-
label: (_jsxs(_Fragment, { children: [_jsx("span", { style: {
|
|
56
|
-
lineHeight: 1,
|
|
57
|
-
fontSize: ITEM_SIZE - 8,
|
|
58
|
-
}, children: i.emoji }), _jsxs(Typography.Text, { ellipsis: {
|
|
59
|
-
tooltip: {
|
|
60
|
-
title: i.slug,
|
|
61
|
-
mouseEnterDelay: 0.3,
|
|
62
|
-
placement: 'right',
|
|
63
|
-
},
|
|
64
|
-
}, children: [":", i.slug] }, i.slug)] })),
|
|
65
|
-
})) }));
|
|
66
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { posToDOMRect, ReactRenderer } from '@tiptap/react';
|
|
2
|
-
import { LIST_EMOJI } from '../../extensions/Emoji';
|
|
3
|
-
import { EmojiList, ITEM_SIZE } from './EmojiList';
|
|
4
|
-
import { computePosition, flip, shift } from '@floating-ui/dom';
|
|
5
|
-
import { COMPONENT_CLS } from '../../constants';
|
|
6
|
-
import { calInlineListSize } from '@antscorp/antsomi-ui/es/components/molecules/VirtualizedMenu/utils';
|
|
7
|
-
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
8
|
-
const updatePosition = (editor, element, itemLength) => {
|
|
9
|
-
const virtualElement = {
|
|
10
|
-
getBoundingClientRect: () => posToDOMRect(editor.view, editor.state.selection.from, editor.state.selection.to),
|
|
11
|
-
};
|
|
12
|
-
computePosition(virtualElement, element, {
|
|
13
|
-
placement: 'top-start',
|
|
14
|
-
strategy: 'absolute',
|
|
15
|
-
middleware: [shift(), flip()],
|
|
16
|
-
}).then(({ x, y, strategy }) => {
|
|
17
|
-
element.style.height = `${calInlineListSize(Math.min(itemLength, 6), ITEM_SIZE)}px`;
|
|
18
|
-
element.style.position = strategy;
|
|
19
|
-
element.style.left = `${x}px`;
|
|
20
|
-
element.style.top = `${y}px`;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
export const suggestion = ({ container }) => ({
|
|
24
|
-
items: ({ query }) => LIST_EMOJI.filter(i => searchStringQuery(i.slug, query)),
|
|
25
|
-
render() {
|
|
26
|
-
let renderer;
|
|
27
|
-
const safeGetRenndererEl = () => {
|
|
28
|
-
if (renderer.element instanceof HTMLElement) {
|
|
29
|
-
return renderer.element;
|
|
30
|
-
}
|
|
31
|
-
throw Error('ReactRenderer element should be HTMLElement');
|
|
32
|
-
};
|
|
33
|
-
const destroy = () => {
|
|
34
|
-
renderer.destroy();
|
|
35
|
-
safeGetRenndererEl().remove();
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
onStart: props => {
|
|
39
|
-
renderer = new ReactRenderer(EmojiList, {
|
|
40
|
-
props,
|
|
41
|
-
editor: props.editor,
|
|
42
|
-
});
|
|
43
|
-
if (!props.clientRect) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const rendererEl = safeGetRenndererEl();
|
|
47
|
-
rendererEl.classList.add(`${COMPONENT_CLS}-emoji-popover`);
|
|
48
|
-
(container || document.body).appendChild(rendererEl);
|
|
49
|
-
updatePosition(props.editor, rendererEl, props.items.length);
|
|
50
|
-
},
|
|
51
|
-
onUpdate(props) {
|
|
52
|
-
renderer.updateProps(props);
|
|
53
|
-
const rendererEl = safeGetRenndererEl();
|
|
54
|
-
if (!props.clientRect) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
updatePosition(props.editor, rendererEl, props.items.length);
|
|
58
|
-
},
|
|
59
|
-
onKeyDown(props) {
|
|
60
|
-
if (props.event.key === 'Escape') {
|
|
61
|
-
destroy();
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return renderer.ref?.onKeyDown(props) || false;
|
|
65
|
-
},
|
|
66
|
-
onExit() {
|
|
67
|
-
destroy();
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FontConfig } from '../../types';
|
|
3
|
-
type FontPopoverProps = {
|
|
4
|
-
fonts?: FontConfig[];
|
|
5
|
-
value?: {
|
|
6
|
-
font: FontConfig;
|
|
7
|
-
weight: number;
|
|
8
|
-
};
|
|
9
|
-
onChange?: (font: FontConfig, weight: number) => void;
|
|
10
|
-
};
|
|
11
|
-
export declare const FontPopover: import("react").MemoExoticComponent<(props: FontPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Flex, Typography } from 'antd';
|
|
3
|
-
import { SearchPopover, VirtualizedMenu } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
4
|
-
import { ChevronRight } from 'lucide-react';
|
|
5
|
-
import { DEFAULT_FONT_CONFIGS, FONT_WEIGHT_MAP } from '../../constants';
|
|
6
|
-
import { memo, useMemo, useState } from 'react';
|
|
7
|
-
import { PopoverTrigger } from './styled';
|
|
8
|
-
import { calInlineListSize } from '@antscorp/antsomi-ui/es/components/molecules/VirtualizedMenu/utils';
|
|
9
|
-
import { useTextEditorStore } from '../../provider';
|
|
10
|
-
import clsx from 'clsx';
|
|
11
|
-
import { TextEditorPopover } from '../Popover';
|
|
12
|
-
const FontItem = (props) => {
|
|
13
|
-
const { fontConfig, active, onSelectFont, onOpenChange } = props;
|
|
14
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
-
const numOfWeight = fontConfig.fontWeight.length;
|
|
16
|
-
const isActive = active.font.fontFamily.name === fontConfig.fontFamily.name;
|
|
17
|
-
const fontNameContent = (_jsxs(Flex, { className: clsx('font-popover-item', { active: isOpen || isActive }), style: { fontFamily: fontConfig.fontFamily.name }, onClick: () => onSelectFont?.(400), align: "center", justify: "space-between", children: [fontConfig.fontFamily.name, numOfWeight > 1 && _jsx(ChevronRight, { size: 14 })] }));
|
|
18
|
-
const handleOpenChange = (newOpen) => {
|
|
19
|
-
setIsOpen(newOpen);
|
|
20
|
-
onOpenChange?.(newOpen);
|
|
21
|
-
};
|
|
22
|
-
if (numOfWeight < 2) {
|
|
23
|
-
return fontNameContent;
|
|
24
|
-
}
|
|
25
|
-
return (_jsx(TextEditorPopover, { open: isOpen, onOpenChange: handleOpenChange, placement: "rightTop", trigger: ['hover'], arrow: false, overlayClassName: "font-weight-popover", destroyTooltipOnHide: true, content: _jsx(Flex, { vertical: true, gap: 4, children: fontConfig.fontWeight.map(weight => (_jsx(Typography.Text, { className: clsx('font-weight-item', {
|
|
26
|
-
active: active.weight === weight,
|
|
27
|
-
}), style: {
|
|
28
|
-
fontFamily: fontConfig.fontFamily.name,
|
|
29
|
-
fontWeight: weight,
|
|
30
|
-
}, onClick: () => onSelectFont?.(weight), children: FONT_WEIGHT_MAP[weight] }, weight))) }), children: fontNameContent }));
|
|
31
|
-
};
|
|
32
|
-
export const FontPopover = memo((props) => {
|
|
33
|
-
const { fonts = [], value: fontValue = {
|
|
34
|
-
font: DEFAULT_FONT_CONFIGS[0],
|
|
35
|
-
weight: 400,
|
|
36
|
-
}, onChange, } = props;
|
|
37
|
-
const [search, setSearch] = useState('');
|
|
38
|
-
const [open, setOpen] = useState(false);
|
|
39
|
-
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
40
|
-
const filteredFonts = useMemo(() => fonts
|
|
41
|
-
.filter(font => font.fontFamily.name.toLowerCase().includes(search.toLowerCase()))
|
|
42
|
-
.sort((a, b) => a.fontFamily.name.localeCompare(b.fontFamily.name)), [fonts, search]);
|
|
43
|
-
const handleClose = () => {
|
|
44
|
-
setOpen(false);
|
|
45
|
-
setSearch('');
|
|
46
|
-
};
|
|
47
|
-
const handleOpenChange = (newOpen) => {
|
|
48
|
-
setOpen(newOpen);
|
|
49
|
-
if (newOpen === false) {
|
|
50
|
-
handleClose();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const handleChangeFont = (font, weight = 400) => {
|
|
54
|
-
onChange?.(font, weight);
|
|
55
|
-
handleClose();
|
|
56
|
-
};
|
|
57
|
-
const itemSize = 30;
|
|
58
|
-
const itemSpacing = 4;
|
|
59
|
-
const activeFontName = fontValue.font.fontFamily.name;
|
|
60
|
-
return (_jsx(SearchPopover, { open: open, placement: "bottomLeft", onOpenChange: handleOpenChange, getPopupContainer: () => bubbleMenuContainer || document.body, inputSearchProps: {
|
|
61
|
-
value: search,
|
|
62
|
-
onAfterChange: setSearch,
|
|
63
|
-
}, overlayClassName: "font-popover-overlay", content: _jsx("div", { className: "list-font-root", style: {
|
|
64
|
-
height: calInlineListSize(Math.min(filteredFonts.length, 6), itemSize, itemSpacing),
|
|
65
|
-
}, children: _jsx(VirtualizedMenu, { itemSize: itemSize, inlinePadding: 0, itemSpacing: itemSpacing, items: filteredFonts.map(fontConfig => ({
|
|
66
|
-
key: fontConfig.fontFamily.name,
|
|
67
|
-
label: (_jsx(FontItem, { fontConfig: fontConfig, active: { font: fontValue.font, weight: fontValue.weight }, onSelectFont: weight => handleChangeFont(fontConfig, weight) })),
|
|
68
|
-
})) }) }), children: _jsx(PopoverTrigger, { className: "font-popover-trigger", children: activeFontName }) }));
|
|
69
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PopoverTrigger: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
export const PopoverTrigger = styled.div `
|
|
4
|
-
&.font-popover-trigger {
|
|
5
|
-
width: 90px;
|
|
6
|
-
height: 22.5px;
|
|
7
|
-
padding: 0 7px;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
white-space: nowrap;
|
|
11
|
-
line-height: 22.5px;
|
|
12
|
-
text-overflow: ellipsis;
|
|
13
|
-
font-size: ${THEME.token?.fontSize || 12}px;
|
|
14
|
-
border-bottom: 1px solid ${THEME.token?.blue1};
|
|
15
|
-
|
|
16
|
-
&:hover {
|
|
17
|
-
background-color: ${THEME.token?.blue};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { PopoverProps } from 'antd/lib';
|
|
3
|
-
export interface TextEditorPopoverProps extends PopoverProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
export declare const TextEditorPopover: ({ children, ...restProps }: TextEditorPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Popover } from 'antd';
|
|
3
|
-
import { useTextEditorStore } from '../../provider';
|
|
4
|
-
export const TextEditorPopover = ({ children, ...restProps }) => {
|
|
5
|
-
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
6
|
-
return (_jsx(Popover, { ...restProps, getPopupContainer: () => bubbleMenuContainer || document.body, children: children }));
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Popover';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Popover';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Select } from 'antd';
|
|
3
|
-
import { useTextEditorStore } from '../../provider';
|
|
4
|
-
export const TextEditorSelect = (props) => {
|
|
5
|
-
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
6
|
-
return _jsx(Select, { ...props, getPopupContainer: () => bubbleMenuContainer || document.body });
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Select';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Select';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Editor } from '@tiptap/core';
|
|
3
|
-
declare const textAlignOptions: readonly [{
|
|
4
|
-
readonly label: string;
|
|
5
|
-
readonly value: string;
|
|
6
|
-
readonly shortcut: string;
|
|
7
|
-
readonly icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
8
|
-
}, {
|
|
9
|
-
readonly label: string;
|
|
10
|
-
readonly value: string;
|
|
11
|
-
readonly shortcut: string;
|
|
12
|
-
readonly icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
13
|
-
}, {
|
|
14
|
-
readonly label: string;
|
|
15
|
-
readonly value: string;
|
|
16
|
-
readonly shortcut: string;
|
|
17
|
-
readonly icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
18
|
-
}, {
|
|
19
|
-
readonly label: string;
|
|
20
|
-
readonly value: string;
|
|
21
|
-
readonly shortcut: string;
|
|
22
|
-
readonly icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
23
|
-
}];
|
|
24
|
-
type AlignType = (typeof textAlignOptions)[number]['value'];
|
|
25
|
-
interface TextAlignSelectProps {
|
|
26
|
-
editor?: Editor;
|
|
27
|
-
onChange?: (value: AlignType) => void;
|
|
28
|
-
}
|
|
29
|
-
export declare const TextAlignSelect: (props: TextAlignSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Flex, Tooltip } from 'antd';
|
|
3
|
-
import { AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon } from 'lucide-react';
|
|
4
|
-
import { useMemo, useState } from 'react';
|
|
5
|
-
import { formatHotkey } from '../../utils';
|
|
6
|
-
import { TEXT_EDITOR_CONSTANTS } from '../../constants';
|
|
7
|
-
import { TextEditorPopover } from '../Popover';
|
|
8
|
-
const { TEXT_ALIGN } = TEXT_EDITOR_CONSTANTS;
|
|
9
|
-
const textAlignOptions = [
|
|
10
|
-
{
|
|
11
|
-
label: TEXT_ALIGN.OPTIONS.LEFT.LABEL,
|
|
12
|
-
value: TEXT_ALIGN.OPTIONS.LEFT.VALUE,
|
|
13
|
-
shortcut: formatHotkey('Shift+L'),
|
|
14
|
-
icon: AlignLeftIcon,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: TEXT_ALIGN.OPTIONS.CENTER.LABEL,
|
|
18
|
-
value: TEXT_ALIGN.OPTIONS.CENTER.VALUE,
|
|
19
|
-
shortcut: formatHotkey('Shift+E'),
|
|
20
|
-
icon: AlignCenterIcon,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
label: TEXT_ALIGN.OPTIONS.RIGHT.LABEL,
|
|
24
|
-
value: TEXT_ALIGN.OPTIONS.RIGHT.VALUE,
|
|
25
|
-
shortcut: formatHotkey('Shift+R'),
|
|
26
|
-
icon: AlignRightIcon,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: TEXT_ALIGN.OPTIONS.JUSTIFY.LABEL,
|
|
30
|
-
value: TEXT_ALIGN.OPTIONS.JUSTIFY.VALUE,
|
|
31
|
-
shortcut: formatHotkey('Shift+J'),
|
|
32
|
-
icon: AlignJustifyIcon,
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
export const TextAlignSelect = (props) => {
|
|
36
|
-
const { editor, onChange } = props;
|
|
37
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
38
|
-
const currentAlignment = ['left', 'center', 'right', 'justify'].find(alignment => editor?.isActive({ textAlign: alignment }));
|
|
39
|
-
const selectedOption = useMemo(() => textAlignOptions.find(option => option.value === currentAlignment), [currentAlignment]);
|
|
40
|
-
const handleClickOption = (align) => {
|
|
41
|
-
setIsOpen(false);
|
|
42
|
-
onChange?.(align);
|
|
43
|
-
};
|
|
44
|
-
let AlignIconComponent = textAlignOptions[0].icon;
|
|
45
|
-
if (selectedOption) {
|
|
46
|
-
AlignIconComponent = selectedOption.icon;
|
|
47
|
-
}
|
|
48
|
-
return (_jsx(TextEditorPopover, { destroyTooltipOnHide: true, open: isOpen, arrow: false, content: _jsx(Flex, { gap: 8, children: textAlignOptions.map(option => (_jsx(Tooltip, { title: `${TEXT_ALIGN.TOOLTIP} ${option.label.toLowerCase()} (${option.shortcut})`, placement: "bottom", children: _jsx(Button, { size: "small", icon: _jsx(option.icon, { size: 16 }, option.value), onClick: () => handleClickOption(option.value), type: currentAlignment === option.value ? 'primary' : 'default' }) }, option.value))) }), trigger: ['click'], placement: "bottomLeft", onOpenChange: setOpen => setIsOpen(setOpen), children: _jsx(Tooltip, { title: TEXT_ALIGN.TITLE, placement: "top", children: _jsx(Button, { size: "small", icon: _jsx(AlignIconComponent, { size: 16 }), type: currentAlignment ? 'primary' : 'default' }) }) }));
|
|
49
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TextAlignSelect } from './TextAlignSelect';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TextAlignSelect } from './TextAlignSelect';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Editor } from '@tiptap/core';
|
|
3
|
-
import { Config } from '../../types';
|
|
4
|
-
export type ToolbarProps = {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
config?: Config;
|
|
7
|
-
smartTagHandler?: {
|
|
8
|
-
onUpsert?: (event: React.MouseEvent) => void;
|
|
9
|
-
};
|
|
10
|
-
linkHanlder?: {
|
|
11
|
-
onUpsert?: () => void;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export declare const Toolbar: (props: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Divider, Flex, Tooltip, Typography } from 'antd';
|
|
3
|
-
import { BoldAction } from './actions/BoldAction';
|
|
4
|
-
import { BulletListAction } from './actions/BulletListAction';
|
|
5
|
-
import { ClearFormattingAction } from './actions/ClearFormattingAction';
|
|
6
|
-
import { FontFamilyAction } from './actions/FontFamilyAction';
|
|
7
|
-
import { FontSizeAction } from './actions/FontSizeAction';
|
|
8
|
-
import { TextBackColorAction } from './actions/TextBackgroundColorAction';
|
|
9
|
-
import { IndentAction } from './actions/IndentAction';
|
|
10
|
-
import { ItalicAction } from './actions/ItalicAction';
|
|
11
|
-
import { LinkAction } from './actions/LinkAction';
|
|
12
|
-
import { OrderedListAction } from './actions/OrderedListAction';
|
|
13
|
-
import { OutdentAction } from './actions/OutdentAction';
|
|
14
|
-
import { SmartTagAction } from './actions/SmartTagAction';
|
|
15
|
-
import { StrikeAction } from './actions/StrikeAction';
|
|
16
|
-
import { SubscriptAction } from './actions/SubscriptAction';
|
|
17
|
-
import { SuperscriptAction } from './actions/SuperscriptAction';
|
|
18
|
-
import { TextAlignAction } from './actions/TextAlignAction';
|
|
19
|
-
import { TextColorAction } from './actions/TextColorAction';
|
|
20
|
-
import { TextTransformAction } from './actions/TextTransformAction';
|
|
21
|
-
import { UnderlineAction } from './actions/UnderlineAction';
|
|
22
|
-
import { SpacingAction } from './actions/SpacingAction';
|
|
23
|
-
import { getLinkMark, isShowLinkMenu } from '../../utils';
|
|
24
|
-
import { CopyIcon, PencilIcon } from 'lucide-react';
|
|
25
|
-
import { ToolbarWrapper } from '../../styled';
|
|
26
|
-
import { UnsetLinkAction } from './actions/UnsetLink';
|
|
27
|
-
import { EmoijiAction } from './actions';
|
|
28
|
-
export const Toolbar = (props) => {
|
|
29
|
-
const { editor, smartTagHandler, linkHanlder, config } = props;
|
|
30
|
-
if (isShowLinkMenu(editor.state)) {
|
|
31
|
-
const { attrs } = getLinkMark({ state: editor.state }) || {};
|
|
32
|
-
const href = String(attrs?.href);
|
|
33
|
-
return (_jsxs(ToolbarWrapper, { wrap: "wrap", gap: 8, align: "center", children: [_jsx(Typography.Link, { style: { maxWidth: 150 }, ellipsis: true, href: href, children: href }), _jsx(Tooltip, { title: "Copy", children: _jsx(Button, { size: "small", icon: _jsx(CopyIcon, { size: 16 }), onClick: () => {
|
|
34
|
-
navigator.clipboard.writeText(href);
|
|
35
|
-
} }) }), _jsx(Tooltip, { title: "Edit", children: _jsx(Button, { size: "small", icon: _jsx(PencilIcon, { size: 16 }), onClick: () => linkHanlder?.onUpsert?.() }) }), _jsx(UnsetLinkAction, { editor: editor })] }));
|
|
36
|
-
}
|
|
37
|
-
return (_jsxs(ToolbarWrapper, { vertical: true, gap: 8, children: [_jsxs(Flex, { gap: 8, justify: "flex-start", align: "center", children: [_jsx(FontFamilyAction, { editor: editor, fonts: config?.FontFamily?.fonts }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(FontSizeAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(BoldAction, { editor: editor }), _jsx(ItalicAction, { editor: editor }), _jsx(UnderlineAction, { editor: editor }), _jsx(StrikeAction, { editor: editor }), _jsx(SuperscriptAction, { editor: editor }), _jsx(SubscriptAction, { editor: editor }), _jsx(TextTransformAction, { editor: editor })] }), _jsxs(Flex, { gap: 8, justify: "flex-start", align: "center", children: [_jsx(LinkAction, { editor: editor, onClick: linkHanlder?.onUpsert }), _jsx(SmartTagAction, { editor: editor, onClick: smartTagHandler?.onUpsert }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(TextColorAction, { editor: editor, colorPickerProps: {
|
|
38
|
-
usedColorsStorageKey: config?.Color?.colorPickerStorageKey,
|
|
39
|
-
} }), _jsx(TextBackColorAction, { editor: editor, colorPickerProps: {
|
|
40
|
-
usedColorsStorageKey: config?.BackgroundColor?.colorPickerStorageKey,
|
|
41
|
-
} }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(BulletListAction, { editor: editor }), _jsx(OrderedListAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(TextAlignAction, { editor: editor }), _jsx(SpacingAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(IndentAction, { editor: editor }), _jsx(OutdentAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(EmoijiAction, { editor: editor }), _jsx(ClearFormattingAction, { editor: editor })] })] }));
|
|
42
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Tooltip } from 'antd';
|
|
3
|
-
import { BoldIcon } from 'lucide-react';
|
|
4
|
-
import { formatHotkey } from '../../../utils';
|
|
5
|
-
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
6
|
-
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
7
|
-
export const BoldAction = ({ editor }) => (_jsx(Tooltip, { title: `${TOOLTIPS.BOLD.TITLE} (${formatHotkey(TOOLTIPS.BOLD.SHORTCUT)})`, placement: "top", children: _jsx(Button, { size: "small", disabled: !editor.can().chain().focus().toggleBold().run(), onClick: () => editor.chain().focus().toggleBold().run(), type: editor.isActive('bold') ? 'primary' : 'default', icon: _jsx(BoldIcon, { size: 16 }) }) }));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Tooltip } from 'antd';
|
|
3
|
-
import { ListIcon } from 'lucide-react';
|
|
4
|
-
import { formatHotkey } from '../../../utils';
|
|
5
|
-
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
6
|
-
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
7
|
-
export const BulletListAction = ({ editor }) => (_jsx(Tooltip, { title: `${TOOLTIPS.BULLET_LIST.TITLE} (${formatHotkey(TOOLTIPS.BULLET_LIST.SHORTCUT)})`, placement: "top", children: _jsx(Button, { size: "small", onClick: () => editor.chain().focus().toggleBulletList().run(), type: editor.isActive('bulletList') ? 'primary' : 'default', icon: _jsx(ListIcon, { size: 16 }) }) }));
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Tooltip } from 'antd';
|
|
3
|
-
import { RemoveFormattingIcon } from 'lucide-react';
|
|
4
|
-
import { DEFAULT_TEXT_STYLE, TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
5
|
-
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
-
export const ClearFormattingAction = ({ editor }) => {
|
|
7
|
-
const clearFormatting = () => {
|
|
8
|
-
editor
|
|
9
|
-
?.chain()
|
|
10
|
-
.updateAttributes('textStyle', DEFAULT_TEXT_STYLE)
|
|
11
|
-
.unsetAllMarks()
|
|
12
|
-
.clearNodes()
|
|
13
|
-
.unsetTextAlign()
|
|
14
|
-
.unsetTextTransform()
|
|
15
|
-
.run();
|
|
16
|
-
};
|
|
17
|
-
return (_jsx(Tooltip, { title: TOOLTIPS.CLEAR_FORMATTING.TITLE, placement: "top", children: _jsx(Button, { size: "small", onClick: clearFormatting, icon: _jsx(RemoveFormattingIcon, { size: 16 }) }) }));
|
|
18
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { EmojiSmileIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
3
|
-
import { EMOJI_COLLECTIONS, EmojiPopover } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
4
|
-
export const EmoijiAction = ({ editor }) => (_jsx(EmojiPopover, { collections: [
|
|
5
|
-
{
|
|
6
|
-
key: EMOJI_COLLECTIONS.COMMON,
|
|
7
|
-
label: _jsx(EmojiSmileIcon, {}),
|
|
8
|
-
},
|
|
9
|
-
], onEmojiClick: emoji => {
|
|
10
|
-
if (typeof emoji !== 'string')
|
|
11
|
-
return;
|
|
12
|
-
editor?.chain().insertEmoji(emoji);
|
|
13
|
-
} }));
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { FontConfig } from '../../../types';
|
|
3
|
-
export interface FontFamilyActionProps {
|
|
4
|
-
editor: Editor;
|
|
5
|
-
fonts?: FontConfig[];
|
|
6
|
-
}
|
|
7
|
-
export declare const FontFamilyAction: (props: FontFamilyActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { toString } from 'lodash';
|
|
3
|
-
import { DEFAULT_FONT_CONFIGS } from '../../../constants';
|
|
4
|
-
import { FontPopover } from '../../FontPopover/FontPopover';
|
|
5
|
-
export const FontFamilyAction = (props) => {
|
|
6
|
-
const { editor, fonts = DEFAULT_FONT_CONFIGS } = props;
|
|
7
|
-
const { fontWeight, fontFamily } = editor.getAttributes('textStyle') || {};
|
|
8
|
-
let fontValue = toString(fontFamily);
|
|
9
|
-
if (fontValue.split(',').length > 0) {
|
|
10
|
-
[fontValue] = fontValue.split(',');
|
|
11
|
-
}
|
|
12
|
-
return (_jsx(FontPopover, { fonts: fonts, value: {
|
|
13
|
-
font: fonts.find(font => font.fontFamily.name === fontValue) || fonts[0],
|
|
14
|
-
weight: Number(fontWeight),
|
|
15
|
-
}, onChange: (font, weight) => {
|
|
16
|
-
editor.chain().focus().setFontFamily(font.fontFamily.name).setFontWeight(weight).run();
|
|
17
|
-
} }));
|
|
18
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Editor } from '@tiptap/core';
|
|
3
|
-
export interface FontSizeActionProps {
|
|
4
|
-
editor: Editor;
|
|
5
|
-
debounceUpdateSize?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const FontSizeAction: import("react").MemoExoticComponent<({ editor, debounceUpdateSize }: FontSizeActionProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useTextEditorStore } from '../../../provider';
|
|
3
|
-
import { FontSizeInput, } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
6
|
-
import { useDebouncedCallback } from 'use-debounce';
|
|
7
|
-
import { DEFAULT_TEXT_STYLE } from '../../../constants';
|
|
8
|
-
const StyledFontSizeInput = styled(FontSizeInput) `
|
|
9
|
-
&.antsomi-input-number {
|
|
10
|
-
height: 22.5px;
|
|
11
|
-
width: 54px;
|
|
12
|
-
|
|
13
|
-
input.antsomi-input-number-input {
|
|
14
|
-
font-size: 12px;
|
|
15
|
-
padding: 0 0 0 7px;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
export const FontSizeAction = memo(({ editor, debounceUpdateSize = 500 }) => {
|
|
20
|
-
const inputRef = useRef(null);
|
|
21
|
-
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
22
|
-
const numberFontSize = (editor.getAttributes('textStyle').fontSize || DEFAULT_TEXT_STYLE.fontSize).replace('px', '');
|
|
23
|
-
const [currentFontSize, setCurrentFontSize] = useState(numberFontSize);
|
|
24
|
-
const updateEditorFontSize = useDebouncedCallback((v) => {
|
|
25
|
-
if (v === numberFontSize)
|
|
26
|
-
return;
|
|
27
|
-
editor.chain().focus().setFontSize(`${v}px`).run();
|
|
28
|
-
}, debounceUpdateSize);
|
|
29
|
-
const handleFontSizeChange = useCallback((value) => {
|
|
30
|
-
setCurrentFontSize(+value);
|
|
31
|
-
updateEditorFontSize(+value);
|
|
32
|
-
}, [updateEditorFontSize]);
|
|
33
|
-
const dropdownProps = useMemo(() => ({
|
|
34
|
-
getPopupContainer: () => bubbleMenuContainer,
|
|
35
|
-
}), [bubbleMenuContainer]);
|
|
36
|
-
return (_jsx(StyledFontSizeInput, { ref: inputRef, delay: 100, placeholder: "Font Size", value: currentFontSize, onChange: handleFontSizeChange, dropdownProps: dropdownProps }));
|
|
37
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Tooltip } from 'antd';
|
|
3
|
-
import { HighlighterIcon } from 'lucide-react';
|
|
4
|
-
import { ColorPicker } from '../../ColorPicker';
|
|
5
|
-
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
6
|
-
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
7
|
-
export const HighlightAction = ({ editor }) => (_jsx(ColorPicker, { value: editor.getAttributes('highlight').color, onChange: v => editor.chain().focus().setHighlight({ color: v }).run(), usedColorsStorageKey: "text-backgrounds", children: _jsx(Tooltip, { title: TOOLTIPS.HIGHLIGHT.TITLE, placement: "top", children: _jsx(Button, { size: "small", icon: _jsx(HighlighterIcon, { color: editor.getAttributes('highlight').color, size: 16 }) }) }) }));
|