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