@uzum-tech/ui 2.3.7 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +63601 -32546
- package/dist/index.mjs +64856 -33810
- package/dist/index.prod.js +3 -3
- package/dist/index.prod.mjs +3 -3
- package/es/_internal/icons/Bold.d.ts +2 -0
- package/es/_internal/icons/Bold.mjs +29 -0
- package/es/_internal/icons/BulletList.d.ts +2 -0
- package/es/_internal/icons/BulletList.mjs +23 -0
- package/es/_internal/icons/HorizontalRule.d.ts +2 -0
- package/es/_internal/icons/HorizontalRule.mjs +14 -0
- package/es/_internal/icons/Italic.d.ts +2 -0
- package/es/_internal/icons/Italic.mjs +19 -0
- package/es/_internal/icons/NumberedList.d.ts +2 -0
- package/es/_internal/icons/NumberedList.mjs +23 -0
- package/es/_internal/icons/Quote.d.ts +2 -0
- package/es/_internal/icons/Quote.mjs +23 -0
- package/es/_internal/icons/SettingsLine.d.ts +2 -0
- package/es/_internal/icons/SettingsLine.mjs +19 -0
- package/es/_internal/icons/Strikethrough.d.ts +2 -0
- package/es/_internal/icons/Strikethrough.mjs +14 -0
- package/es/_internal/icons/index.d.ts +8 -0
- package/es/_internal/icons/index.mjs +8 -0
- package/es/_styles/markdown/markdown-content.cssr.d.ts +6 -0
- package/es/_styles/markdown/markdown-content.cssr.mjs +22 -0
- package/es/_utils/markdown/index.d.ts +3 -2
- package/es/_utils/markdown/index.mjs +2 -1
- package/es/_utils/markdown/render-markdown.d.ts +2 -1
- package/es/_utils/markdown/render-markdown.mjs +1 -1
- package/es/chat/src/Chat.d.ts +261 -24
- package/es/chat/src/Chat.mjs +2 -0
- package/es/chat/src/ChatMainArea.d.ts +81 -8
- package/es/chat/src/ChatMainArea.mjs +111 -355
- package/es/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.d.ts +9084 -0
- package/es/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.mjs +71 -0
- package/es/chat/src/ChatParts/ChatAttachmentButton/interface.d.ts +2645 -0
- package/es/chat/src/ChatParts/ChatAttachmentButton/interface.mjs +19 -0
- package/es/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.d.ts +9070 -0
- package/es/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.mjs +78 -0
- package/es/chat/src/ChatParts/ChatEditingBlock/interface.d.ts +2637 -0
- package/es/chat/src/ChatParts/ChatEditingBlock/interface.mjs +15 -0
- package/es/chat/src/ChatParts/ChatEditorInput/ChatEditorInput.d.ts +89 -0
- package/es/chat/src/ChatParts/ChatEditorInput/ChatEditorInput.mjs +63 -0
- package/es/chat/src/ChatParts/ChatEditorInput/interface.d.ts +42 -0
- package/es/chat/src/ChatParts/ChatEditorInput/interface.mjs +34 -0
- package/es/chat/src/ChatParts/ChatFooter/ChatFooter.d.ts +115 -0
- package/es/chat/src/ChatParts/ChatFooter/ChatFooter.mjs +99 -0
- package/es/chat/src/ChatParts/ChatFooter/interface.d.ts +56 -0
- package/es/chat/src/ChatParts/ChatFooter/interface.mjs +46 -0
- package/es/chat/src/ChatParts/ChatHeader/ChatHeader.d.ts +9205 -0
- package/es/chat/src/ChatParts/ChatHeader/ChatHeader.mjs +219 -0
- package/es/chat/src/ChatParts/ChatHeader/interface.d.ts +2694 -0
- package/es/chat/src/ChatParts/ChatHeader/interface.mjs +67 -0
- package/es/chat/src/ChatParts/ChatLegacyInput/ChatLegacyInput.d.ts +9142 -0
- package/es/chat/src/ChatParts/ChatLegacyInput/ChatLegacyInput.mjs +129 -0
- package/es/chat/src/ChatParts/ChatLegacyInput/interface.d.ts +2654 -0
- package/es/chat/src/ChatParts/ChatLegacyInput/interface.mjs +27 -0
- package/es/chat/src/ChatParts/ChatMessagesArea/ChatMessagesArea.d.ts +148 -0
- package/es/chat/src/ChatParts/ChatMessagesArea/ChatMessagesArea.mjs +92 -0
- package/es/chat/src/ChatParts/ChatMessagesArea/interface.d.ts +72 -0
- package/es/chat/src/ChatParts/ChatMessagesArea/interface.mjs +58 -0
- package/es/chat/src/interface.d.ts +7 -0
- package/es/chat/src/interface.mjs +4 -0
- package/es/chat/styles/light.d.ts +4 -0
- package/es/chat/styles/light.mjs +18 -0
- package/es/components.d.ts +12933 -32
- package/es/components.mjs +186 -180
- package/es/config-provider/src/internal-interface.d.ts +2 -0
- package/es/data-table/index.d.ts +1 -1
- package/es/data-table/src/ColumnSettings/ColumnSettingsDrawer.d.ts +156 -0
- package/es/data-table/src/ColumnSettings/ColumnSettingsDrawer.mjs +220 -0
- package/es/data-table/src/ColumnSettings/styles.cssr.d.ts +2 -0
- package/es/data-table/src/ColumnSettings/styles.cssr.mjs +25 -0
- package/es/data-table/src/DataTable.d.ts +60 -2
- package/es/data-table/src/DataTable.mjs +99 -23
- package/es/data-table/src/HeaderButton/FilterMenu.d.ts +14 -0
- package/es/data-table/src/interface.d.ts +53 -1
- package/es/data-table/src/interface.mjs +18 -1
- package/es/data-table/src/styles/index.cssr.mjs +17 -1
- package/es/data-table/src/use-column-settings.d.ts +2 -0
- package/es/data-table/src/use-column-settings.mjs +124 -0
- package/es/data-table/src/utils/column-utils.d.ts +2 -1
- package/es/data-table/src/utils/column-utils.mjs +6 -0
- package/es/editor/index.d.ts +10 -0
- package/es/editor/index.mjs +5 -0
- package/es/editor/src/Editor.d.ts +3896 -0
- package/es/editor/src/Editor.mjs +220 -0
- package/es/editor/src/EditorParts/BlockTypeSelect/BlockTypeSelect.d.ts +37 -0
- package/es/editor/src/EditorParts/BlockTypeSelect/BlockTypeSelect.mjs +63 -0
- package/es/editor/src/EditorParts/BlockTypeSelect/interface.d.ts +21 -0
- package/es/editor/src/EditorParts/BlockTypeSelect/interface.mjs +14 -0
- package/es/editor/src/EditorParts/EditorContent/EditorContent.d.ts +4078 -0
- package/es/editor/src/EditorParts/EditorContent/EditorContent.mjs +154 -0
- package/es/editor/src/EditorParts/EditorContent/index.d.ts +2 -0
- package/es/editor/src/EditorParts/EditorContent/index.mjs +2 -0
- package/es/editor/src/EditorParts/EditorContent/interface.d.ts +1906 -0
- package/es/editor/src/EditorParts/EditorContent/interface.mjs +17 -0
- package/es/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +4582 -0
- package/es/editor/src/EditorParts/EditorToolbar/EditorToolbar.mjs +170 -0
- package/es/editor/src/EditorParts/EditorToolbar/composables/use-editor-toolbar-customization.d.ts +11 -0
- package/es/editor/src/EditorParts/EditorToolbar/composables/use-editor-toolbar-customization.mjs +54 -0
- package/es/editor/src/EditorParts/EditorToolbar/index.d.ts +2 -0
- package/es/editor/src/EditorParts/EditorToolbar/index.mjs +2 -0
- package/es/editor/src/EditorParts/EditorToolbar/interface.d.ts +1912 -0
- package/es/editor/src/EditorParts/EditorToolbar/interface.mjs +18 -0
- package/es/editor/src/EditorParts/SendButton/SendButton.d.ts +23 -0
- package/es/editor/src/EditorParts/SendButton/SendButton.mjs +42 -0
- package/es/editor/src/EditorParts/SendButton/interface.d.ts +18 -0
- package/es/editor/src/EditorParts/SendButton/interface.mjs +8 -0
- package/es/editor/src/EditorParts/ToolbarButton/ToolbarButton.d.ts +32 -0
- package/es/editor/src/EditorParts/ToolbarButton/ToolbarButton.mjs +44 -0
- package/es/editor/src/EditorParts/ToolbarButton/interface.d.ts +20 -0
- package/es/editor/src/EditorParts/ToolbarButton/interface.mjs +13 -0
- package/es/editor/src/composables/use-editor-commands.d.ts +8 -0
- package/es/editor/src/composables/use-editor-commands.mjs +69 -0
- package/es/editor/src/composables/use-editor-css-vars.d.ts +4 -0
- package/es/editor/src/composables/use-editor-css-vars.mjs +81 -0
- package/es/editor/src/constants.d.ts +12 -0
- package/es/editor/src/constants.mjs +25 -0
- package/es/editor/src/extensions.d.ts +7 -0
- package/es/editor/src/extensions.mjs +129 -0
- package/es/editor/src/interface.d.ts +2019 -0
- package/es/editor/src/interface.mjs +52 -0
- package/es/editor/src/markdown/constants.d.ts +8 -0
- package/es/editor/src/markdown/constants.mjs +206 -0
- package/es/editor/src/markdown/editor-serializer.d.ts +9 -0
- package/es/editor/src/markdown/editor-serializer.mjs +18 -0
- package/es/editor/src/markdown/escape.d.ts +2 -0
- package/es/editor/src/markdown/escape.mjs +24 -0
- package/es/editor/src/markdown/html.d.ts +1 -0
- package/es/editor/src/markdown/html.mjs +4 -0
- package/es/editor/src/markdown/parser.d.ts +4 -0
- package/es/editor/src/markdown/parser.mjs +36 -0
- package/es/editor/src/markdown/serializer-state.d.ts +10 -0
- package/es/editor/src/markdown/serializer-state.mjs +12 -0
- package/es/editor/src/markdown/serializer.d.ts +3 -0
- package/es/editor/src/markdown/serializer.mjs +8 -0
- package/es/editor/src/styles/index.cssr.d.ts +2 -0
- package/es/editor/src/styles/index.cssr.mjs +119 -0
- package/es/editor/styles/dark.d.ts +630 -0
- package/es/editor/styles/dark.mjs +21 -0
- package/es/editor/styles/index.d.ts +3 -0
- package/es/editor/styles/index.mjs +2 -0
- package/es/editor/styles/light.d.ts +677 -0
- package/es/editor/styles/light.mjs +87 -0
- package/es/editor/tests/fixtures/round-trip.d.ts +12 -0
- package/es/editor/tests/fixtures/round-trip.mjs +98 -0
- package/es/editor/tests/utils.d.ts +7 -0
- package/es/editor/tests/utils.mjs +27 -0
- package/es/locales/common/enUS.d.ts +21 -0
- package/es/locales/common/enUS.mjs +22 -1
- package/es/locales/common/ruRU.mjs +22 -1
- package/es/locales/common/uzUZ.mjs +22 -1
- package/es/locales/common/zhCN.mjs +22 -1
- package/es/message-bubble/src/styles/index.cssr.mjs +4 -17
- package/es/styles.d.ts +1 -0
- package/es/styles.mjs +1 -0
- package/es/themes/dark.mjs +2 -0
- package/es/themes/light.mjs +2 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/_internal/icons/Bold.d.ts +2 -0
- package/lib/_internal/icons/Bold.js +13 -0
- package/lib/_internal/icons/BulletList.d.ts +2 -0
- package/lib/_internal/icons/BulletList.js +13 -0
- package/lib/_internal/icons/HorizontalRule.d.ts +2 -0
- package/lib/_internal/icons/HorizontalRule.js +10 -0
- package/lib/_internal/icons/Italic.d.ts +2 -0
- package/lib/_internal/icons/Italic.js +11 -0
- package/lib/_internal/icons/NumberedList.d.ts +2 -0
- package/lib/_internal/icons/NumberedList.js +13 -0
- package/lib/_internal/icons/Quote.d.ts +2 -0
- package/lib/_internal/icons/Quote.js +13 -0
- package/lib/_internal/icons/SettingsLine.d.ts +2 -0
- package/lib/_internal/icons/SettingsLine.js +11 -0
- package/lib/_internal/icons/Strikethrough.d.ts +2 -0
- package/lib/_internal/icons/Strikethrough.js +10 -0
- package/lib/_internal/icons/index.d.ts +8 -0
- package/lib/_internal/icons/index.js +18 -2
- package/lib/_styles/markdown/markdown-content.cssr.d.ts +6 -0
- package/lib/_styles/markdown/markdown-content.cssr.js +28 -0
- package/lib/_utils/markdown/index.d.ts +3 -2
- package/lib/_utils/markdown/index.js +4 -1
- package/lib/_utils/markdown/render-markdown.d.ts +2 -1
- package/lib/_utils/markdown/render-markdown.js +1 -0
- package/lib/chat/src/Chat.d.ts +261 -24
- package/lib/chat/src/Chat.js +2 -0
- package/lib/chat/src/ChatMainArea.d.ts +81 -8
- package/lib/chat/src/ChatMainArea.js +93 -223
- package/lib/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.d.ts +9084 -0
- package/lib/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.js +52 -0
- package/lib/chat/src/ChatParts/ChatAttachmentButton/interface.d.ts +2645 -0
- package/lib/chat/src/ChatParts/ChatAttachmentButton/interface.js +17 -0
- package/lib/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.d.ts +9070 -0
- package/lib/chat/src/ChatParts/ChatEditingBlock/ChatEditingBlock.js +55 -0
- package/lib/chat/src/ChatParts/ChatEditingBlock/interface.d.ts +2637 -0
- package/lib/chat/src/ChatParts/ChatEditingBlock/interface.js +14 -0
- package/lib/chat/src/ChatParts/ChatEditorInput/ChatEditorInput.d.ts +89 -0
- package/lib/chat/src/ChatParts/ChatEditorInput/ChatEditorInput.js +45 -0
- package/lib/chat/src/ChatParts/ChatEditorInput/interface.d.ts +42 -0
- package/lib/chat/src/ChatParts/ChatEditorInput/interface.js +37 -0
- package/lib/chat/src/ChatParts/ChatFooter/ChatFooter.d.ts +115 -0
- package/lib/chat/src/ChatParts/ChatFooter/ChatFooter.js +66 -0
- package/lib/chat/src/ChatParts/ChatFooter/interface.d.ts +56 -0
- package/lib/chat/src/ChatParts/ChatFooter/interface.js +49 -0
- package/lib/chat/src/ChatParts/ChatHeader/ChatHeader.d.ts +9205 -0
- package/lib/chat/src/ChatParts/ChatHeader/ChatHeader.js +164 -0
- package/lib/chat/src/ChatParts/ChatHeader/interface.d.ts +2694 -0
- package/lib/chat/src/ChatParts/ChatHeader/interface.js +53 -0
- package/lib/chat/src/ChatParts/ChatLegacyInput/ChatLegacyInput.d.ts +9142 -0
- package/lib/chat/src/ChatParts/ChatLegacyInput/ChatLegacyInput.js +98 -0
- package/lib/chat/src/ChatParts/ChatLegacyInput/interface.d.ts +2654 -0
- package/lib/chat/src/ChatParts/ChatLegacyInput/interface.js +23 -0
- package/lib/chat/src/ChatParts/ChatMessagesArea/ChatMessagesArea.d.ts +148 -0
- package/lib/chat/src/ChatParts/ChatMessagesArea/ChatMessagesArea.js +49 -0
- package/lib/chat/src/ChatParts/ChatMessagesArea/interface.d.ts +72 -0
- package/lib/chat/src/ChatParts/ChatMessagesArea/interface.js +61 -0
- package/lib/chat/src/interface.d.ts +7 -0
- package/lib/chat/src/interface.js +3 -0
- package/lib/chat/styles/light.d.ts +4 -0
- package/lib/chat/styles/light.js +19 -0
- package/lib/components.d.ts +12933 -32
- package/lib/components.js +18 -7
- package/lib/config-provider/src/internal-interface.d.ts +2 -0
- package/lib/data-table/index.d.ts +1 -1
- package/lib/data-table/src/ColumnSettings/ColumnSettingsDrawer.d.ts +156 -0
- package/lib/data-table/src/ColumnSettings/ColumnSettingsDrawer.js +181 -0
- package/lib/data-table/src/ColumnSettings/styles.cssr.d.ts +2 -0
- package/lib/data-table/src/ColumnSettings/styles.cssr.js +30 -0
- package/lib/data-table/src/DataTable.d.ts +60 -2
- package/lib/data-table/src/DataTable.js +65 -23
- package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +14 -0
- package/lib/data-table/src/interface.d.ts +53 -1
- package/lib/data-table/src/interface.js +17 -2
- package/lib/data-table/src/styles/index.cssr.js +17 -1
- package/lib/data-table/src/use-column-settings.d.ts +2 -0
- package/lib/data-table/src/use-column-settings.js +144 -0
- package/lib/data-table/src/utils/column-utils.d.ts +2 -1
- package/lib/data-table/src/utils/column-utils.js +5 -0
- package/lib/editor/index.d.ts +10 -0
- package/lib/editor/index.js +19 -0
- package/lib/editor/src/Editor.d.ts +3896 -0
- package/lib/editor/src/Editor.js +216 -0
- package/lib/editor/src/EditorParts/BlockTypeSelect/BlockTypeSelect.d.ts +37 -0
- package/lib/editor/src/EditorParts/BlockTypeSelect/BlockTypeSelect.js +47 -0
- package/lib/editor/src/EditorParts/BlockTypeSelect/interface.d.ts +21 -0
- package/lib/editor/src/EditorParts/BlockTypeSelect/interface.js +17 -0
- package/lib/editor/src/EditorParts/EditorContent/EditorContent.d.ts +4078 -0
- package/lib/editor/src/EditorParts/EditorContent/EditorContent.js +121 -0
- package/lib/editor/src/EditorParts/EditorContent/index.d.ts +2 -0
- package/lib/editor/src/EditorParts/EditorContent/index.js +10 -0
- package/lib/editor/src/EditorParts/EditorContent/interface.d.ts +1906 -0
- package/lib/editor/src/EditorParts/EditorContent/interface.js +8 -0
- package/lib/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +4582 -0
- package/lib/editor/src/EditorParts/EditorToolbar/EditorToolbar.js +126 -0
- package/lib/editor/src/EditorParts/EditorToolbar/composables/use-editor-toolbar-customization.d.ts +11 -0
- package/lib/editor/src/EditorParts/EditorToolbar/composables/use-editor-toolbar-customization.js +52 -0
- package/lib/editor/src/EditorParts/EditorToolbar/index.d.ts +2 -0
- package/lib/editor/src/EditorParts/EditorToolbar/index.js +10 -0
- package/lib/editor/src/EditorParts/EditorToolbar/interface.d.ts +1912 -0
- package/lib/editor/src/EditorParts/EditorToolbar/interface.js +11 -0
- package/lib/editor/src/EditorParts/SendButton/SendButton.d.ts +23 -0
- package/lib/editor/src/EditorParts/SendButton/SendButton.js +31 -0
- package/lib/editor/src/EditorParts/SendButton/interface.d.ts +18 -0
- package/lib/editor/src/EditorParts/SendButton/interface.js +11 -0
- package/lib/editor/src/EditorParts/ToolbarButton/ToolbarButton.d.ts +32 -0
- package/lib/editor/src/EditorParts/ToolbarButton/ToolbarButton.js +34 -0
- package/lib/editor/src/EditorParts/ToolbarButton/interface.d.ts +20 -0
- package/lib/editor/src/EditorParts/ToolbarButton/interface.js +16 -0
- package/lib/editor/src/composables/use-editor-commands.d.ts +8 -0
- package/lib/editor/src/composables/use-editor-commands.js +70 -0
- package/lib/editor/src/composables/use-editor-css-vars.d.ts +4 -0
- package/lib/editor/src/composables/use-editor-css-vars.js +46 -0
- package/lib/editor/src/constants.d.ts +12 -0
- package/lib/editor/src/constants.js +56 -0
- package/lib/editor/src/extensions.d.ts +7 -0
- package/lib/editor/src/extensions.js +136 -0
- package/lib/editor/src/interface.d.ts +2019 -0
- package/lib/editor/src/interface.js +22 -0
- package/lib/editor/src/markdown/constants.d.ts +8 -0
- package/lib/editor/src/markdown/constants.js +201 -0
- package/lib/editor/src/markdown/editor-serializer.d.ts +9 -0
- package/lib/editor/src/markdown/editor-serializer.js +20 -0
- package/lib/editor/src/markdown/escape.d.ts +2 -0
- package/lib/editor/src/markdown/escape.js +31 -0
- package/lib/editor/src/markdown/html.d.ts +1 -0
- package/lib/editor/src/markdown/html.js +9 -0
- package/lib/editor/src/markdown/parser.d.ts +4 -0
- package/lib/editor/src/markdown/parser.js +42 -0
- package/lib/editor/src/markdown/serializer-state.d.ts +10 -0
- package/lib/editor/src/markdown/serializer-state.js +16 -0
- package/lib/editor/src/markdown/serializer.d.ts +3 -0
- package/lib/editor/src/markdown/serializer.js +9 -0
- package/lib/editor/src/styles/index.cssr.d.ts +2 -0
- package/lib/editor/src/styles/index.cssr.js +124 -0
- package/lib/editor/styles/dark.d.ts +630 -0
- package/lib/editor/styles/dark.js +23 -0
- package/lib/editor/styles/index.d.ts +3 -0
- package/lib/editor/styles/index.js +10 -0
- package/lib/editor/styles/light.d.ts +677 -0
- package/lib/editor/styles/light.js +71 -0
- package/lib/editor/tests/fixtures/round-trip.d.ts +12 -0
- package/lib/editor/tests/fixtures/round-trip.js +125 -0
- package/lib/editor/tests/utils.d.ts +7 -0
- package/lib/editor/tests/utils.js +26 -0
- package/lib/locales/common/enUS.d.ts +21 -0
- package/lib/locales/common/enUS.js +22 -1
- package/lib/locales/common/ruRU.js +22 -1
- package/lib/locales/common/uzUZ.js +22 -1
- package/lib/locales/common/zhCN.js +22 -1
- package/lib/message-bubble/src/styles/index.cssr.js +4 -17
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +127 -125
- package/lib/themes/dark.js +136 -134
- package/lib/themes/light.js +136 -134
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -1
- package/volar.d.ts +3 -0
- package/web-types.json +437 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useTheme } from "../../../../_mixins/index.mjs";
|
|
2
|
+
export const editorToolbarProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
3
|
+
editor: Object,
|
|
4
|
+
themeVars: Object,
|
|
5
|
+
toolbar: {
|
|
6
|
+
type: [Array, Boolean],
|
|
7
|
+
default: true
|
|
8
|
+
},
|
|
9
|
+
markdownOptions: Object,
|
|
10
|
+
disabled: Boolean,
|
|
11
|
+
buttonProps: Object,
|
|
12
|
+
iconProps: Object,
|
|
13
|
+
dropdownProps: Object,
|
|
14
|
+
tooltips: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: () => ({})
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SlotsType } from 'vue';
|
|
2
|
+
import type { SendButtonSlots } from './interface';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
readonly tooltip: StringConstructor;
|
|
5
|
+
readonly buttonThemeOverrides: import("vue").PropType<import("../../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../../button/styles").ButtonTheme>>;
|
|
6
|
+
readonly buttonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
|
|
7
|
+
readonly iconProps: import("vue").PropType<Partial<import("../../../..").IconProps>>;
|
|
8
|
+
readonly disabled: BooleanConstructor;
|
|
9
|
+
readonly onActivate: import("vue").PropType<VoidFunction>;
|
|
10
|
+
}>, {
|
|
11
|
+
mergedClsPrefix: import("vue").Ref<string, string>;
|
|
12
|
+
handleClick: () => void;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
readonly tooltip: StringConstructor;
|
|
15
|
+
readonly buttonThemeOverrides: import("vue").PropType<import("../../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../../button/styles").ButtonTheme>>;
|
|
16
|
+
readonly buttonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
|
|
17
|
+
readonly iconProps: import("vue").PropType<Partial<import("../../../..").IconProps>>;
|
|
18
|
+
readonly disabled: BooleanConstructor;
|
|
19
|
+
readonly onActivate: import("vue").PropType<VoidFunction>;
|
|
20
|
+
}>> & Readonly<{}>, {
|
|
21
|
+
readonly disabled: boolean;
|
|
22
|
+
}, SlotsType<SendButtonSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { SendFilled } from "../../../../_internal/icons/index.mjs";
|
|
3
|
+
import { useConfig } from "../../../../_mixins/index.mjs";
|
|
4
|
+
import { UxButton } from "../../../../button/index.mjs";
|
|
5
|
+
import { UIcon } from "../../../../icon/index.mjs";
|
|
6
|
+
import { sendButtonProps } from "./interface.mjs";
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: 'EditorSendButton',
|
|
9
|
+
props: sendButtonProps,
|
|
10
|
+
slots: Object,
|
|
11
|
+
setup(props) {
|
|
12
|
+
const {
|
|
13
|
+
mergedClsPrefixRef
|
|
14
|
+
} = useConfig();
|
|
15
|
+
function handleClick() {
|
|
16
|
+
var _a;
|
|
17
|
+
(_a = props.onActivate) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
21
|
+
handleClick
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
render() {
|
|
25
|
+
return h(UxButton, Object.assign({
|
|
26
|
+
class: `${this.mergedClsPrefix}-editor__send-button`,
|
|
27
|
+
size: "tiny",
|
|
28
|
+
bordered: false,
|
|
29
|
+
builtinThemeOverrides: this.buttonThemeOverrides,
|
|
30
|
+
disabled: this.disabled,
|
|
31
|
+
"aria-label": this.tooltip,
|
|
32
|
+
onClick: this.handleClick
|
|
33
|
+
}, this.buttonProps), {
|
|
34
|
+
icon: () => h(UIcon, Object.assign({}, this.iconProps), {
|
|
35
|
+
default: () => {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
return (_c = (_b = (_a = this.$slots).icon) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : h(SendFilled, null);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PropType, VNodeChild } from 'vue';
|
|
2
|
+
import type { ExtractThemeOverrides } from '../../../../_mixins/use-theme';
|
|
3
|
+
import type { ExtractPublicPropTypes } from '../../../../_utils';
|
|
4
|
+
import type { ButtonProps } from '../../../../button';
|
|
5
|
+
import type { ButtonTheme } from '../../../../button/styles';
|
|
6
|
+
import type { IconProps } from '../../../../icon';
|
|
7
|
+
export interface SendButtonSlots {
|
|
8
|
+
icon?: () => VNodeChild;
|
|
9
|
+
}
|
|
10
|
+
export type SendButtonProps = ExtractPublicPropTypes<typeof sendButtonProps>;
|
|
11
|
+
export declare const sendButtonProps: {
|
|
12
|
+
readonly tooltip: StringConstructor;
|
|
13
|
+
readonly buttonThemeOverrides: PropType<ExtractThemeOverrides<ButtonTheme>>;
|
|
14
|
+
readonly buttonProps: PropType<Partial<ButtonProps>>;
|
|
15
|
+
readonly iconProps: PropType<Partial<IconProps>>;
|
|
16
|
+
readonly disabled: BooleanConstructor;
|
|
17
|
+
readonly onActivate: PropType<VoidFunction>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
readonly icon: {
|
|
3
|
+
readonly type: import("vue").PropType<import("vue").Component>;
|
|
4
|
+
readonly required: true;
|
|
5
|
+
};
|
|
6
|
+
readonly tooltip: StringConstructor;
|
|
7
|
+
readonly buttonThemeOverrides: import("vue").PropType<import("../../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../../button/styles").ButtonTheme>>;
|
|
8
|
+
readonly buttonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
|
|
9
|
+
readonly iconProps: import("vue").PropType<Partial<import("../../../..").IconProps>>;
|
|
10
|
+
readonly active: BooleanConstructor;
|
|
11
|
+
readonly disabled: BooleanConstructor;
|
|
12
|
+
readonly onActivate: import("vue").PropType<VoidFunction>;
|
|
13
|
+
}>, {
|
|
14
|
+
mergedClsPrefix: import("vue").Ref<string, string>;
|
|
15
|
+
handleClick: () => void;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
|
+
readonly icon: {
|
|
18
|
+
readonly type: import("vue").PropType<import("vue").Component>;
|
|
19
|
+
readonly required: true;
|
|
20
|
+
};
|
|
21
|
+
readonly tooltip: StringConstructor;
|
|
22
|
+
readonly buttonThemeOverrides: import("vue").PropType<import("../../../../_mixins/use-theme").ExtractThemeOverrides<import("../../../../button/styles").ButtonTheme>>;
|
|
23
|
+
readonly buttonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
|
|
24
|
+
readonly iconProps: import("vue").PropType<Partial<import("../../../..").IconProps>>;
|
|
25
|
+
readonly active: BooleanConstructor;
|
|
26
|
+
readonly disabled: BooleanConstructor;
|
|
27
|
+
readonly onActivate: import("vue").PropType<VoidFunction>;
|
|
28
|
+
}>> & Readonly<{}>, {
|
|
29
|
+
readonly disabled: boolean;
|
|
30
|
+
readonly active: boolean;
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { useConfig } from "../../../../_mixins/index.mjs";
|
|
3
|
+
import { UxButton } from "../../../../button/index.mjs";
|
|
4
|
+
import { UIcon } from "../../../../icon/index.mjs";
|
|
5
|
+
import { UTooltip } from "../../../../tooltip/index.mjs";
|
|
6
|
+
import { toolbarButtonProps } from "./interface.mjs";
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
name: 'EditorToolbarButton',
|
|
9
|
+
props: toolbarButtonProps,
|
|
10
|
+
setup(props) {
|
|
11
|
+
const {
|
|
12
|
+
mergedClsPrefixRef
|
|
13
|
+
} = useConfig();
|
|
14
|
+
function handleClick() {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = props.onActivate) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
20
|
+
handleClick
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
render() {
|
|
24
|
+
const button = h(UxButton, Object.assign({
|
|
25
|
+
class: `${this.mergedClsPrefix}-editor__toolbar-button`,
|
|
26
|
+
size: "tiny",
|
|
27
|
+
bordered: false,
|
|
28
|
+
builtinThemeOverrides: this.buttonThemeOverrides,
|
|
29
|
+
disabled: this.disabled,
|
|
30
|
+
"aria-pressed": this.active,
|
|
31
|
+
"aria-label": this.tooltip,
|
|
32
|
+
onClick: this.handleClick
|
|
33
|
+
}, this.buttonProps), {
|
|
34
|
+
icon: () => h(UIcon, Object.assign({}, this.iconProps), {
|
|
35
|
+
default: () => h(this.icon)
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
if (!this.tooltip) return button;
|
|
39
|
+
return h(UTooltip, null, {
|
|
40
|
+
trigger: () => button,
|
|
41
|
+
default: () => this.tooltip
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component, PropType } from 'vue';
|
|
2
|
+
import type { ExtractThemeOverrides } from '../../../../_mixins/use-theme';
|
|
3
|
+
import type { ExtractPublicPropTypes } from '../../../../_utils';
|
|
4
|
+
import type { ButtonProps } from '../../../../button';
|
|
5
|
+
import type { ButtonTheme } from '../../../../button/styles';
|
|
6
|
+
import type { IconProps } from '../../../../icon';
|
|
7
|
+
export type ToolbarButtonProps = ExtractPublicPropTypes<typeof toolbarButtonProps>;
|
|
8
|
+
export declare const toolbarButtonProps: {
|
|
9
|
+
readonly icon: {
|
|
10
|
+
readonly type: PropType<Component>;
|
|
11
|
+
readonly required: true;
|
|
12
|
+
};
|
|
13
|
+
readonly tooltip: StringConstructor;
|
|
14
|
+
readonly buttonThemeOverrides: PropType<ExtractThemeOverrides<ButtonTheme>>;
|
|
15
|
+
readonly buttonProps: PropType<Partial<ButtonProps>>;
|
|
16
|
+
readonly iconProps: PropType<Partial<IconProps>>;
|
|
17
|
+
readonly active: BooleanConstructor;
|
|
18
|
+
readonly disabled: BooleanConstructor;
|
|
19
|
+
readonly onActivate: PropType<VoidFunction>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/vue-3';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { EditorBlockTypeKey, EditorToolbarItemKey } from '../interface';
|
|
4
|
+
export default function useEditorCommands(editorRef: Ref<Editor | undefined>, keysRef: Ref<EditorToolbarItemKey[]>): {
|
|
5
|
+
commandsRef: import("vue").ComputedRef<Partial<Record<EditorToolbarItemKey, import("../interface").EditorCommand>>>;
|
|
6
|
+
activeBlockTypeRef: import("vue").ComputedRef<EditorBlockTypeKey>;
|
|
7
|
+
setBlockType: (key: EditorBlockTypeKey) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
|
2
|
+
import { EDITOR_BLOCK_TYPE_LEVELS, EDITOR_BLOCK_TYPES } from "../constants.mjs";
|
|
3
|
+
import { EDITOR_COMMAND_SPECS } from "../markdown/constants.mjs";
|
|
4
|
+
export default function useEditorCommands(editorRef, keysRef) {
|
|
5
|
+
const editorStateRef = shallowRef();
|
|
6
|
+
let subscribed;
|
|
7
|
+
function handleTransaction() {
|
|
8
|
+
var _a;
|
|
9
|
+
editorStateRef.value = (_a = editorRef.value) === null || _a === void 0 ? void 0 : _a.state;
|
|
10
|
+
}
|
|
11
|
+
function unsubscribe() {
|
|
12
|
+
subscribed === null || subscribed === void 0 ? void 0 : subscribed.off('transaction', handleTransaction);
|
|
13
|
+
subscribed = undefined;
|
|
14
|
+
}
|
|
15
|
+
watch(editorRef, editor => {
|
|
16
|
+
unsubscribe();
|
|
17
|
+
editorStateRef.value = editor === null || editor === void 0 ? void 0 : editor.state;
|
|
18
|
+
if (!editor) return;
|
|
19
|
+
subscribed = editor;
|
|
20
|
+
editor.on('transaction', handleTransaction);
|
|
21
|
+
}, {
|
|
22
|
+
immediate: true
|
|
23
|
+
});
|
|
24
|
+
onBeforeUnmount(unsubscribe);
|
|
25
|
+
const commandsRef = computed(() => {
|
|
26
|
+
const editor = editorRef.value;
|
|
27
|
+
const ready = Boolean(editor && editorStateRef.value);
|
|
28
|
+
const commands = {};
|
|
29
|
+
for (const key of keysRef.value) {
|
|
30
|
+
const spec = EDITOR_COMMAND_SPECS[key];
|
|
31
|
+
commands[key] = {
|
|
32
|
+
run: () => {
|
|
33
|
+
if (editor) spec.run(editor);
|
|
34
|
+
},
|
|
35
|
+
active: ready && editor ? spec.active(editor) : false,
|
|
36
|
+
disabled: !ready || !editor || !spec.enabled(editor)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return commands;
|
|
40
|
+
});
|
|
41
|
+
const activeBlockTypeRef = computed(() => {
|
|
42
|
+
const editor = editorRef.value;
|
|
43
|
+
if (!editor || !editorStateRef.value) return 'paragraph';
|
|
44
|
+
const active = EDITOR_BLOCK_TYPES.find(key => {
|
|
45
|
+
const level = EDITOR_BLOCK_TYPE_LEVELS[key];
|
|
46
|
+
return level !== null && editor.isActive('heading', {
|
|
47
|
+
level
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return active !== null && active !== void 0 ? active : 'paragraph';
|
|
51
|
+
});
|
|
52
|
+
function setBlockType(key) {
|
|
53
|
+
const editor = editorRef.value;
|
|
54
|
+
if (!editor) return;
|
|
55
|
+
const level = EDITOR_BLOCK_TYPE_LEVELS[key];
|
|
56
|
+
if (level === null) {
|
|
57
|
+
editor.chain().focus().setParagraph().run();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
editor.chain().focus().setHeading({
|
|
61
|
+
level
|
|
62
|
+
}).run();
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
commandsRef,
|
|
66
|
+
activeBlockTypeRef,
|
|
67
|
+
setBlockType
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import type { MergedTheme } from '../../../_mixins/use-theme';
|
|
3
|
+
import type { EditorTheme, EditorThemeVars } from '../../styles';
|
|
4
|
+
export default function useEditorCssVars(themeRef: Ref<MergedTheme<EditorTheme>>, themeVarsRef: Ref<EditorThemeVars>): ComputedRef<Record<string, string>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
export default function useEditorCssVars(themeRef, themeVarsRef) {
|
|
3
|
+
return computed(() => {
|
|
4
|
+
const {
|
|
5
|
+
common: {
|
|
6
|
+
cubicBezierEaseInOut
|
|
7
|
+
}
|
|
8
|
+
} = themeRef.value;
|
|
9
|
+
const {
|
|
10
|
+
backgroundColor,
|
|
11
|
+
borderColor,
|
|
12
|
+
borderRadius,
|
|
13
|
+
toolbarBackgroundColor,
|
|
14
|
+
toolbarDividerColor,
|
|
15
|
+
toolbarButtonColorActive,
|
|
16
|
+
toolbarButtonColorHover,
|
|
17
|
+
toolbarIconColorDisabled,
|
|
18
|
+
toolbarIconColorActive,
|
|
19
|
+
toolbarIconColorHover,
|
|
20
|
+
toolbarIconColor,
|
|
21
|
+
contentBackgroundColor,
|
|
22
|
+
contentTextColor,
|
|
23
|
+
placeholderColor,
|
|
24
|
+
sendButtonColor,
|
|
25
|
+
blockTypeMenuWidth,
|
|
26
|
+
blockTypeMenuColor,
|
|
27
|
+
blockTypeMenuBorderColor,
|
|
28
|
+
blockTypeMenuBorderRadius,
|
|
29
|
+
blockTypeMenuBoxShadow,
|
|
30
|
+
markdownQuoteBorderColor,
|
|
31
|
+
markdownQuoteTextColor,
|
|
32
|
+
markdownQuoteBackgroundColor,
|
|
33
|
+
markdownQuoteMarkerColor,
|
|
34
|
+
markdownDividerColor,
|
|
35
|
+
markdownH1FontSize,
|
|
36
|
+
markdownH2FontSize,
|
|
37
|
+
markdownH3FontSize,
|
|
38
|
+
markdownTextFontSize,
|
|
39
|
+
markdownH1LineHeight,
|
|
40
|
+
markdownH2LineHeight,
|
|
41
|
+
markdownH3LineHeight,
|
|
42
|
+
markdownTextLineHeight
|
|
43
|
+
} = themeVarsRef.value;
|
|
44
|
+
return {
|
|
45
|
+
'--u-bezier': cubicBezierEaseInOut,
|
|
46
|
+
'--u-editor-background-color': backgroundColor,
|
|
47
|
+
'--u-editor-border-color': borderColor,
|
|
48
|
+
'--u-editor-border-radius': borderRadius,
|
|
49
|
+
'--u-editor-toolbar-background-color': toolbarBackgroundColor,
|
|
50
|
+
'--u-editor-toolbar-divider-color': toolbarDividerColor,
|
|
51
|
+
'--u-editor-toolbar-button-color-active': toolbarButtonColorActive,
|
|
52
|
+
'--u-editor-toolbar-button-color-hover': toolbarButtonColorHover,
|
|
53
|
+
'--u-editor-toolbar-icon-color-disabled': toolbarIconColorDisabled,
|
|
54
|
+
'--u-editor-toolbar-icon-color-active': toolbarIconColorActive,
|
|
55
|
+
'--u-editor-toolbar-icon-color-hover': toolbarIconColorHover,
|
|
56
|
+
'--u-editor-toolbar-icon-color': toolbarIconColor,
|
|
57
|
+
'--u-editor-content-background-color': contentBackgroundColor,
|
|
58
|
+
'--u-editor-content-text-color': contentTextColor,
|
|
59
|
+
'--u-editor-placeholder-color': placeholderColor,
|
|
60
|
+
'--u-editor-send-button-color': sendButtonColor,
|
|
61
|
+
'--u-editor-block-type-menu-width': blockTypeMenuWidth,
|
|
62
|
+
'--u-editor-block-type-menu-color': blockTypeMenuColor,
|
|
63
|
+
'--u-editor-block-type-menu-border-color': blockTypeMenuBorderColor,
|
|
64
|
+
'--u-editor-block-type-menu-border-radius': blockTypeMenuBorderRadius,
|
|
65
|
+
'--u-editor-block-type-menu-box-shadow': blockTypeMenuBoxShadow,
|
|
66
|
+
'--u-editor-markdown-quote-border-color': markdownQuoteBorderColor,
|
|
67
|
+
'--u-editor-markdown-quote-text-color': markdownQuoteTextColor,
|
|
68
|
+
'--u-editor-markdown-quote-background-color': markdownQuoteBackgroundColor,
|
|
69
|
+
'--u-editor-markdown-quote-marker-color': markdownQuoteMarkerColor,
|
|
70
|
+
'--u-editor-markdown-divider-color': markdownDividerColor,
|
|
71
|
+
'--u-editor-markdown-h1-font-size': markdownH1FontSize,
|
|
72
|
+
'--u-editor-markdown-h2-font-size': markdownH2FontSize,
|
|
73
|
+
'--u-editor-markdown-h3-font-size': markdownH3FontSize,
|
|
74
|
+
'--u-editor-markdown-text-font-size': markdownTextFontSize,
|
|
75
|
+
'--u-editor-markdown-h1-line-height': markdownH1LineHeight,
|
|
76
|
+
'--u-editor-markdown-h2-line-height': markdownH2LineHeight,
|
|
77
|
+
'--u-editor-markdown-h3-line-height': markdownH3LineHeight,
|
|
78
|
+
'--u-editor-markdown-text-line-height': markdownTextLineHeight
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorBlockTypeKey, EditorHeadingLevels, EditorToolbarItemKey } from './interface';
|
|
2
|
+
export declare const EDITOR_HEADING_LEVELS: EditorHeadingLevels[];
|
|
3
|
+
export declare const EDITOR_DEFAULT_TOOLBAR: EditorToolbarItemKey[][];
|
|
4
|
+
export declare const EDITOR_BLOCK_TYPES: EditorBlockTypeKey[];
|
|
5
|
+
export declare const PLAIN_PASTE_NODE_TYPES: Set<string>;
|
|
6
|
+
export declare const MARKDOWN_SOURCE_TYPES: string[];
|
|
7
|
+
export declare const EDITOR_BLOCK_TYPE_LEVELS: Record<EditorBlockTypeKey, EditorHeadingLevels | null>;
|
|
8
|
+
export declare const EDITOR_TOOLBAR_ITEM_FEATURES: Record<EditorToolbarItemKey, string>;
|
|
9
|
+
export declare const EDITOR_MARKDOWN_REGEX: {
|
|
10
|
+
SINGLE_PARAGRAPH_ITEM: RegExp;
|
|
11
|
+
PARAGRAPH_BEFORE_NESTED_LIST: RegExp;
|
|
12
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const EDITOR_HEADING_LEVELS = [1, 2, 3, 4, 5, 6];
|
|
2
|
+
export const EDITOR_DEFAULT_TOOLBAR = [['blockType'], ['bold', 'strikethrough', 'italic'], ['blockquote', 'divider'], ['bulletList', 'orderedList']];
|
|
3
|
+
export const EDITOR_BLOCK_TYPES = ['heading1', 'heading2', 'heading3', 'paragraph'];
|
|
4
|
+
export const PLAIN_PASTE_NODE_TYPES = new Set(['doc', 'paragraph', 'text', 'hardBreak']);
|
|
5
|
+
export const MARKDOWN_SOURCE_TYPES = ['paragraph', 'heading', 'blockquote', 'bulletList', 'orderedList', 'listItem', 'horizontalRule', 'hardBreak', 'bold', 'italic', 'strike', 'link'];
|
|
6
|
+
export const EDITOR_BLOCK_TYPE_LEVELS = {
|
|
7
|
+
paragraph: null,
|
|
8
|
+
heading1: 1,
|
|
9
|
+
heading2: 2,
|
|
10
|
+
heading3: 3
|
|
11
|
+
};
|
|
12
|
+
export const EDITOR_TOOLBAR_ITEM_FEATURES = {
|
|
13
|
+
blockType: 'heading',
|
|
14
|
+
bold: 'bold',
|
|
15
|
+
strikethrough: 'strikethrough',
|
|
16
|
+
italic: 'italic',
|
|
17
|
+
blockquote: 'blockquote',
|
|
18
|
+
divider: 'divider',
|
|
19
|
+
bulletList: 'bulletList',
|
|
20
|
+
orderedList: 'orderedList'
|
|
21
|
+
};
|
|
22
|
+
export const EDITOR_MARKDOWN_REGEX = {
|
|
23
|
+
SINGLE_PARAGRAPH_ITEM: /<li><p>((?:(?!<\/?p[\s>])[\s\S])*)<\/p><\/li>/g,
|
|
24
|
+
PARAGRAPH_BEFORE_NESTED_LIST: /<li><p>((?:(?!<\/?p[\s>])[\s\S])*)<\/p>(?=<[ou]l)/g
|
|
25
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Extensions } from '@tiptap/core';
|
|
2
|
+
import type { CreateEditorExtensionsOptions, MarkdownPasteOptions, SendShortcutOptions } from './interface';
|
|
3
|
+
import { Extension } from '@tiptap/core';
|
|
4
|
+
export declare const MarkdownSource: Extension<any, any>;
|
|
5
|
+
export declare const SendShortcut: Extension<SendShortcutOptions, any>;
|
|
6
|
+
export declare const MarkdownPaste: Extension<MarkdownPasteOptions, any>;
|
|
7
|
+
export declare function createEditorExtensions({ placeholder, markdownOptions, extensions, maxLength, onSendShortcut }?: CreateEditorExtensionsOptions): Extensions;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { CharacterCount, Placeholder } from '@tiptap/extensions';
|
|
3
|
+
import { Slice } from '@tiptap/pm/model';
|
|
4
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
5
|
+
import { StarterKit } from '@tiptap/starter-kit';
|
|
6
|
+
import { normalizeOptions } from "../../_utils/markdown/index.mjs";
|
|
7
|
+
import { EDITOR_HEADING_LEVELS, MARKDOWN_SOURCE_TYPES, PLAIN_PASTE_NODE_TYPES } from "./constants.mjs";
|
|
8
|
+
import { createMarkdownParser } from "./markdown/parser.mjs";
|
|
9
|
+
export const MarkdownSource = Extension.create({
|
|
10
|
+
name: 'markdownSource',
|
|
11
|
+
addGlobalAttributes() {
|
|
12
|
+
return [{
|
|
13
|
+
types: MARKDOWN_SOURCE_TYPES,
|
|
14
|
+
attributes: {
|
|
15
|
+
markdownSource: {
|
|
16
|
+
default: null,
|
|
17
|
+
parseHTML: () => null,
|
|
18
|
+
renderHTML: () => ({})
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export const SendShortcut = Extension.create({
|
|
25
|
+
name: 'sendShortcut',
|
|
26
|
+
priority: 1000,
|
|
27
|
+
addOptions: () => ({
|
|
28
|
+
onSend: null
|
|
29
|
+
}),
|
|
30
|
+
addKeyboardShortcuts() {
|
|
31
|
+
return {
|
|
32
|
+
Enter: () => {
|
|
33
|
+
const onSend = this.options.onSend;
|
|
34
|
+
if (!onSend) return false;
|
|
35
|
+
onSend();
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
'Shift-Enter': () => {
|
|
39
|
+
const editor = this.editor;
|
|
40
|
+
return editor.commands.first(({
|
|
41
|
+
commands
|
|
42
|
+
}) => [...(editor.schema.nodes.listItem ? [() => commands.splitListItem('listItem')] : []), () => commands.liftEmptyBlock(), () => commands.splitBlock()]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
function hasMarkdownStructure(document) {
|
|
48
|
+
let markdown = false;
|
|
49
|
+
document.descendants(node => {
|
|
50
|
+
if (markdown) return false;
|
|
51
|
+
if (node.marks.length > 0 || !PLAIN_PASTE_NODE_TYPES.has(node.type.name)) {
|
|
52
|
+
markdown = true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
return markdown;
|
|
58
|
+
}
|
|
59
|
+
export const MarkdownPaste = Extension.create({
|
|
60
|
+
name: 'markdownPaste',
|
|
61
|
+
addOptions: () => ({
|
|
62
|
+
markdownOptions: undefined
|
|
63
|
+
}),
|
|
64
|
+
addProseMirrorPlugins() {
|
|
65
|
+
let parser;
|
|
66
|
+
return [new Plugin({
|
|
67
|
+
props: {
|
|
68
|
+
handlePaste: (view, event) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const clipboard = event.clipboardData;
|
|
71
|
+
const text = clipboard === null || clipboard === void 0 ? void 0 : clipboard.getData('text/plain');
|
|
72
|
+
if (!text) return false;
|
|
73
|
+
parser !== null && parser !== void 0 ? parser : parser = createMarkdownParser(view.state.schema, this.options.markdownOptions);
|
|
74
|
+
const document = parser.parse(text);
|
|
75
|
+
if (((_a = clipboard === null || clipboard === void 0 ? void 0 : clipboard.getData('text/html')) === null || _a === void 0 ? void 0 : _a.trim()) && !hasMarkdownStructure(document)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const single = document.childCount === 1 && ((_b = document.firstChild) === null || _b === void 0 ? void 0 : _b.type.name) === 'paragraph';
|
|
79
|
+
const slice = single ? new Slice(document.content, 1, 1) : new Slice(document.content, 0, 0);
|
|
80
|
+
view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
export function createEditorExtensions({
|
|
88
|
+
placeholder = '',
|
|
89
|
+
markdownOptions,
|
|
90
|
+
extensions = [],
|
|
91
|
+
maxLength,
|
|
92
|
+
onSendShortcut
|
|
93
|
+
} = {}) {
|
|
94
|
+
const normalizedOptions = normalizeOptions(markdownOptions);
|
|
95
|
+
const features = new Set(normalizedOptions.features);
|
|
96
|
+
const headingLevels = EDITOR_HEADING_LEVELS.filter(level => level <= normalizedOptions.maxHeadingLevel);
|
|
97
|
+
const lists = features.has('bulletList') || features.has('orderedList');
|
|
98
|
+
return [StarterKit.configure({
|
|
99
|
+
code: false,
|
|
100
|
+
codeBlock: false,
|
|
101
|
+
underline: false,
|
|
102
|
+
trailingNode: false,
|
|
103
|
+
bold: features.has('bold') && {},
|
|
104
|
+
italic: features.has('italic') && {},
|
|
105
|
+
strike: features.has('strikethrough') && {},
|
|
106
|
+
heading: features.has('heading') && {
|
|
107
|
+
levels: headingLevels
|
|
108
|
+
},
|
|
109
|
+
bulletList: features.has('bulletList') && {},
|
|
110
|
+
orderedList: features.has('orderedList') && {},
|
|
111
|
+
blockquote: features.has('blockquote') && {},
|
|
112
|
+
horizontalRule: features.has('divider') && {},
|
|
113
|
+
listItem: lists && {},
|
|
114
|
+
listKeymap: lists && {},
|
|
115
|
+
link: {
|
|
116
|
+
openOnClick: false,
|
|
117
|
+
autolink: false,
|
|
118
|
+
linkOnPaste: false
|
|
119
|
+
}
|
|
120
|
+
}), Placeholder.configure({
|
|
121
|
+
placeholder
|
|
122
|
+
}), ...(maxLength === undefined ? [] : [CharacterCount.configure({
|
|
123
|
+
limit: maxLength
|
|
124
|
+
})]), MarkdownSource, MarkdownPaste.configure({
|
|
125
|
+
markdownOptions
|
|
126
|
+
}), ...(onSendShortcut ? [SendShortcut.configure({
|
|
127
|
+
onSend: onSendShortcut
|
|
128
|
+
})] : []), ...extensions];
|
|
129
|
+
}
|