@onereach/ui-components 2.62.3-beta.1902.0 → 2.63.0-beta.1894.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/v2/{OrConfirm-f3aed6d3.js → OrConfirm-8d149ece.js} +1 -1
- package/dist/v2/{OrIconButton-94c69467.js → OrIconButton-5883eba0.js} +2 -2
- package/dist/v2/{OrInlineInput-50da2b1f.js → OrInlineInput-16a343c1.js} +1 -1
- package/dist/v2/{OrInlineTextarea-94253b64.js → OrInlineTextarea-f154bdf5.js} +1 -1
- package/dist/v2/{OrInput-040147f3.js → OrInput-4a50fe57.js} +1 -1
- package/dist/v2/{OrModal-e4439825.js → OrModal-64c5ae2e.js} +1 -1
- package/dist/v2/{OrNotification-be6132e6.js → OrNotification-9c164908.js} +1 -1
- package/dist/v2/{OrSearch-375ad422.js → OrSearch-a247f072.js} +1 -1
- package/dist/v2/{OrSelect-846e9a87.js → OrSelect-bb223cce.js} +2 -2
- package/dist/v2/{OrTag-02320f5f.js → OrTag-ab03c4f7.js} +1 -1
- package/dist/v2/{OrTooltip-afe7030b.js → OrTooltip-caeac590.js} +3 -33
- package/dist/v2/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +12 -0
- package/dist/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +111 -0
- package/dist/v2/components/or-rich-text-editor-v3/index.d.ts +1 -0
- package/dist/v2/components/or-rich-text-editor-v3/styles.d.ts +7 -0
- package/dist/v2/components/or-tooltip-v3/styles.d.ts +0 -2
- package/dist/v2/index.js +12 -12
- package/dist/v2/index2.js +12 -12
- package/dist/v2/index20.js +4 -4
- package/dist/v2/index31.js +2 -2
- package/dist/v2/index34.js +3 -3
- package/dist/v2/index36.js +3 -3
- package/dist/v2/index38.js +3 -3
- package/dist/v2/index50.js +3 -3
- package/dist/v2/index52.js +3 -3
- package/dist/v2/index62.js +306 -12
- package/dist/v2/index63.js +18 -15
- package/dist/v2/index64.js +15 -23
- package/dist/v2/index65.js +25 -4
- package/dist/v2/index66.js +2 -1
- package/dist/v2/index67.js +3 -4
- package/dist/v2/index68.js +3 -4
- package/dist/v2/index69.js +3 -10
- package/dist/v2/index70.js +3 -6
- package/dist/v2/index71.js +13 -2
- package/dist/v2/index72.js +4 -6
- package/dist/v2/index73.js +6 -4
- package/dist/v2/index74.js +2 -1
- package/dist/v2/index75.js +3 -3
- package/dist/v2/index76.js +3 -4
- package/dist/v2/index77.js +4 -15
- package/dist/v2/index78.js +14 -11
- package/dist/v2/index79.js +11 -13
- package/dist/v2/index80.js +14 -2
- package/dist/v2/index81.js +2 -2
- package/dist/v2/index82.js +2 -3
- package/dist/v2/index83.js +1 -6
- package/dist/v2/index84.js +7 -20
- package/dist/v2/index85.js +12 -9
- package/dist/v2/index86.js +18 -1
- package/dist/v2/index87.js +2 -18
- package/dist/v2/index88.js +18 -2
- package/dist/v2/index89.js +2 -10
- package/dist/v2/index90.js +9 -11
- package/dist/v2/index91.js +12 -6
- package/dist/v2/index92.js +5 -1
- package/dist/v2/index93.js +3 -0
- package/dist/v2/{types-dd4c7282.js → types-fb93ea4e.js} +1 -1
- package/dist/v3/{OrConfirm-58aa4260.js → OrConfirm-456ddee1.js} +1 -1
- package/dist/v3/{OrIconButton-eef9eb43.js → OrIconButton-b8066b5d.js} +2 -2
- package/dist/v3/{OrInlineInput-0c87838c.js → OrInlineInput-280768ba.js} +1 -1
- package/dist/v3/{OrInlineTextarea-d50f03b7.js → OrInlineTextarea-0f63f344.js} +1 -1
- package/dist/v3/{OrInput-d34c8571.js → OrInput-3eef7945.js} +1 -1
- package/dist/v3/{OrModal-179f5a1a.js → OrModal-f67d37d3.js} +1 -1
- package/dist/v3/{OrNotification-4a0dc24a.js → OrNotification-fefa1cb4.js} +1 -1
- package/dist/v3/{OrSearch-95d4e098.js → OrSearch-15a70678.js} +1 -1
- package/dist/v3/{OrSelect-32f188bd.js → OrSelect-63ada65d.js} +2 -2
- package/dist/v3/{OrTag-d1f3a0d0.js → OrTag-144b4ab8.js} +1 -1
- package/dist/v3/{OrTooltip-36c6728c.js → OrTooltip-30e05f9e.js} +3 -33
- package/dist/v3/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +12 -0
- package/dist/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +111 -0
- package/dist/v3/components/or-rich-text-editor-v3/index.d.ts +1 -0
- package/dist/v3/components/or-rich-text-editor-v3/styles.d.ts +7 -0
- package/dist/v3/components/or-tooltip-v3/styles.d.ts +0 -2
- package/dist/v3/index.js +12 -12
- package/dist/v3/index2.js +12 -12
- package/dist/v3/index20.js +4 -4
- package/dist/v3/index31.js +2 -2
- package/dist/v3/index34.js +3 -3
- package/dist/v3/index36.js +3 -3
- package/dist/v3/index38.js +3 -3
- package/dist/v3/index50.js +3 -3
- package/dist/v3/index52.js +3 -3
- package/dist/v3/index62.js +280 -12
- package/dist/v3/index63.js +17 -14
- package/dist/v3/index64.js +13 -21
- package/dist/v3/index65.js +23 -3
- package/dist/v3/index66.js +2 -1
- package/dist/v3/index67.js +3 -4
- package/dist/v3/index68.js +3 -4
- package/dist/v3/index69.js +3 -9
- package/dist/v3/index70.js +3 -4
- package/dist/v3/index71.js +10 -2
- package/dist/v3/index72.js +3 -5
- package/dist/v3/index73.js +5 -3
- package/dist/v3/index74.js +2 -1
- package/dist/v3/index75.js +3 -3
- package/dist/v3/index76.js +3 -4
- package/dist/v3/index77.js +4 -14
- package/dist/v3/index78.js +13 -10
- package/dist/v3/index79.js +10 -12
- package/dist/v3/index80.js +13 -1
- package/dist/v3/index81.js +1 -1
- package/dist/v3/index82.js +1 -3
- package/dist/v3/index83.js +1 -6
- package/dist/v3/index84.js +6 -16
- package/dist/v3/index85.js +12 -9
- package/dist/v3/index86.js +15 -1
- package/dist/v3/index87.js +2 -17
- package/dist/v3/index88.js +17 -2
- package/dist/v3/index89.js +2 -8
- package/dist/v3/index90.js +6 -9
- package/dist/v3/index91.js +11 -6
- package/dist/v3/index92.js +5 -1
- package/dist/v3/index93.js +3 -0
- package/dist/v3/{types-8ff779b1.js → types-a2a8f948.js} +1 -1
- package/package.json +7 -1
- package/src/components/or-avatar-v3/OrAvatar.docs.mdx +0 -4
- package/src/components/or-bottom-sheet-v3/OrBottomSheet.docs.mdx +0 -4
- package/src/components/or-button-v3/OrButton.docs.mdx +0 -4
- package/src/components/or-card-v3/OrCard.docs.mdx +0 -4
- package/src/components/or-checkbox-v3/OrCheckbox.docs.mdx +0 -4
- package/src/components/or-confirm-v3/OrConfirm.docs.mdx +0 -4
- package/src/components/or-error-tag-v3/OrErrorTag.docs.mdx +0 -5
- package/src/components/or-error-v3/OrError.docs.mdx +0 -4
- package/src/components/or-expansion-panel-v3/OrExpansionPanel.docs.mdx +0 -4
- package/src/components/or-fab-v3/OrFab.docs.mdx +0 -4
- package/src/components/or-hint-v3/OrHint.docs.mdx +0 -4
- package/src/components/or-icon-button-v3/OrIconButton.docs.mdx +0 -4
- package/src/components/or-icon-button-v3/styles.ts +1 -0
- package/src/components/or-icon-v3/OrIcon.docs.mdx +0 -4
- package/src/components/or-inline-input-v3/OrInlineInput.docs.mdx +0 -4
- package/src/components/or-inline-textarea-v3/OrInlineTextarea.docs.mdx +0 -4
- package/src/components/or-input-v3/OrInput.docs.mdx +0 -4
- package/src/components/or-label-v3/OrLabel.docs.mdx +0 -4
- package/src/components/or-link-v3/OrLink.docs.mdx +0 -4
- package/src/components/or-loader-v3/OrLoader.docs.mdx +0 -4
- package/src/components/or-menu-item-v3/OrMenuItem.docs.mdx +0 -4
- package/src/components/or-menu-v3/OrMenu.docs.mdx +0 -4
- package/src/components/or-modal-v3/OrModal.docs.mdx +0 -4
- package/src/components/or-notification-v3/OrNotification.docs.mdx +0 -4
- package/src/components/or-overlay-v3/OrOverlay.docs.mdx +0 -4
- package/src/components/or-popover-v3/OrPopover.docs.mdx +0 -4
- package/src/components/or-progress-v3/OrProgress.docs.mdx +0 -4
- package/src/components/or-radio-v3/OrRadio.docs.mdx +0 -4
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.docs.mdx +16 -0
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.ts +57 -0
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +295 -0
- package/src/components/or-rich-text-editor-v3/index.ts +1 -0
- package/src/components/or-rich-text-editor-v3/styles.ts +71 -0
- package/src/components/or-search-v3/OrSearch.docs.mdx +0 -4
- package/src/components/or-select-v3/OrSelect.docs.mdx +0 -4
- package/src/components/or-sidebar-v3/OrSidebar.docs.mdx +0 -4
- package/src/components/or-skeleton-v3/OrSkeleton.docs.mdx +0 -8
- package/src/components/or-switch-v3/OrSwitch.docs.mdx +0 -4
- package/src/components/or-tab-v3/OrTab.docs.mdx +0 -4
- package/src/components/or-tabs-v3/OrTabs.docs.mdx +0 -4
- package/src/components/or-tag-v3/OrTag.docs.mdx +0 -4
- package/src/components/or-teleport-v3/OrTeleport.docs.mdx +0 -4
- package/src/components/or-text-v3/OrText.docs.mdx +0 -4
- package/src/components/or-textarea-v3/OrTextarea.docs.mdx +0 -4
- package/src/components/or-tooltip-v3/OrTooltip.docs.mdx +0 -3
- package/src/components/or-tooltip-v3/OrTooltip.vue +2 -3
- package/src/components/or-tooltip-v3/styles.ts +0 -55
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Title,
|
|
3
|
+
Subtitle,
|
|
4
|
+
Description,
|
|
5
|
+
Primary,
|
|
6
|
+
ArgsTable,
|
|
7
|
+
Stories,
|
|
8
|
+
PRIMARY_STORY
|
|
9
|
+
} from '@storybook/addon-docs';
|
|
10
|
+
|
|
11
|
+
<Title />
|
|
12
|
+
<Subtitle />
|
|
13
|
+
<Description />
|
|
14
|
+
<Primary />
|
|
15
|
+
<ArgsTable story={PRIMARY_STORY} />
|
|
16
|
+
<Stories />
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/vue3';
|
|
2
|
+
import { ref } from 'vue-demi';
|
|
3
|
+
import OrRichTextEditorDocs from './OrRichTextEditor.docs.mdx';
|
|
4
|
+
import OrRichTextEditor from './OrRichTextEditor.vue';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Demo/OrRichTextEditor',
|
|
8
|
+
component: OrRichTextEditor,
|
|
9
|
+
|
|
10
|
+
argTypes: {
|
|
11
|
+
// Props
|
|
12
|
+
description: {
|
|
13
|
+
control: { type: 'text' },
|
|
14
|
+
},
|
|
15
|
+
placeholder: {
|
|
16
|
+
control: { type: 'text' },
|
|
17
|
+
},
|
|
18
|
+
modelValue: {
|
|
19
|
+
control: { type: 'text' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
parameters: {
|
|
24
|
+
docs: {
|
|
25
|
+
page: OrRichTextEditorDocs,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
design: {
|
|
29
|
+
type: 'figma',
|
|
30
|
+
url: 'https://www.figma.com/file/o7DdkaznUW2PtX4wiSuhhQ/Core?node-id=608%3A2926',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
} as Meta<typeof OrRichTextEditor>;
|
|
34
|
+
|
|
35
|
+
const Template: StoryFn<typeof OrRichTextEditor> = (args) => ({
|
|
36
|
+
components: {
|
|
37
|
+
OrRichTextEditor,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
setup() {
|
|
41
|
+
// Refs
|
|
42
|
+
const text = ref('');
|
|
43
|
+
return {
|
|
44
|
+
args,
|
|
45
|
+
text,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
template: `
|
|
50
|
+
<OrRichTextEditor
|
|
51
|
+
v-bind="args"
|
|
52
|
+
v-model="text"
|
|
53
|
+
/>
|
|
54
|
+
`,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const RichTextEditor = Template.bind({});
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="root"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
:class="rootStyles"
|
|
6
|
+
>
|
|
7
|
+
<or-label>
|
|
8
|
+
{{ description }}
|
|
9
|
+
</or-label>
|
|
10
|
+
<div
|
|
11
|
+
ref="containerRef"
|
|
12
|
+
:class="containerStyles"
|
|
13
|
+
@click="handleEditorClick()"
|
|
14
|
+
>
|
|
15
|
+
<div :class="toolbarContainerStyles">
|
|
16
|
+
<div
|
|
17
|
+
v-for="tool in toolbar"
|
|
18
|
+
:key="tool"
|
|
19
|
+
:class="toolbarStyles"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
v-for="item in tool"
|
|
23
|
+
:key="item"
|
|
24
|
+
:class="toolbarButtonStyles(item)"
|
|
25
|
+
>
|
|
26
|
+
<or-icon-button
|
|
27
|
+
:tooltip="{text: iconTooltipsEnum[item], placement: 'top'}"
|
|
28
|
+
:icon="{icon: iconsEnum[item], variant: 'inherit', size: 's'}"
|
|
29
|
+
@click="handleToolbarClick(item)"
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
<div
|
|
35
|
+
ref="editorRef"
|
|
36
|
+
:class="editorInputStyles"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch } from 'vue-demi';
|
|
44
|
+
import { useClassAttribute } from '../../hooks';
|
|
45
|
+
import { Editor } from '@tiptap/core';
|
|
46
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
47
|
+
import Underline from '@tiptap/extension-underline';
|
|
48
|
+
// import Link from '@tiptap/extension-link';
|
|
49
|
+
import Highlight from '@tiptap/extension-highlight';
|
|
50
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
51
|
+
import { OrIconButtonV3 as OrIconButton } from '../or-icon-button-v3';
|
|
52
|
+
import { OrLabelV3 as OrLabel } from '../or-label-v3';
|
|
53
|
+
import { flatMap } from 'lodash';
|
|
54
|
+
import {
|
|
55
|
+
EditorContainer,
|
|
56
|
+
EditorContainerFilled,
|
|
57
|
+
ToolbarContainer,
|
|
58
|
+
Toolbar,
|
|
59
|
+
ToolbarButtonActive,
|
|
60
|
+
ToolbarButton,
|
|
61
|
+
EditorInput,
|
|
62
|
+
} from './styles';
|
|
63
|
+
|
|
64
|
+
export default defineComponent({
|
|
65
|
+
name: 'OrRichTextEditor',
|
|
66
|
+
|
|
67
|
+
components: {
|
|
68
|
+
OrIconButton,
|
|
69
|
+
OrLabel,
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
inheritAttrs: false,
|
|
73
|
+
|
|
74
|
+
props: {
|
|
75
|
+
modelValue: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: '',
|
|
78
|
+
required: false,
|
|
79
|
+
},
|
|
80
|
+
toolbar: {
|
|
81
|
+
type: Array,
|
|
82
|
+
default: () => [['bold', 'italic', 'strike'], ['underline', 'highlight'], ['bulletList', 'orderedList'], ['undo', 'redo']],
|
|
83
|
+
},
|
|
84
|
+
description: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: '',
|
|
87
|
+
},
|
|
88
|
+
placeholder: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: 'Write something...',
|
|
91
|
+
},
|
|
92
|
+
autofocus: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
emits: ['update:modelValue'],
|
|
99
|
+
|
|
100
|
+
setup(props, { emit }) {
|
|
101
|
+
// Refs
|
|
102
|
+
let editor = null as Editor | null;
|
|
103
|
+
const editorRef = ref<HTMLDivElement>();
|
|
104
|
+
const containerRef = ref<HTMLDivElement>();
|
|
105
|
+
const isActive = ref<{[key: string]: boolean;}>({});
|
|
106
|
+
const isFilled = ref<boolean>(false);
|
|
107
|
+
const iconsEnum = ref<{[key: string]: string;}>({
|
|
108
|
+
bold: 'format_bold',
|
|
109
|
+
italic: 'format_italic',
|
|
110
|
+
underline: 'format_underlined',
|
|
111
|
+
strike: 'format_strikethrough',
|
|
112
|
+
bulletList: 'format_list_bulleted',
|
|
113
|
+
orderedList: 'format_list_numbered',
|
|
114
|
+
link: 'link',
|
|
115
|
+
highlight: 'highlight',
|
|
116
|
+
redo: 'redo',
|
|
117
|
+
undo: 'undo',
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const iconTooltipsEnum = ref<{[key: string]: string;}>({
|
|
121
|
+
bold: 'Bold',
|
|
122
|
+
italic: 'Italic',
|
|
123
|
+
underline: 'Underline',
|
|
124
|
+
strike: 'Strike',
|
|
125
|
+
bulletList: 'Bulleted List',
|
|
126
|
+
orderedList: 'Numbered List',
|
|
127
|
+
link: 'Link',
|
|
128
|
+
highlight: 'Highlight',
|
|
129
|
+
redo: 'Redo',
|
|
130
|
+
undo: 'Undo',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
onMounted(() => {
|
|
134
|
+
editor = new Editor({
|
|
135
|
+
onUpdate: ({ editor }) => {
|
|
136
|
+
setActiveFormats();
|
|
137
|
+
const html = editor.getHTML();
|
|
138
|
+
const text = editor.getText();
|
|
139
|
+
emit('update:modelValue', text === '' ? text : html);
|
|
140
|
+
isFilled.value = text !== '';
|
|
141
|
+
},
|
|
142
|
+
element: editorRef.value,
|
|
143
|
+
content: props.modelValue,
|
|
144
|
+
autofocus: props.autofocus,
|
|
145
|
+
extensions: [
|
|
146
|
+
StarterKit,
|
|
147
|
+
Underline,
|
|
148
|
+
// Link.configure({
|
|
149
|
+
// openOnClick: true,
|
|
150
|
+
// linkOnPaste: true,
|
|
151
|
+
// protocols: ['ftp', 'mailto'],
|
|
152
|
+
// validate: href => /^https?:\/\//.test(href),
|
|
153
|
+
// HTMLAttributes: {
|
|
154
|
+
// class: 'text-primary cursor-pointer',
|
|
155
|
+
// },
|
|
156
|
+
// }),
|
|
157
|
+
Highlight,
|
|
158
|
+
Placeholder
|
|
159
|
+
.configure({
|
|
160
|
+
placeholder: props.placeholder,
|
|
161
|
+
emptyEditorClass: 'is-editor-empty text-outline',
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
editorProps: {
|
|
165
|
+
attributes: {
|
|
166
|
+
class: 'focus:outline-none',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
setActiveFormats();
|
|
171
|
+
isFilled.value = props.modelValue !== '';
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
onBeforeUnmount(() => {
|
|
175
|
+
editor?.destroy();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Methods
|
|
179
|
+
const handleEditorClick = () => {
|
|
180
|
+
setActiveFormats();
|
|
181
|
+
editor?.commands.focus();
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const handleToolbarClick = (item: string) => {
|
|
185
|
+
if (item === 'bulletList' || item === 'orderedList') {
|
|
186
|
+
item === 'bulletList' ? editor?.commands.toggleBulletList() : editor?.commands.toggleOrderedList();
|
|
187
|
+
}
|
|
188
|
+
else if (item === 'undo' || item === 'redo') {
|
|
189
|
+
item === 'undo' ? editor?.commands.undo() : editor?.commands.redo();
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
editor?.chain().focus().toggleMark(item).run();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const setActiveFormats = () => {
|
|
197
|
+
const toolbarList = flatMap(props.toolbar) as string[];
|
|
198
|
+
toolbarList.forEach((item) => {
|
|
199
|
+
isActive.value[item] = editor?.isActive(item) || false;
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Styles
|
|
204
|
+
const classAttribute = useClassAttribute();
|
|
205
|
+
|
|
206
|
+
const rootStyles = computed(() => {
|
|
207
|
+
return [
|
|
208
|
+
'or-rich-text-editor',
|
|
209
|
+
classAttribute.value,
|
|
210
|
+
];
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const containerStyles = computed(() => {
|
|
214
|
+
return [
|
|
215
|
+
...EditorContainer,
|
|
216
|
+
...(isFilled.value ? EditorContainerFilled : []),
|
|
217
|
+
];
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const toolbarContainerStyles = computed(() => {
|
|
221
|
+
return [
|
|
222
|
+
...ToolbarContainer,
|
|
223
|
+
];
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const toolbarStyles = computed(() => {
|
|
227
|
+
return [
|
|
228
|
+
...Toolbar,
|
|
229
|
+
];
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const editorInputStyles = computed(() => {
|
|
233
|
+
return [
|
|
234
|
+
'tiptap-editor',
|
|
235
|
+
...EditorInput,
|
|
236
|
+
];
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const toolbarButtonStyles = (item: string) => {
|
|
240
|
+
return [
|
|
241
|
+
// Layout
|
|
242
|
+
'flex',
|
|
243
|
+
// Spacing
|
|
244
|
+
'gap-md',
|
|
245
|
+
...isActive.value[item] ? ToolbarButtonActive : ToolbarButton,
|
|
246
|
+
];
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
//Effects
|
|
250
|
+
watch(() => props.modelValue, (value) => {
|
|
251
|
+
if (value !== editor?.getHTML()) {
|
|
252
|
+
editor?.commands.setContent(value);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
editor,
|
|
258
|
+
editorRef,
|
|
259
|
+
containerRef,
|
|
260
|
+
iconsEnum,
|
|
261
|
+
handleToolbarClick,
|
|
262
|
+
handleEditorClick,
|
|
263
|
+
isActive,
|
|
264
|
+
iconTooltipsEnum,
|
|
265
|
+
containerStyles,
|
|
266
|
+
toolbarContainerStyles,
|
|
267
|
+
toolbarStyles,
|
|
268
|
+
rootStyles,
|
|
269
|
+
toolbarButtonStyles,
|
|
270
|
+
editorInputStyles,
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
</script>
|
|
275
|
+
|
|
276
|
+
<style lang="scss">
|
|
277
|
+
.tiptap-editor {
|
|
278
|
+
ol { //see if editor can not inherit it
|
|
279
|
+
margin: 0 24px;
|
|
280
|
+
list-style: decimal;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
ul {
|
|
284
|
+
margin: 0 24px;
|
|
285
|
+
list-style: initial;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.is-editor-empty::before {
|
|
289
|
+
content: attr(data-placeholder);
|
|
290
|
+
height: 0;
|
|
291
|
+
pointer-events: none;
|
|
292
|
+
float: left;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as OrRichTextEditor } from './OrRichTextEditor.vue';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const EditorContainer: string[] = [
|
|
2
|
+
// Colors
|
|
3
|
+
'border-disabled',
|
|
4
|
+
'dark:border-outline-dark',
|
|
5
|
+
'focus-within:theme-border-1-primary',
|
|
6
|
+
'dark:focus-within:theme-border-1-primary-dark',
|
|
7
|
+
'focus-within:bg-primary-opacity-0-08',
|
|
8
|
+
'dark:focus-within:bg-primary-opacity-0-08-dark',
|
|
9
|
+
'focus-within:theme-outline-primary',
|
|
10
|
+
'dark:focus-within:theme-outline-primary-dark',
|
|
11
|
+
|
|
12
|
+
// Sizing
|
|
13
|
+
'border-1',
|
|
14
|
+
'rounded-md',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export const EditorContainerFilled: string[] = [
|
|
18
|
+
//Colors
|
|
19
|
+
'bg-primary-opacity-0-08',
|
|
20
|
+
'dark:bg-primary-opacity-0-08-dark',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const ToolbarContainer: string[] = [
|
|
24
|
+
// Layout
|
|
25
|
+
'flex',
|
|
26
|
+
//Spacing
|
|
27
|
+
'py-sm',
|
|
28
|
+
//Sizing
|
|
29
|
+
'border-b-1',
|
|
30
|
+
//Colors
|
|
31
|
+
'border-b-disabled',
|
|
32
|
+
'dark:border-b-outline-dark',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export const Toolbar: string[] = [
|
|
36
|
+
// Layout
|
|
37
|
+
'flex',
|
|
38
|
+
// Spacing
|
|
39
|
+
'px-sm',
|
|
40
|
+
'gap-md',
|
|
41
|
+
// Sizing
|
|
42
|
+
'border-r-1',
|
|
43
|
+
//Colors
|
|
44
|
+
'border-r-disabled',
|
|
45
|
+
'dark:border-r-outline-dark',
|
|
46
|
+
// Last child
|
|
47
|
+
'last-of-type:border-none',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export const ToolbarButton: string[] = [
|
|
51
|
+
// Typography
|
|
52
|
+
'text-on-disabled',
|
|
53
|
+
'dark:text-outline-dark',
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export const ToolbarButtonActive: string[] = [
|
|
57
|
+
// Typography
|
|
58
|
+
'text-on-background',
|
|
59
|
+
'dark:text-on-background-dark',
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
export const EditorInput: string[] = [
|
|
63
|
+
// Spacing
|
|
64
|
+
'p-sm',
|
|
65
|
+
// Typography
|
|
66
|
+
'typography-body-2-regular',
|
|
67
|
+
'text-on-background',
|
|
68
|
+
'dark:text-on-background-dark',
|
|
69
|
+
// Sizing
|
|
70
|
+
'min-h-[88px]',
|
|
71
|
+
];
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { DocsPage } from '@storybook/addon-docs';
|
|
2
2
|
|
|
3
|
-
```ts
|
|
4
|
-
import {
|
|
5
|
-
OrSkeletonCircleV3 as OrSkeletonCircle,
|
|
6
|
-
OrSkeletonRectV3 as OrSkeletonRect,
|
|
7
|
-
OrSkeletonTextV3 as OrSkeletonText,
|
|
8
|
-
} from '@onereach/ui-components';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
3
|
<DocsPage />
|
|
12
4
|
|
|
13
5
|
## Migration Guide from V1
|