@antscorp/antsomi-ui 2.0.86-text-editor-beta.5 → 2.0.86
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/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/components/template/Layout/constants/permission.d.ts +1 -0
- package/es/components/template/Layout/constants/permission.js +1 -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 -7
- package/es/components/organism/TextEditor/hooks/index.js +0 -7
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.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 -12
- package/es/components/organism/TextEditor/provider.js +0 -34
- package/es/components/organism/TextEditor/store.d.ts +0 -13
- package/es/components/organism/TextEditor/store.js +0 -20
- 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 -132
- 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 -319
- 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,247 +0,0 @@
|
|
|
1
|
-
import { arrow, autoPlacement, computePosition, flip, hide, inline, offset, shift, size, } from '@floating-ui/dom';
|
|
2
|
-
import { isTextSelection, posToDOMRect } from '@tiptap/core';
|
|
3
|
-
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
4
|
-
export class BubbleMenuView {
|
|
5
|
-
get middlewares() {
|
|
6
|
-
const middlewares = [];
|
|
7
|
-
if (this.floatingUIOptions.flip) {
|
|
8
|
-
middlewares.push(flip(typeof this.floatingUIOptions.flip !== 'boolean'
|
|
9
|
-
? this.floatingUIOptions.flip
|
|
10
|
-
: undefined));
|
|
11
|
-
}
|
|
12
|
-
if (this.floatingUIOptions.shift) {
|
|
13
|
-
middlewares.push(shift(typeof this.floatingUIOptions.shift !== 'boolean'
|
|
14
|
-
? this.floatingUIOptions.shift
|
|
15
|
-
: undefined));
|
|
16
|
-
}
|
|
17
|
-
if (this.floatingUIOptions.offset) {
|
|
18
|
-
middlewares.push(offset(typeof this.floatingUIOptions.offset !== 'boolean'
|
|
19
|
-
? this.floatingUIOptions.offset
|
|
20
|
-
: undefined));
|
|
21
|
-
}
|
|
22
|
-
if (this.floatingUIOptions.arrow) {
|
|
23
|
-
middlewares.push(arrow(this.floatingUIOptions.arrow));
|
|
24
|
-
}
|
|
25
|
-
if (this.floatingUIOptions.size) {
|
|
26
|
-
middlewares.push(size(typeof this.floatingUIOptions.size !== 'boolean'
|
|
27
|
-
? this.floatingUIOptions.size
|
|
28
|
-
: undefined));
|
|
29
|
-
}
|
|
30
|
-
if (this.floatingUIOptions.autoPlacement) {
|
|
31
|
-
middlewares.push(autoPlacement(typeof this.floatingUIOptions.autoPlacement !== 'boolean'
|
|
32
|
-
? this.floatingUIOptions.autoPlacement
|
|
33
|
-
: undefined));
|
|
34
|
-
}
|
|
35
|
-
if (this.floatingUIOptions.hide) {
|
|
36
|
-
middlewares.push(hide(typeof this.floatingUIOptions.hide !== 'boolean'
|
|
37
|
-
? this.floatingUIOptions.hide
|
|
38
|
-
: undefined));
|
|
39
|
-
}
|
|
40
|
-
if (this.floatingUIOptions.inline) {
|
|
41
|
-
middlewares.push(inline(typeof this.floatingUIOptions.inline !== 'boolean'
|
|
42
|
-
? this.floatingUIOptions.inline
|
|
43
|
-
: undefined));
|
|
44
|
-
}
|
|
45
|
-
return middlewares;
|
|
46
|
-
}
|
|
47
|
-
constructor({ editor, element, view, updateDelay = 250, resizeDelay = 60, container, shouldShow, options, onShow, onHide, }) {
|
|
48
|
-
this.preventHide = false;
|
|
49
|
-
this.floatingUIOptions = {
|
|
50
|
-
strategy: 'absolute',
|
|
51
|
-
placement: 'top',
|
|
52
|
-
offset: 8,
|
|
53
|
-
flip: {},
|
|
54
|
-
shift: {},
|
|
55
|
-
arrow: false,
|
|
56
|
-
size: false,
|
|
57
|
-
autoPlacement: false,
|
|
58
|
-
hide: false,
|
|
59
|
-
inline: false,
|
|
60
|
-
};
|
|
61
|
-
this.shouldShow = ({ view, state, from, to, }) => {
|
|
62
|
-
const { doc, selection } = state;
|
|
63
|
-
const { empty } = selection;
|
|
64
|
-
// Sometime check for `empty` is not enough.
|
|
65
|
-
// Doubleclick an empty paragraph returns a node size of 2.
|
|
66
|
-
// So we check also for an empty text size.
|
|
67
|
-
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
68
|
-
// When clicking on a element inside the bubble menu the editor "blur" event
|
|
69
|
-
// is called and the bubble menu item is focussed. In this case we should
|
|
70
|
-
// consider the menu as part of the editor and keep showing the menu
|
|
71
|
-
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
72
|
-
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
73
|
-
if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
};
|
|
78
|
-
this.mousedownHandler = () => {
|
|
79
|
-
this.preventHide = true;
|
|
80
|
-
};
|
|
81
|
-
this.dragstartHandler = () => {
|
|
82
|
-
this.hide();
|
|
83
|
-
};
|
|
84
|
-
this.focusHandler = () => {
|
|
85
|
-
// we use `setTimeout` to make sure `selection` is already updated
|
|
86
|
-
setTimeout(() => this.update(this.editor.view));
|
|
87
|
-
};
|
|
88
|
-
this.blurHandler = ({ event }) => {
|
|
89
|
-
if (this.preventHide) {
|
|
90
|
-
this.preventHide = false;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (event?.relatedTarget && this.element.parentNode?.contains(event.relatedTarget)) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (event?.relatedTarget === this.editor.view.dom) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.hide();
|
|
100
|
-
};
|
|
101
|
-
this.handleDebouncedUpdate = (view, oldState) => {
|
|
102
|
-
const selectionChanged = !oldState?.selection.eq(view.state.selection);
|
|
103
|
-
const docChanged = !oldState?.doc.eq(view.state.doc);
|
|
104
|
-
if (!selectionChanged && !docChanged) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (this.updateDebounceTimer) {
|
|
108
|
-
clearTimeout(this.updateDebounceTimer);
|
|
109
|
-
}
|
|
110
|
-
this.updateDebounceTimer = window.setTimeout(() => {
|
|
111
|
-
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
112
|
-
}, this.updateDelay);
|
|
113
|
-
};
|
|
114
|
-
this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
|
|
115
|
-
const { composing } = view;
|
|
116
|
-
const isSame = !selectionChanged && !docChanged;
|
|
117
|
-
if (composing || isSame) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const shouldShow = this.getShouldShow(oldState);
|
|
121
|
-
if (!shouldShow) {
|
|
122
|
-
this.hide();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this.show();
|
|
126
|
-
this.updatePosition();
|
|
127
|
-
};
|
|
128
|
-
this.editor = editor;
|
|
129
|
-
this.element = element;
|
|
130
|
-
this.view = view;
|
|
131
|
-
this.updateDelay = updateDelay;
|
|
132
|
-
this.resizeDelay = resizeDelay;
|
|
133
|
-
this.container = container;
|
|
134
|
-
this.onShow = onShow;
|
|
135
|
-
this.onHide = onHide;
|
|
136
|
-
this.floatingUIOptions = {
|
|
137
|
-
...this.floatingUIOptions,
|
|
138
|
-
...options,
|
|
139
|
-
};
|
|
140
|
-
if (shouldShow) {
|
|
141
|
-
this.shouldShow = shouldShow;
|
|
142
|
-
}
|
|
143
|
-
const containerElement = this.getContainer();
|
|
144
|
-
if (containerElement === document.body) {
|
|
145
|
-
this.element.style.zIndex = '9999';
|
|
146
|
-
}
|
|
147
|
-
this.element.addEventListener('mousedown', this.mousedownHandler, { capture: true });
|
|
148
|
-
this.view.dom.addEventListener('dragstart', this.dragstartHandler);
|
|
149
|
-
this.editor.on('focus', this.focusHandler);
|
|
150
|
-
this.editor.on('blur', this.blurHandler);
|
|
151
|
-
window.addEventListener('resize', () => {
|
|
152
|
-
if (this.resizeDebounceTimer) {
|
|
153
|
-
clearTimeout(this.resizeDebounceTimer);
|
|
154
|
-
}
|
|
155
|
-
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
156
|
-
this.updatePosition();
|
|
157
|
-
}, this.resizeDelay);
|
|
158
|
-
});
|
|
159
|
-
this.update(view, view.state);
|
|
160
|
-
if (this.getShouldShow()) {
|
|
161
|
-
this.show();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
updatePosition() {
|
|
165
|
-
const { selection } = this.editor.state;
|
|
166
|
-
const virtualElement = {
|
|
167
|
-
getBoundingClientRect: () => posToDOMRect(this.view, selection.from, selection.to),
|
|
168
|
-
};
|
|
169
|
-
const strategy = this.container === document.body ? 'fixed' : this.floatingUIOptions.strategy;
|
|
170
|
-
computePosition(virtualElement, this.element, {
|
|
171
|
-
placement: this.floatingUIOptions.placement,
|
|
172
|
-
strategy,
|
|
173
|
-
middleware: this.middlewares,
|
|
174
|
-
}).then(({ x, y, strategy }) => {
|
|
175
|
-
this.element.style.width = 'max-content';
|
|
176
|
-
this.element.style.position = strategy;
|
|
177
|
-
this.element.style.left = `${x}px`;
|
|
178
|
-
this.element.style.top = `${y}px`;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
update(view, oldState) {
|
|
182
|
-
const { state } = view;
|
|
183
|
-
const hasValidSelection = state.selection.from !== state.selection.to;
|
|
184
|
-
if (this.updateDelay > 0 && hasValidSelection) {
|
|
185
|
-
this.handleDebouncedUpdate(view, oldState);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const selectionChanged = !oldState?.selection.eq(view.state.selection);
|
|
189
|
-
const docChanged = !oldState?.doc.eq(view.state.doc);
|
|
190
|
-
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
191
|
-
}
|
|
192
|
-
getShouldShow(oldState) {
|
|
193
|
-
const { state } = this.view;
|
|
194
|
-
const { selection } = state;
|
|
195
|
-
// support for CellSelections
|
|
196
|
-
const { ranges } = selection;
|
|
197
|
-
const from = Math.min(...ranges.map(range => range.$from.pos));
|
|
198
|
-
const to = Math.max(...ranges.map(range => range.$to.pos));
|
|
199
|
-
const shouldShow = this.shouldShow?.({
|
|
200
|
-
editor: this.editor,
|
|
201
|
-
element: this.element,
|
|
202
|
-
view: this.view,
|
|
203
|
-
state,
|
|
204
|
-
oldState,
|
|
205
|
-
from,
|
|
206
|
-
to,
|
|
207
|
-
});
|
|
208
|
-
return shouldShow;
|
|
209
|
-
}
|
|
210
|
-
getContainer() {
|
|
211
|
-
if (!this.container) {
|
|
212
|
-
return this.view.dom.parentElement;
|
|
213
|
-
}
|
|
214
|
-
if (typeof this.container === 'function') {
|
|
215
|
-
return this.container();
|
|
216
|
-
}
|
|
217
|
-
return this.container;
|
|
218
|
-
}
|
|
219
|
-
show() {
|
|
220
|
-
this.element.style.visibility = 'visible';
|
|
221
|
-
this.element.style.opacity = '1';
|
|
222
|
-
// attach to editor's parent element
|
|
223
|
-
const container = this.getContainer();
|
|
224
|
-
if (container) {
|
|
225
|
-
container.appendChild(this.element);
|
|
226
|
-
this.onShow?.();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
hide() {
|
|
230
|
-
this.element.style.visibility = 'hidden';
|
|
231
|
-
this.element.style.opacity = '0';
|
|
232
|
-
// remove from the parent element
|
|
233
|
-
this.element.remove();
|
|
234
|
-
this.onHide?.();
|
|
235
|
-
}
|
|
236
|
-
destroy() {
|
|
237
|
-
this.hide();
|
|
238
|
-
this.element.removeEventListener('mousedown', this.mousedownHandler, { capture: true });
|
|
239
|
-
this.view.dom.removeEventListener('dragstart', this.dragstartHandler);
|
|
240
|
-
this.editor.off('focus', this.focusHandler);
|
|
241
|
-
this.editor.off('blur', this.blurHandler);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export const BubbleMenuPlugin = (options) => new Plugin({
|
|
245
|
-
key: typeof options.pluginKey === 'string' ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
246
|
-
view: view => new BubbleMenuView({ view, ...options }),
|
|
247
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import type { BubbleMenuPluginProps } from './bubble-menu-plugin';
|
|
3
|
-
export type BubbleMenuOptions = Omit<BubbleMenuPluginProps, 'editor' | 'element'> & {
|
|
4
|
-
/**
|
|
5
|
-
* The DOM element that contains your menu.
|
|
6
|
-
* @type {HTMLElement}
|
|
7
|
-
* @default null
|
|
8
|
-
*/
|
|
9
|
-
element: HTMLElement | null;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* This extension allows you to create a bubble menu.
|
|
13
|
-
* @see https://tiptap.dev/api/extensions/bubble-menu
|
|
14
|
-
*/
|
|
15
|
-
export declare const BubbleMenu: Extension<BubbleMenuOptions, any>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { BubbleMenuPlugin } from './bubble-menu-plugin';
|
|
3
|
-
/**
|
|
4
|
-
* This extension allows you to create a bubble menu.
|
|
5
|
-
* @see https://tiptap.dev/api/extensions/bubble-menu
|
|
6
|
-
*/
|
|
7
|
-
export const BubbleMenu = Extension.create({
|
|
8
|
-
name: 'bubbleMenu',
|
|
9
|
-
addOptions() {
|
|
10
|
-
return {
|
|
11
|
-
element: null,
|
|
12
|
-
pluginKey: 'bubbleMenu',
|
|
13
|
-
updateDelay: undefined,
|
|
14
|
-
shouldShow: null,
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
addProseMirrorPlugins() {
|
|
18
|
-
if (!this.options.element) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
return [
|
|
22
|
-
BubbleMenuPlugin({
|
|
23
|
-
pluginKey: this.options.pluginKey,
|
|
24
|
-
editor: this.editor,
|
|
25
|
-
element: this.options.element,
|
|
26
|
-
updateDelay: this.options.updateDelay,
|
|
27
|
-
shouldShow: this.options.shouldShow,
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
},
|
|
31
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Color as TiptapColorExtension, } from '@tiptap/extension-color';
|
|
2
|
-
import { DEFAULT_TEXT_STYLE } from '../constants';
|
|
3
|
-
import tinycolor from 'tinycolor2';
|
|
4
|
-
export const Color = TiptapColorExtension.extend({
|
|
5
|
-
addOptions() {
|
|
6
|
-
return {
|
|
7
|
-
...this.parent?.(),
|
|
8
|
-
defaultColor: DEFAULT_TEXT_STYLE.color,
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
addGlobalAttributes() {
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
types: this.options.types,
|
|
15
|
-
attributes: {
|
|
16
|
-
color: {
|
|
17
|
-
default: null,
|
|
18
|
-
parseHTML: element => element.style.color?.replace(/['"]+/g, ''),
|
|
19
|
-
renderHTML: attrs => {
|
|
20
|
-
if (!attrs.color || tinycolor.equals(attrs.color, this.options.defaultColor)) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
style: `color: ${attrs.color}`,
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
addCommands() {
|
|
33
|
-
return {
|
|
34
|
-
...this.parent?.(),
|
|
35
|
-
unsetColor: () => ({ chain }) => chain()
|
|
36
|
-
.setMark('textStyle', { color: this.options.defaultColor || null })
|
|
37
|
-
.removeEmptyTextStyle()
|
|
38
|
-
.run(),
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
import { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
3
|
-
import { SuggestionOptions } from '@tiptap/suggestion';
|
|
4
|
-
export declare const LIST_EMOJI: ({
|
|
5
|
-
emoji: string;
|
|
6
|
-
skin_tone_support: boolean;
|
|
7
|
-
name: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
unicode_version: string;
|
|
10
|
-
emoji_version: string;
|
|
11
|
-
skin_tone_support_unicode_version?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
emoji: string;
|
|
14
|
-
skin_tone_support: boolean;
|
|
15
|
-
skin_tone_support_unicode_version: string;
|
|
16
|
-
name: string;
|
|
17
|
-
slug: string;
|
|
18
|
-
unicode_version: string;
|
|
19
|
-
emoji_version: string;
|
|
20
|
-
})[];
|
|
21
|
-
declare module '@tiptap/core' {
|
|
22
|
-
interface Commands<ReturnType> {
|
|
23
|
-
emoji: {
|
|
24
|
-
insertEmoji: (emojiName: string) => ReturnType;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export interface SuggestionItem {
|
|
29
|
-
emoji: string;
|
|
30
|
-
skin_tone_support: boolean;
|
|
31
|
-
name: string;
|
|
32
|
-
slug: string;
|
|
33
|
-
unicode_version: string;
|
|
34
|
-
emoji_version: string;
|
|
35
|
-
}
|
|
36
|
-
export interface EmojiNodeAttrs {
|
|
37
|
-
name?: string | null;
|
|
38
|
-
}
|
|
39
|
-
export type EmojiOptions<Attrs extends Record<string, any> = EmojiNodeAttrs> = {
|
|
40
|
-
HTMLAttributes: Record<string, any>;
|
|
41
|
-
renderLabel?: (props: {
|
|
42
|
-
options: EmojiOptions<Attrs>;
|
|
43
|
-
node: ProseMirrorNode;
|
|
44
|
-
}) => string;
|
|
45
|
-
renderText: (props: {
|
|
46
|
-
options: EmojiOptions<Attrs>;
|
|
47
|
-
node: ProseMirrorNode;
|
|
48
|
-
}) => string;
|
|
49
|
-
renderHTML: (props: {
|
|
50
|
-
options: EmojiOptions<Attrs>;
|
|
51
|
-
node: ProseMirrorNode;
|
|
52
|
-
}) => DOMOutputSpec;
|
|
53
|
-
deleteTriggerWithBackspace: boolean;
|
|
54
|
-
suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>;
|
|
55
|
-
};
|
|
56
|
-
export declare const EXTENSION_NAME = "emoji";
|
|
57
|
-
export declare const Emoji: Node<EmojiOptions<EmojiNodeAttrs>, any>;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
-
import { PluginKey } from '@tiptap/pm/state';
|
|
3
|
-
import Suggestion from '@tiptap/suggestion';
|
|
4
|
-
import { ICON_EMOJI_COMMON } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
5
|
-
import { memoize } from 'lodash';
|
|
6
|
-
export const LIST_EMOJI = ICON_EMOJI_COMMON.flatMap(group => group.emojis);
|
|
7
|
-
const findEmojiByName = memoize((name) => LIST_EMOJI.find(i => i.name === name)?.emoji);
|
|
8
|
-
export const EXTENSION_NAME = 'emoji';
|
|
9
|
-
export const Emoji = Node.create({
|
|
10
|
-
name: EXTENSION_NAME,
|
|
11
|
-
priority: 102,
|
|
12
|
-
group: 'inline',
|
|
13
|
-
inline: true,
|
|
14
|
-
atom: true,
|
|
15
|
-
selectable: true,
|
|
16
|
-
addOptions() {
|
|
17
|
-
return {
|
|
18
|
-
HTMLAttributes: {},
|
|
19
|
-
deleteTriggerWithBackspace: false,
|
|
20
|
-
renderText({ node }) {
|
|
21
|
-
return findEmojiByName(node.attrs.name) || node.attrs.name;
|
|
22
|
-
},
|
|
23
|
-
renderHTML({ options, node }) {
|
|
24
|
-
const emoji = findEmojiByName(node.attrs.name);
|
|
25
|
-
return [
|
|
26
|
-
'span',
|
|
27
|
-
mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),
|
|
28
|
-
emoji || node.attrs.name,
|
|
29
|
-
];
|
|
30
|
-
},
|
|
31
|
-
suggestion: {
|
|
32
|
-
char: ':',
|
|
33
|
-
pluginKey: new PluginKey('emoji'),
|
|
34
|
-
command: ({ editor, range, props }) => {
|
|
35
|
-
const { name } = props;
|
|
36
|
-
// increase range.to by one when the next node is of type "text"
|
|
37
|
-
// and starts with a space character
|
|
38
|
-
const { nodeAfter } = editor.view.state.selection.$to;
|
|
39
|
-
const overrideSpace = nodeAfter?.text?.startsWith(' ');
|
|
40
|
-
if (overrideSpace) {
|
|
41
|
-
range.to++;
|
|
42
|
-
}
|
|
43
|
-
const nodeBeforeMarks = editor.state.doc
|
|
44
|
-
.resolve(range.from)
|
|
45
|
-
.marks()
|
|
46
|
-
.map(i => ({
|
|
47
|
-
type: i.type.name,
|
|
48
|
-
attrs: i.attrs,
|
|
49
|
-
}));
|
|
50
|
-
editor
|
|
51
|
-
.chain()
|
|
52
|
-
.focus()
|
|
53
|
-
.insertContentAt(range, [
|
|
54
|
-
{
|
|
55
|
-
type: this.name,
|
|
56
|
-
attrs: { name },
|
|
57
|
-
marks: nodeBeforeMarks,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: 'text',
|
|
61
|
-
text: ' ',
|
|
62
|
-
marks: nodeBeforeMarks,
|
|
63
|
-
},
|
|
64
|
-
])
|
|
65
|
-
.run();
|
|
66
|
-
// get reference to `window` object from editor element, to support cross-frame JS usage
|
|
67
|
-
editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd();
|
|
68
|
-
},
|
|
69
|
-
allow: ({ state, range }) => {
|
|
70
|
-
const $from = state.doc.resolve(range.from);
|
|
71
|
-
const type = state.schema.nodes[this.name];
|
|
72
|
-
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
73
|
-
return allow;
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
addAttributes() {
|
|
79
|
-
return {
|
|
80
|
-
name: {
|
|
81
|
-
default: null,
|
|
82
|
-
parseHTML: element => element.getAttribute('data-name'),
|
|
83
|
-
renderHTML: attributes => {
|
|
84
|
-
if (!attributes.name) {
|
|
85
|
-
return {};
|
|
86
|
-
}
|
|
87
|
-
return { 'data-name': attributes.name };
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
parseHTML() {
|
|
93
|
-
return [
|
|
94
|
-
{
|
|
95
|
-
tag: `span[data-type="${this.name}"]`,
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
},
|
|
99
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
100
|
-
const mergedOptions = { ...this.options };
|
|
101
|
-
mergedOptions.HTMLAttributes = mergeAttributes({
|
|
102
|
-
'data-type': this.name,
|
|
103
|
-
}, this.options.HTMLAttributes, HTMLAttributes);
|
|
104
|
-
const html = this.options.renderHTML({
|
|
105
|
-
options: mergedOptions,
|
|
106
|
-
node,
|
|
107
|
-
});
|
|
108
|
-
if (typeof html === 'string') {
|
|
109
|
-
return [
|
|
110
|
-
'span',
|
|
111
|
-
mergeAttributes({
|
|
112
|
-
'data-type': this.name,
|
|
113
|
-
}, this.options.HTMLAttributes, HTMLAttributes),
|
|
114
|
-
html,
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
return html;
|
|
118
|
-
},
|
|
119
|
-
renderText({ node }) {
|
|
120
|
-
return this.options.renderText({
|
|
121
|
-
options: this.options,
|
|
122
|
-
node,
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
addKeyboardShortcuts() {
|
|
126
|
-
return {
|
|
127
|
-
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
128
|
-
let isEmoji = false;
|
|
129
|
-
const { selection } = state;
|
|
130
|
-
const { empty, anchor } = selection;
|
|
131
|
-
if (!empty) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
135
|
-
if (node.type.name === this.name) {
|
|
136
|
-
isEmoji = true;
|
|
137
|
-
tr.insertText(this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '', pos, pos + node.nodeSize);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
return isEmoji;
|
|
142
|
-
}),
|
|
143
|
-
};
|
|
144
|
-
},
|
|
145
|
-
addCommands() {
|
|
146
|
-
return {
|
|
147
|
-
insertEmoji: emojiName => ({ editor, state }) => {
|
|
148
|
-
const { selection } = state;
|
|
149
|
-
const nodeBeforeMarks = selection.$from.marks().map(i => ({
|
|
150
|
-
type: i.type.name,
|
|
151
|
-
attrs: i.attrs,
|
|
152
|
-
}));
|
|
153
|
-
// Chèn emoji node
|
|
154
|
-
editor
|
|
155
|
-
.chain()
|
|
156
|
-
.focus()
|
|
157
|
-
.insertContent([
|
|
158
|
-
{
|
|
159
|
-
type: this.name,
|
|
160
|
-
attrs: { name: emojiName },
|
|
161
|
-
marks: nodeBeforeMarks,
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
type: 'text',
|
|
165
|
-
text: ' ',
|
|
166
|
-
marks: nodeBeforeMarks,
|
|
167
|
-
},
|
|
168
|
-
])
|
|
169
|
-
.run();
|
|
170
|
-
// Đưa con trỏ về cuối emoji
|
|
171
|
-
editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd();
|
|
172
|
-
return true;
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
addProseMirrorPlugins() {
|
|
177
|
-
return [
|
|
178
|
-
Suggestion({
|
|
179
|
-
editor: this.editor,
|
|
180
|
-
...this.options.suggestion,
|
|
181
|
-
}),
|
|
182
|
-
];
|
|
183
|
-
},
|
|
184
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FontFamilyOptions as TiptapFontFamilyOptions } from '@tiptap/extension-font-family';
|
|
2
|
-
interface FontFamilyOptions extends TiptapFontFamilyOptions {
|
|
3
|
-
defaultFontFamily: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const FontFamily: import("@tiptap/core").Extension<FontFamilyOptions, any>;
|
|
6
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { FontFamily as TiptapFontFamilyExtension, } from '@tiptap/extension-font-family';
|
|
2
|
-
import { DEFAULT_TEXT_STYLE } from '../constants';
|
|
3
|
-
export const FontFamily = TiptapFontFamilyExtension.extend({
|
|
4
|
-
addOptions() {
|
|
5
|
-
return {
|
|
6
|
-
...this.parent?.(),
|
|
7
|
-
defaultFontFamily: DEFAULT_TEXT_STYLE.fontFamily,
|
|
8
|
-
};
|
|
9
|
-
},
|
|
10
|
-
addCommands() {
|
|
11
|
-
return {
|
|
12
|
-
...this.parent?.(),
|
|
13
|
-
unsetFontFamily: () => ({ chain }) => chain()
|
|
14
|
-
.setMark('textStyle', {
|
|
15
|
-
fontFamily: this.options.defaultFontFamily || null,
|
|
16
|
-
})
|
|
17
|
-
.removeEmptyTextStyle()
|
|
18
|
-
.run(),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
addGlobalAttributes() {
|
|
22
|
-
return [
|
|
23
|
-
...(this.parent?.() || []),
|
|
24
|
-
{
|
|
25
|
-
types: this.options.types,
|
|
26
|
-
attributes: {
|
|
27
|
-
fontFamily: {
|
|
28
|
-
default: this.options.defaultFontFamily,
|
|
29
|
-
renderHTML: attrs => {
|
|
30
|
-
if (!attrs.fontFamily || attrs.fontFamily === this.options.defaultFontFamily) {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
style: `font-family: ${attrs.fontFamily}`,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
parseHTML: element => element.style.fontFamily || this.options.defaultFontFamily,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
},
|
|
43
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import '@tiptap/extension-text-style';
|
|
2
|
-
import { Extension } from '@tiptap/core';
|
|
3
|
-
export type FontSizeOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* A list of node names where the font size can be applied.
|
|
6
|
-
* @default ['textStyle']
|
|
7
|
-
* @example ['heading', 'paragraph']
|
|
8
|
-
*/
|
|
9
|
-
types: string[];
|
|
10
|
-
defaultFontSize: string;
|
|
11
|
-
};
|
|
12
|
-
declare module '@tiptap/core' {
|
|
13
|
-
interface Commands<ReturnType> {
|
|
14
|
-
fontSize: {
|
|
15
|
-
/**
|
|
16
|
-
* Set the font size
|
|
17
|
-
* @param fontSize The font size
|
|
18
|
-
* @example editor.commands.setFontSize('16px')
|
|
19
|
-
*/
|
|
20
|
-
setFontSize: (fontSize: string) => ReturnType;
|
|
21
|
-
/**
|
|
22
|
-
* Unset the font size
|
|
23
|
-
* @example editor.commands.unsetFontSize()
|
|
24
|
-
*/
|
|
25
|
-
unsetFontSize: () => ReturnType;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* This extension allows you to set a font size for text.
|
|
31
|
-
*/
|
|
32
|
-
export declare const FontSize: Extension<FontSizeOptions, any>;
|