@onereach/ui-components 2.68.0-beta.2002.0 → 2.68.0-beta.2003.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/bundled/v2/{OrCode-0cd991a1.js → OrCode-edc7a1f5.js} +114 -1
- package/dist/bundled/v2/components/index.d.ts +0 -1
- package/dist/bundled/v2/components/index.js +1 -4
- package/dist/bundled/v2/components/or-code/index.js +1 -2
- package/dist/bundled/v2/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +39 -0
- package/dist/bundled/v2/components/or-empty-state-v3/OrEmptyState.vue.d.ts +109 -0
- package/dist/bundled/v2/components/or-empty-state-v3/index.d.ts +2 -0
- package/dist/bundled/v2/components/or-empty-state-v3/index.js +131 -0
- package/dist/bundled/v2/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/bundled/v2/index.js +2 -5
- package/dist/bundled/v3/{OrCode.vue_vue_type_script_lang-6c5f94a6.js → OrCode.vue_vue_type_script_lang-ef5e7f04.js} +114 -1
- package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-2fdbd2f2.js → OrTabs.vue_vue_type_script_lang-ca57f9d9.js} +36 -10
- package/dist/bundled/v3/components/index.d.ts +0 -1
- package/dist/bundled/v3/components/index.js +2 -6
- package/dist/bundled/v3/components/or-code/index.js +1 -2
- package/dist/bundled/v3/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +39 -0
- package/dist/bundled/v3/components/or-empty-state-v3/OrEmptyState.vue.d.ts +109 -0
- package/dist/bundled/v3/components/or-empty-state-v3/index.d.ts +2 -0
- package/dist/bundled/v3/components/or-empty-state-v3/index.js +111 -0
- package/dist/bundled/v3/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/bundled/v3/components/or-tabs-v3/index.js +1 -2
- package/dist/bundled/v3/index.js +178 -273
- package/dist/esm/v2/components/index.d.ts +0 -1
- package/dist/esm/v2/components/index.js +0 -19
- package/dist/esm/v2/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +39 -0
- package/dist/esm/v2/components/or-empty-state-v3/OrEmptyState.vue.d.ts +109 -0
- package/dist/esm/v2/components/or-empty-state-v3/index.d.ts +2 -0
- package/dist/esm/v2/components/or-empty-state-v3/index.js +129 -0
- package/dist/esm/v2/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/esm/v2/index.js +0 -19
- package/dist/esm/v3/components/index.d.ts +0 -1
- package/dist/esm/v3/components/index.js +0 -19
- package/dist/esm/v3/components/or-empty-state-v3/OrEmptyState.stories3.d.ts +39 -0
- package/dist/esm/v3/components/or-empty-state-v3/OrEmptyState.vue.d.ts +109 -0
- package/dist/esm/v3/components/or-empty-state-v3/index.d.ts +2 -0
- package/dist/esm/v3/components/or-empty-state-v3/index.js +111 -0
- package/dist/esm/v3/components/or-empty-state-v3/types.d.ts +2 -0
- package/dist/esm/v3/index.js +0 -19
- package/package.json +1 -19
- package/src/components/index.ts +0 -1
- package/src/components/or-empty-state-v3/OrEmptyState.stories3.ts +203 -0
- package/src/components/or-empty-state-v3/OrEmptyState.vue +101 -0
- package/src/components/or-empty-state-v3/index.ts +2 -0
- package/src/components/or-empty-state-v3/types.ts +3 -0
- package/dist/bundled/v2/OrRichTextEditor-898d67d5.js +0 -36828
- package/dist/bundled/v2/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +0 -12
- package/dist/bundled/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -149
- package/dist/bundled/v2/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/bundled/v2/components/or-rich-text-editor-v3/index.js +0 -24
- package/dist/bundled/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -6
- package/dist/bundled/v2/index.es-3f39f316.js +0 -115
- package/dist/bundled/v3/OrMenu-08aa60de.js +0 -29
- package/dist/bundled/v3/OrRichTextEditor.vue_vue_type_script_lang-2e607f79.js +0 -36708
- package/dist/bundled/v3/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +0 -12
- package/dist/bundled/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -149
- package/dist/bundled/v3/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/bundled/v3/components/or-rich-text-editor-v3/index.js +0 -25
- package/dist/bundled/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -6
- package/dist/bundled/v3/index.es-3f39f316.js +0 -115
- package/dist/esm/v2/OrRichTextEditor-6bc37dc4.js +0 -516
- package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +0 -12
- package/dist/esm/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -149
- package/dist/esm/v2/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +0 -38
- package/dist/esm/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -6
- package/dist/esm/v3/OrRichTextEditor-a5d38e89.js +0 -486
- package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts +0 -12
- package/dist/esm/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -149
- package/dist/esm/v3/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +0 -37
- package/dist/esm/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -6
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.docs.mdx +0 -16
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.stories3.ts +0 -62
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +0 -520
- package/src/components/or-rich-text-editor-v3/index.ts +0 -1
- package/src/components/or-rich-text-editor-v3/styles.ts +0 -65
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export { _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-6bc37dc4.js';
|
|
2
|
-
import 'vue-demi';
|
|
3
|
-
import '../../useClassAttribute-47fdb016.js';
|
|
4
|
-
import '@vueuse/core';
|
|
5
|
-
import 'prosemirror-markdown';
|
|
6
|
-
import 'prosemirror-model';
|
|
7
|
-
import 'marked';
|
|
8
|
-
import '../../OrIconButton-a7764de4.js';
|
|
9
|
-
import '../../OrIcon-05689298.js';
|
|
10
|
-
import '../../normalize-component-6e8e3d80.js';
|
|
11
|
-
import '../../OrTooltip-3454c2e6.js';
|
|
12
|
-
import '../../OrPopover-ef8c91f1.js';
|
|
13
|
-
import '@floating-ui/dom';
|
|
14
|
-
import '../../useElevation-31bfe1f6.js';
|
|
15
|
-
import '../../useResponsive-a02e95b7.js';
|
|
16
|
-
import '../../OrBottomSheet-5acd034f.js';
|
|
17
|
-
import '../../OrOverlay-18ba2dc6.js';
|
|
18
|
-
import '../../OrTeleport.vue2-fb92f29f.js';
|
|
19
|
-
import 'portal-vue';
|
|
20
|
-
import '../../OrLabel-5670468e.js';
|
|
21
|
-
import '../../OrMenu-e7210edc.js';
|
|
22
|
-
import '../../OrMenuItem-038641b7.js';
|
|
23
|
-
import '@tiptap/core';
|
|
24
|
-
import '@tiptap/starter-kit';
|
|
25
|
-
import '@tiptap/extension-underline';
|
|
26
|
-
import '@tiptap/extension-link';
|
|
27
|
-
import '@tiptap/extension-highlight';
|
|
28
|
-
import '@tiptap/extension-heading';
|
|
29
|
-
import '@tiptap/extension-placeholder';
|
|
30
|
-
import '@tiptap/extension-paragraph';
|
|
31
|
-
import '@tiptap/extension-bullet-list';
|
|
32
|
-
import '@tiptap/extension-list-item';
|
|
33
|
-
import '@tiptap/extension-ordered-list';
|
|
34
|
-
import '@tiptap/extension-strike';
|
|
35
|
-
import '@tiptap/extension-italic';
|
|
36
|
-
import '@tiptap/extension-hard-break';
|
|
37
|
-
import '@tiptap/extension-bold';
|
|
38
|
-
import '../../browser-82dea9ed.js';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const EditorContainer: string[];
|
|
2
|
-
export declare const ToolbarContainer: string[];
|
|
3
|
-
export declare const Toolbar: string[];
|
|
4
|
-
export declare const ToolbarButton: string[];
|
|
5
|
-
export declare const ToolbarButtonActive: string[];
|
|
6
|
-
export declare const EditorInput: string[];
|
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch } from 'vue-demi';
|
|
2
|
-
import { u as useClassAttribute } from './useClassAttribute-47fdb016.js';
|
|
3
|
-
import '@vueuse/core';
|
|
4
|
-
import { defaultMarkdownSerializer, MarkdownSerializer } from 'prosemirror-markdown';
|
|
5
|
-
import { DOMParser as DOMParser$1 } from 'prosemirror-model';
|
|
6
|
-
import { marked } from 'marked';
|
|
7
|
-
import { s as script$1 } from './OrIconButton-85abafab.js';
|
|
8
|
-
import { s as script$2 } from './OrLabel-7d4fe80b.js';
|
|
9
|
-
import { s as script$4 } from './OrMenu-d9e12030.js';
|
|
10
|
-
import './OrPopover-94a8f21d.js';
|
|
11
|
-
import { s as script$3 } from './OrMenuItem-d001f0f6.js';
|
|
12
|
-
import { Editor, mergeAttributes } from '@tiptap/core';
|
|
13
|
-
import StarterKit from '@tiptap/starter-kit';
|
|
14
|
-
import Underline from '@tiptap/extension-underline';
|
|
15
|
-
import Link from '@tiptap/extension-link';
|
|
16
|
-
import Highlight from '@tiptap/extension-highlight';
|
|
17
|
-
import Heading from '@tiptap/extension-heading';
|
|
18
|
-
import Placeholder from '@tiptap/extension-placeholder';
|
|
19
|
-
import Paragraph from '@tiptap/extension-paragraph';
|
|
20
|
-
import BulletList from '@tiptap/extension-bullet-list';
|
|
21
|
-
import ListItem from '@tiptap/extension-list-item';
|
|
22
|
-
import OrderedList from '@tiptap/extension-ordered-list';
|
|
23
|
-
import Strike from '@tiptap/extension-strike';
|
|
24
|
-
import Italic from '@tiptap/extension-italic';
|
|
25
|
-
import HardBreak from '@tiptap/extension-hard-break';
|
|
26
|
-
import Bold from '@tiptap/extension-bold';
|
|
27
|
-
import { resolveComponent, openBlock, createElementBlock, mergeProps, createVNode, withCtx, createTextVNode, toDisplayString, createElementVNode, normalizeClass, Fragment, renderList, createBlock, createCommentVNode } from 'vue';
|
|
28
|
-
import { s as styleInject } from './style-inject.es-4c6f2515.js';
|
|
29
|
-
|
|
30
|
-
const EditorContainer = [
|
|
31
|
-
// Colors
|
|
32
|
-
'border-outline', 'dark:border-outline-dark', 'focus-within:theme-border-1-primary', 'dark:focus-within:theme-border-1-primary-dark', 'focus-within:bg-primary-opacity-0-08', 'dark:focus-within:bg-primary-opacity-0-08-dark', 'focus-within:theme-outline-primary', 'dark:focus-within:theme-outline-primary-dark',
|
|
33
|
-
// Sizing
|
|
34
|
-
'border-1', 'rounded-md'];
|
|
35
|
-
const ToolbarContainer = [
|
|
36
|
-
// Layout
|
|
37
|
-
'flex',
|
|
38
|
-
//Spacing
|
|
39
|
-
'py-sm',
|
|
40
|
-
//Sizing
|
|
41
|
-
'border-b-1',
|
|
42
|
-
//Colors
|
|
43
|
-
'border-b-outline', 'dark:border-b-outline-dark'];
|
|
44
|
-
const Toolbar = [
|
|
45
|
-
// Layout
|
|
46
|
-
'flex',
|
|
47
|
-
// Spacing
|
|
48
|
-
'px-sm', 'gap-md',
|
|
49
|
-
// Sizing
|
|
50
|
-
'border-r-1',
|
|
51
|
-
//Colors
|
|
52
|
-
'border-r-disabled', 'dark:border-r-outline-dark',
|
|
53
|
-
// Last child
|
|
54
|
-
'last-of-type:border-none'];
|
|
55
|
-
const ToolbarButton = [
|
|
56
|
-
// Typography
|
|
57
|
-
'text-on-disabled', 'dark:text-outline-dark'];
|
|
58
|
-
const ToolbarButtonActive = [
|
|
59
|
-
// Typography
|
|
60
|
-
'text-on-background', 'dark:text-on-background-dark'];
|
|
61
|
-
const EditorInput = [
|
|
62
|
-
// Spacing
|
|
63
|
-
'p-sm',
|
|
64
|
-
// Typography
|
|
65
|
-
'typography-body-2-regular', 'text-on-background', 'dark:text-on-background-dark',
|
|
66
|
-
// Sizing
|
|
67
|
-
'min-h-[88px]'];
|
|
68
|
-
|
|
69
|
-
var script = defineComponent({
|
|
70
|
-
name: 'OrRichTextEditor',
|
|
71
|
-
components: {
|
|
72
|
-
OrIconButton: script$1,
|
|
73
|
-
OrLabel: script$2,
|
|
74
|
-
OrMenuItem: script$3,
|
|
75
|
-
OrMenu: script$4
|
|
76
|
-
},
|
|
77
|
-
inheritAttrs: false,
|
|
78
|
-
props: {
|
|
79
|
-
modelValue: {
|
|
80
|
-
type: String,
|
|
81
|
-
default: '',
|
|
82
|
-
required: false
|
|
83
|
-
},
|
|
84
|
-
toolbar: {
|
|
85
|
-
type: Array,
|
|
86
|
-
default: () => [['heading'], ['bold', 'italic', 'strike'], ['underline', 'highlight'], ['link'], ['bulletList', 'orderedList'], ['undo', 'redo']]
|
|
87
|
-
},
|
|
88
|
-
description: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: 'Description'
|
|
91
|
-
},
|
|
92
|
-
placeholder: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: 'Write something...'
|
|
95
|
-
},
|
|
96
|
-
autofocus: {
|
|
97
|
-
type: Boolean,
|
|
98
|
-
default: false
|
|
99
|
-
},
|
|
100
|
-
markdown: {
|
|
101
|
-
type: Boolean,
|
|
102
|
-
default: true
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
emits: ['update:modelValue'],
|
|
106
|
-
setup(props, {
|
|
107
|
-
emit
|
|
108
|
-
}) {
|
|
109
|
-
// Refs
|
|
110
|
-
let editor = null;
|
|
111
|
-
const editorRef = ref();
|
|
112
|
-
const containerRef = ref();
|
|
113
|
-
const toolbarButtonRef = ref();
|
|
114
|
-
const menuRef = ref();
|
|
115
|
-
const isActive = ref({});
|
|
116
|
-
const headingLevels = [1, 2, 3, 4];
|
|
117
|
-
const previousHeadingLevel = ref();
|
|
118
|
-
const activeHeadingLevel = ref(0);
|
|
119
|
-
const markdownOutput = ref('');
|
|
120
|
-
const iconsEnum = ref({
|
|
121
|
-
bold: 'format_bold',
|
|
122
|
-
italic: 'format_italic',
|
|
123
|
-
underline: 'format_underlined',
|
|
124
|
-
strike: 'format_strikethrough',
|
|
125
|
-
bulletList: 'format_list_bulleted',
|
|
126
|
-
orderedList: 'format_list_numbered',
|
|
127
|
-
link: 'link',
|
|
128
|
-
highlight: 'highlight',
|
|
129
|
-
redo: 'redo',
|
|
130
|
-
undo: 'undo'
|
|
131
|
-
});
|
|
132
|
-
const iconTooltipsEnum = ref({
|
|
133
|
-
bold: 'Bold',
|
|
134
|
-
italic: 'Italic',
|
|
135
|
-
underline: 'Underline',
|
|
136
|
-
strike: 'Strike',
|
|
137
|
-
bulletList: 'Bulleted List',
|
|
138
|
-
orderedList: 'Numbered List',
|
|
139
|
-
link: 'Link',
|
|
140
|
-
highlight: 'Highlight',
|
|
141
|
-
redo: 'Redo',
|
|
142
|
-
undo: 'Undo'
|
|
143
|
-
});
|
|
144
|
-
const serializerMarks = {
|
|
145
|
-
...defaultMarkdownSerializer.marks,
|
|
146
|
-
[Bold.name]: defaultMarkdownSerializer.marks.strong,
|
|
147
|
-
[Strike.name]: {
|
|
148
|
-
open: '~~',
|
|
149
|
-
close: '~~',
|
|
150
|
-
mixable: true,
|
|
151
|
-
expelEnclosingWhitespace: true
|
|
152
|
-
},
|
|
153
|
-
[Italic.name]: {
|
|
154
|
-
open: '_',
|
|
155
|
-
close: '_',
|
|
156
|
-
mixable: true,
|
|
157
|
-
expelEnclosingWhitespace: true
|
|
158
|
-
},
|
|
159
|
-
[Highlight.name]: {
|
|
160
|
-
open: '==',
|
|
161
|
-
close: '==',
|
|
162
|
-
mixable: true,
|
|
163
|
-
expelEnclosingWhitespace: true
|
|
164
|
-
},
|
|
165
|
-
[Link.name]: {
|
|
166
|
-
open(state, mark, parent, index) {
|
|
167
|
-
return isPlainURL(mark, parent, index, 1) ? '<' : '[';
|
|
168
|
-
},
|
|
169
|
-
close(state, mark, parent, index) {
|
|
170
|
-
const href = mark.attrs.canonicalSrc || mark.attrs.href;
|
|
171
|
-
return isPlainURL(mark, parent, index, -1) ? '>' : `](${state.esc(href)}${mark.attrs.title ? ` ${state.quote(mark.attrs.title)}` : ''})`;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const serializerNodes = {
|
|
176
|
-
...defaultMarkdownSerializer.nodes,
|
|
177
|
-
[Paragraph.name]: defaultMarkdownSerializer.nodes.paragraph,
|
|
178
|
-
[BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list,
|
|
179
|
-
[ListItem.name]: defaultMarkdownSerializer.nodes.list_item,
|
|
180
|
-
[OrderedList.name]: defaultMarkdownSerializer.nodes.ordered_list,
|
|
181
|
-
[HardBreak.name]: defaultMarkdownSerializer.nodes.hard_break
|
|
182
|
-
};
|
|
183
|
-
onMounted(() => {
|
|
184
|
-
editor = new Editor({
|
|
185
|
-
onUpdate: ({
|
|
186
|
-
editor
|
|
187
|
-
}) => {
|
|
188
|
-
setActiveFormats();
|
|
189
|
-
const html = editor.getHTML();
|
|
190
|
-
const text = editor.getText();
|
|
191
|
-
if (props.markdown) {
|
|
192
|
-
markdownOutput.value = serialize(editor.schema, editor.getJSON());
|
|
193
|
-
emit('update:modelValue', markdownOutput.value);
|
|
194
|
-
} else {
|
|
195
|
-
emit('update:modelValue', text === '' ? text : html);
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
onCreate: ({
|
|
199
|
-
editor
|
|
200
|
-
}) => {
|
|
201
|
-
if (props.markdown) {
|
|
202
|
-
const deserialized = deserialize(editor.schema, props.modelValue);
|
|
203
|
-
// const deserialized = defaultMarkdownParser.parse(props.modelValue);
|
|
204
|
-
// editor.view.state.doc = deserialized as Node;
|
|
205
|
-
editor.commands.setContent(deserialized);
|
|
206
|
-
} else {
|
|
207
|
-
editor.commands.setContent(props.modelValue);
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
element: editorRef.value,
|
|
211
|
-
autofocus: props.autofocus,
|
|
212
|
-
extensions: [StarterKit.configure({
|
|
213
|
-
heading: false
|
|
214
|
-
}), Heading.configure({
|
|
215
|
-
levels: headingLevels
|
|
216
|
-
}).extend({
|
|
217
|
-
levels: headingLevels,
|
|
218
|
-
renderHTML({
|
|
219
|
-
node,
|
|
220
|
-
HTMLAttributes
|
|
221
|
-
}) {
|
|
222
|
-
return ['h' + node.attrs.level, mergeAttributes(HTMLAttributes, {
|
|
223
|
-
class: `typography-headline-${node.attrs.level}`
|
|
224
|
-
}), 0];
|
|
225
|
-
}
|
|
226
|
-
}), Underline, Link.configure({
|
|
227
|
-
openOnClick: true,
|
|
228
|
-
linkOnPaste: true,
|
|
229
|
-
autolink: false,
|
|
230
|
-
protocols: ['ftp', 'mailto', 'http', 'https'],
|
|
231
|
-
validate: href => /^https?:\/\//.test(href),
|
|
232
|
-
HTMLAttributes: {
|
|
233
|
-
class: 'text-primary cursor-pointer'
|
|
234
|
-
}
|
|
235
|
-
}), Highlight, Placeholder.configure({
|
|
236
|
-
placeholder: props.placeholder,
|
|
237
|
-
emptyEditorClass: 'is-editor-empty text-outline'
|
|
238
|
-
})],
|
|
239
|
-
editorProps: {
|
|
240
|
-
attributes: {
|
|
241
|
-
class: 'focus:outline-none'
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
setActiveFormats();
|
|
246
|
-
});
|
|
247
|
-
onBeforeUnmount(() => {
|
|
248
|
-
editor === null || editor === void 0 ? void 0 : editor.destroy();
|
|
249
|
-
});
|
|
250
|
-
// Computed
|
|
251
|
-
const getIndexOfHeading = computed(() => {
|
|
252
|
-
return props.toolbar.flat().indexOf('heading');
|
|
253
|
-
});
|
|
254
|
-
const headingIcon = computed(() => {
|
|
255
|
-
if (activeHeadingLevel.value && isActive.value.heading) {
|
|
256
|
-
return `format_h${activeHeadingLevel.value}`;
|
|
257
|
-
}
|
|
258
|
-
return 'format_paragraph';
|
|
259
|
-
});
|
|
260
|
-
// Methods
|
|
261
|
-
const handleEditorClick = () => {
|
|
262
|
-
setActiveFormats();
|
|
263
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.focus();
|
|
264
|
-
};
|
|
265
|
-
const handleToolbarClick = (item, level) => {
|
|
266
|
-
if (item === 'bulletList' || item === 'orderedList') {
|
|
267
|
-
item === 'bulletList' ? editor === null || editor === void 0 ? void 0 : editor.commands.toggleBulletList() : editor === null || editor === void 0 ? void 0 : editor.commands.toggleOrderedList();
|
|
268
|
-
} else if (item === 'link') {
|
|
269
|
-
setLink();
|
|
270
|
-
} else if (item === 'heading') {
|
|
271
|
-
if (!level) {
|
|
272
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.toggleHeading({
|
|
273
|
-
level: previousHeadingLevel.value
|
|
274
|
-
});
|
|
275
|
-
activeHeadingLevel.value = 0;
|
|
276
|
-
} else {
|
|
277
|
-
activeHeadingLevel.value = level;
|
|
278
|
-
previousHeadingLevel.value = level;
|
|
279
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.toggleHeading({
|
|
280
|
-
level: level
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.focus();
|
|
284
|
-
} else if (item === 'undo' || item === 'redo') {
|
|
285
|
-
item === 'undo' ? editor === null || editor === void 0 ? void 0 : editor.commands.undo() : editor === null || editor === void 0 ? void 0 : editor.commands.redo();
|
|
286
|
-
} else {
|
|
287
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().toggleMark(item).run();
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const setLink = () => {
|
|
291
|
-
const previousUrl = editor === null || editor === void 0 ? void 0 : editor.getAttributes('link').href;
|
|
292
|
-
const url = window.prompt('URL', previousUrl);
|
|
293
|
-
// cancelled
|
|
294
|
-
if (url === null) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
// empty
|
|
298
|
-
if (url === '') {
|
|
299
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
// update link
|
|
303
|
-
editor === null || editor === void 0 ? void 0 : editor.chain().focus().extendMarkRange('link').setLink({
|
|
304
|
-
href: url
|
|
305
|
-
}).run();
|
|
306
|
-
};
|
|
307
|
-
const setActiveFormats = () => {
|
|
308
|
-
const toolbarList = props.toolbar.flat();
|
|
309
|
-
toolbarList.forEach(item => {
|
|
310
|
-
isActive.value[item] = (editor === null || editor === void 0 ? void 0 : editor.isActive(item)) || false;
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
// Styles
|
|
314
|
-
const classAttribute = useClassAttribute();
|
|
315
|
-
const rootStyles = computed(() => {
|
|
316
|
-
return ['or-rich-text-editor', classAttribute.value];
|
|
317
|
-
});
|
|
318
|
-
const containerStyles = computed(() => {
|
|
319
|
-
return [...EditorContainer];
|
|
320
|
-
});
|
|
321
|
-
const toolbarContainerStyles = computed(() => {
|
|
322
|
-
return [...ToolbarContainer];
|
|
323
|
-
});
|
|
324
|
-
const toolbarStyles = computed(() => {
|
|
325
|
-
return [...Toolbar];
|
|
326
|
-
});
|
|
327
|
-
const editorInputStyles = computed(() => {
|
|
328
|
-
return ['tiptap-editor', ...EditorInput];
|
|
329
|
-
});
|
|
330
|
-
const toolbarButtonStyles = item => {
|
|
331
|
-
return [
|
|
332
|
-
// Layout
|
|
333
|
-
'flex',
|
|
334
|
-
// Spacing
|
|
335
|
-
'gap-md', ...(isActive.value[item] ? ToolbarButtonActive : ToolbarButton)];
|
|
336
|
-
};
|
|
337
|
-
const isPlainURL = (link, parent, index, side) => {
|
|
338
|
-
if (link.attrs.title || !/^\w+:/.test(link.attrs.href)) return false;
|
|
339
|
-
const content = parent.child(index + (side < 0 ? -1 : 0));
|
|
340
|
-
if (!content.isText || content.text !== link.attrs.href || content.marks[content.marks.length - 1] !== link) return false;
|
|
341
|
-
if (index === (side < 0 ? 1 : parent.childCount - 1)) return true;
|
|
342
|
-
const next = parent.child(index + (side < 0 ? -2 : 1));
|
|
343
|
-
return !link.isInSet(next.marks);
|
|
344
|
-
};
|
|
345
|
-
const serialize = (schema, content) => {
|
|
346
|
-
const proseMirrorDocument = schema.nodeFromJSON(content);
|
|
347
|
-
const serializer = new MarkdownSerializer(serializerNodes, serializerMarks);
|
|
348
|
-
return serializer.serialize(proseMirrorDocument);
|
|
349
|
-
};
|
|
350
|
-
const deserialize = (schema, content) => {
|
|
351
|
-
// const html = defaultMarkdownParser.parse(content);
|
|
352
|
-
const html = marked.parse(content);
|
|
353
|
-
if (!html) return null;
|
|
354
|
-
const parser = new DOMParser();
|
|
355
|
-
const {
|
|
356
|
-
body
|
|
357
|
-
} = parser.parseFromString(html, 'text/html');
|
|
358
|
-
// append original source as a comment that nodes can access
|
|
359
|
-
body.append(document.createComment(content));
|
|
360
|
-
const state = DOMParser$1.fromSchema(schema).parse(body);
|
|
361
|
-
return state.toJSON();
|
|
362
|
-
};
|
|
363
|
-
//Effects
|
|
364
|
-
watch(() => props.modelValue, value => {
|
|
365
|
-
if (value !== (editor === null || editor === void 0 ? void 0 : editor.getHTML()) && !props.markdown) {
|
|
366
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value);
|
|
367
|
-
}
|
|
368
|
-
if (props.markdown && value !== markdownOutput.value) {
|
|
369
|
-
editor === null || editor === void 0 ? void 0 : editor.commands.setContent(markdownOutput.value);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
return {
|
|
373
|
-
editor,
|
|
374
|
-
editorRef,
|
|
375
|
-
containerRef,
|
|
376
|
-
toolbarButtonRef,
|
|
377
|
-
menuRef,
|
|
378
|
-
iconsEnum,
|
|
379
|
-
handleToolbarClick,
|
|
380
|
-
handleEditorClick,
|
|
381
|
-
isActive,
|
|
382
|
-
iconTooltipsEnum,
|
|
383
|
-
containerStyles,
|
|
384
|
-
toolbarContainerStyles,
|
|
385
|
-
toolbarStyles,
|
|
386
|
-
rootStyles,
|
|
387
|
-
toolbarButtonStyles,
|
|
388
|
-
editorInputStyles,
|
|
389
|
-
getIndexOfHeading,
|
|
390
|
-
headingLevels,
|
|
391
|
-
headingIcon
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
397
|
-
const _component_or_label = resolveComponent("or-label");
|
|
398
|
-
const _component_or_icon_button = resolveComponent("or-icon-button");
|
|
399
|
-
const _component_or_menu_item = resolveComponent("or-menu-item");
|
|
400
|
-
const _component_or_menu = resolveComponent("or-menu");
|
|
401
|
-
return openBlock(), createElementBlock("div", mergeProps({
|
|
402
|
-
ref: "root"
|
|
403
|
-
}, _ctx.$attrs, {
|
|
404
|
-
class: _ctx.rootStyles
|
|
405
|
-
}), [createVNode(_component_or_label, null, {
|
|
406
|
-
default: withCtx(() => [createTextVNode(toDisplayString(_ctx.description), 1 /* TEXT */)]),
|
|
407
|
-
|
|
408
|
-
_: 1 /* STABLE */
|
|
409
|
-
}), createElementVNode("div", {
|
|
410
|
-
ref: "containerRef",
|
|
411
|
-
class: normalizeClass(_ctx.containerStyles),
|
|
412
|
-
onClick: _cache[1] || (_cache[1] = $event => _ctx.handleEditorClick())
|
|
413
|
-
}, [createElementVNode("div", {
|
|
414
|
-
class: normalizeClass(_ctx.toolbarContainerStyles)
|
|
415
|
-
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.toolbar, tool => {
|
|
416
|
-
return openBlock(), createElementBlock("div", {
|
|
417
|
-
key: tool,
|
|
418
|
-
class: normalizeClass(_ctx.toolbarStyles)
|
|
419
|
-
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(tool, item => {
|
|
420
|
-
return openBlock(), createElementBlock("div", {
|
|
421
|
-
key: item,
|
|
422
|
-
class: normalizeClass([_ctx.toolbarButtonStyles(item), "-my-xs"])
|
|
423
|
-
}, [item === 'heading' ? (openBlock(), createBlock(_component_or_icon_button, {
|
|
424
|
-
key: 0,
|
|
425
|
-
ref_for: true,
|
|
426
|
-
ref: "toolbarButtonRef",
|
|
427
|
-
tooltip: {
|
|
428
|
-
text: item,
|
|
429
|
-
placement: 'top'
|
|
430
|
-
},
|
|
431
|
-
icon: {
|
|
432
|
-
icon: _ctx.headingIcon,
|
|
433
|
-
variant: 'inherit',
|
|
434
|
-
size: 'm'
|
|
435
|
-
},
|
|
436
|
-
onClick: _cache[0] || (_cache[0] = $event => _ctx.menuRef.open())
|
|
437
|
-
}, null, 8 /* PROPS */, ["tooltip", "icon"])) : (openBlock(), createBlock(_component_or_icon_button, {
|
|
438
|
-
key: 1,
|
|
439
|
-
tooltip: {
|
|
440
|
-
text: _ctx.iconTooltipsEnum[item],
|
|
441
|
-
placement: 'top'
|
|
442
|
-
},
|
|
443
|
-
icon: {
|
|
444
|
-
icon: _ctx.iconsEnum[item],
|
|
445
|
-
variant: 'inherit',
|
|
446
|
-
size: 'm'
|
|
447
|
-
},
|
|
448
|
-
onClick: $event => _ctx.handleToolbarClick(item)
|
|
449
|
-
}, null, 8 /* PROPS */, ["tooltip", "icon", "onClick"]))], 2 /* CLASS */);
|
|
450
|
-
}), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */);
|
|
451
|
-
}), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */), createElementVNode("div", {
|
|
452
|
-
ref: "editorRef",
|
|
453
|
-
class: normalizeClass(_ctx.editorInputStyles)
|
|
454
|
-
}, null, 2 /* CLASS */)], 2 /* CLASS */), _ctx.toolbarButtonRef ? (openBlock(), createBlock(_component_or_menu, {
|
|
455
|
-
key: 0,
|
|
456
|
-
ref: "menuRef",
|
|
457
|
-
trigger: _ctx.toolbarButtonRef[_ctx.getIndexOfHeading].root,
|
|
458
|
-
placement: "bottom-start"
|
|
459
|
-
}, {
|
|
460
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.headingLevels, heading => {
|
|
461
|
-
return openBlock(), createBlock(_component_or_menu_item, {
|
|
462
|
-
key: heading,
|
|
463
|
-
onClick: $event => _ctx.handleToolbarClick('heading', heading)
|
|
464
|
-
}, {
|
|
465
|
-
default: withCtx(() => [createTextVNode(" Heading " + toDisplayString(heading), 1 /* TEXT */)]),
|
|
466
|
-
|
|
467
|
-
_: 2 /* DYNAMIC */
|
|
468
|
-
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onClick"]);
|
|
469
|
-
}), 128 /* KEYED_FRAGMENT */)), createVNode(_component_or_menu_item, {
|
|
470
|
-
onClick: _cache[2] || (_cache[2] = $event => _ctx.handleToolbarClick('heading'))
|
|
471
|
-
}, {
|
|
472
|
-
default: withCtx(() => [createTextVNode(" None ")]),
|
|
473
|
-
_: 1 /* STABLE */
|
|
474
|
-
})]),
|
|
475
|
-
|
|
476
|
-
_: 1 /* STABLE */
|
|
477
|
-
}, 8 /* PROPS */, ["trigger"])) : createCommentVNode("v-if", true)], 16 /* FULL_PROPS */);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
var css_248z = ".tiptap-editor ol {\n margin: 0 24px;\n list-style: decimal;\n}\n.tiptap-editor ul {\n margin: 0 24px;\n list-style: initial;\n}\n.tiptap-editor .is-editor-empty::before {\n content: attr(data-placeholder);\n height: 0;\n pointer-events: none;\n float: left;\n}";
|
|
481
|
-
styleInject(css_248z);
|
|
482
|
-
|
|
483
|
-
script.render = render;
|
|
484
|
-
script.__file = "src/components/or-rich-text-editor-v3/OrRichTextEditor.vue";
|
|
485
|
-
|
|
486
|
-
export { script as s };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from '@storybook/vue3';
|
|
2
|
-
declare const _default: Meta<import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<unknown>, import("@vue/composition-api").MethodOptions, import("@vue/composition-api").ComputedOptions, import("@vue/composition-api").ComponentPropsOptions<import("@vue/composition-api").Data>, import("@vue/composition-api").ExtractPropTypes<import("@vue/composition-api").ComponentPropsOptions<import("@vue/composition-api").Data>>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{} & {}, import("@vue/composition-api").ShallowUnwrapRef<unknown>, unknown, import("@vue/composition-api").ComputedOptions, import("@vue/composition-api").MethodOptions, unknown, unknown, {
|
|
3
|
-
[x: string]: ((...args: any[]) => any) | null;
|
|
4
|
-
} | string[], {} & {}, {
|
|
5
|
-
[x: number]: string;
|
|
6
|
-
} | {}, true>)>;
|
|
7
|
-
export default _default;
|
|
8
|
-
export declare const RichTextEditor: StoryFn<import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<unknown>, import("@vue/composition-api").MethodOptions, import("@vue/composition-api").ComputedOptions, import("@vue/composition-api").ComponentPropsOptions<import("@vue/composition-api").Data>, import("@vue/composition-api").ExtractPropTypes<import("@vue/composition-api").ComponentPropsOptions<import("@vue/composition-api").Data>>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{} & {}, import("@vue/composition-api").ShallowUnwrapRef<unknown>, unknown, import("@vue/composition-api").ComputedOptions, import("@vue/composition-api").MethodOptions, unknown, unknown, {
|
|
9
|
-
[x: string]: ((...args: any[]) => any) | null;
|
|
10
|
-
} | string[], {} & {}, {
|
|
11
|
-
[x: number]: string;
|
|
12
|
-
} | {}, true>)>;
|