@onereach/ui-components 2.63.0-beta.1907.0 → 2.63.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-8d149ece.js → OrConfirm-24e2a1a2.js} +1 -1
- package/dist/v2/{OrIconButton-5883eba0.js → OrIconButton-2088a37f.js} +1 -1
- package/dist/v2/{OrInlineInput-16a343c1.js → OrInlineInput-f00cba5e.js} +6 -5
- package/dist/v2/{OrInlineTextarea-f154bdf5.js → OrInlineTextarea-75de33d0.js} +6 -5
- package/dist/v2/{OrInput-4a50fe57.js → OrInput-24028f23.js} +7 -5
- package/dist/v2/{OrModal-64c5ae2e.js → OrModal-a1452b11.js} +1 -1
- package/dist/v2/{OrNotification-9c164908.js → OrNotification-ac420f39.js} +1 -1
- package/dist/v2/{OrSearch-a247f072.js → OrSearch-978a3a6e.js} +1 -1
- package/dist/v2/OrSegmentedControl-17df63b8.js +236 -0
- package/dist/v2/{OrSelect-f416b7aa.js → OrSelect-c6d0a69e.js} +2 -2
- package/dist/v2/{OrTabs-b4a9740b.js → OrTabs-f2a60b41.js} +1 -1
- package/dist/v2/{OrTag-ab03c4f7.js → OrTag-1ced4e58.js} +1 -1
- package/dist/v2/{OrTooltip-caeac590.js → OrTooltip-afe7030b.js} +33 -3
- package/dist/v2/components/index.d.ts +1 -0
- package/dist/v2/components/{or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts → or-segmented-control-v3/OrSegmentedControl.stories3.d.ts} +1 -1
- package/dist/v2/components/or-segmented-control-v3/OrSegmentedControl.vue.d.ts +77 -0
- package/dist/v2/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue.d.ts +47 -0
- package/dist/v2/components/or-segmented-control-v3/components/or-segmented-control-item/styles.d.ts +3 -0
- package/dist/v2/components/or-segmented-control-v3/index.d.ts +3 -0
- package/dist/v2/components/or-segmented-control-v3/props.d.ts +4 -0
- package/dist/v2/components/or-segmented-control-v3/styles.d.ts +3 -0
- package/dist/v2/components/or-segmented-control-v3/types.d.ts +4 -0
- package/dist/v2/components/or-tooltip-v3/styles.d.ts +2 -0
- package/dist/v2/index.js +14 -13
- package/dist/v2/index2.js +14 -13
- 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 +12 -325
- package/dist/v2/index63.js +2 -19
- package/dist/v2/index65.js +5 -5
- package/dist/v2/index78.js +1 -1
- package/dist/v2/index80.js +3 -3
- package/dist/v2/index88.js +3 -3
- package/dist/v2/index91.js +1 -1
- package/dist/v2/{types-fb93ea4e.js → types-89aad7fb.js} +1 -1
- package/dist/v3/{OrConfirm-456ddee1.js → OrConfirm-371630a4.js} +1 -1
- package/dist/v3/{OrIconButton-b8066b5d.js → OrIconButton-5fb3a9aa.js} +1 -1
- package/dist/v3/{OrInlineInput-280768ba.js → OrInlineInput-bac4abdd.js} +4 -3
- package/dist/v3/{OrInlineTextarea-0f63f344.js → OrInlineTextarea-d1ec1bba.js} +4 -3
- package/dist/v3/{OrInput-3eef7945.js → OrInput-256d2530.js} +6 -3
- package/dist/v3/{OrModal-f67d37d3.js → OrModal-3a43b7e7.js} +1 -1
- package/dist/v3/{OrNotification-fefa1cb4.js → OrNotification-433d16f7.js} +1 -1
- package/dist/v3/{OrSearch-15a70678.js → OrSearch-375eab55.js} +1 -1
- package/dist/v3/OrSegmentedControl-2bbc0f22.js +184 -0
- package/dist/v3/{OrSelect-9d300f55.js → OrSelect-52cfb10d.js} +2 -2
- package/dist/v3/{OrTabs-194ca950.js → OrTabs-ac0be933.js} +1 -1
- package/dist/v3/{OrTag-144b4ab8.js → OrTag-deaff080.js} +1 -1
- package/dist/v3/{OrTooltip-30e05f9e.js → OrTooltip-36c6728c.js} +33 -3
- package/dist/v3/components/index.d.ts +1 -0
- package/dist/v3/components/{or-rich-text-editor-v3/OrRichTextEditor.stories3.d.ts → or-segmented-control-v3/OrSegmentedControl.stories3.d.ts} +1 -1
- package/dist/v3/components/or-segmented-control-v3/OrSegmentedControl.vue.d.ts +77 -0
- package/dist/v3/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue.d.ts +47 -0
- package/dist/v3/components/or-segmented-control-v3/components/or-segmented-control-item/styles.d.ts +3 -0
- package/dist/v3/components/or-segmented-control-v3/index.d.ts +3 -0
- package/dist/v3/components/or-segmented-control-v3/props.d.ts +4 -0
- package/dist/v3/components/or-segmented-control-v3/styles.d.ts +3 -0
- package/dist/v3/components/or-segmented-control-v3/types.d.ts +4 -0
- package/dist/v3/components/or-tooltip-v3/styles.d.ts +2 -0
- package/dist/v3/index.js +14 -13
- package/dist/v3/index2.js +14 -13
- 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 +12 -299
- package/dist/v3/index63.js +2 -18
- package/dist/v3/index65.js +5 -5
- package/dist/v3/index78.js +1 -1
- package/dist/v3/index80.js +3 -3
- package/dist/v3/index88.js +3 -3
- package/dist/v3/index91.js +1 -1
- package/dist/v3/{types-a2a8f948.js → types-d5d4ab32.js} +1 -1
- package/package.json +4 -9
- package/src/components/index.ts +1 -0
- package/src/components/or-checkbox-v3/OrCheckbox.stories3.ts +1 -1
- package/src/components/or-inline-input-v3/OrInlineInput.vue +2 -2
- package/src/components/or-inline-textarea-v3/OrInlineTextarea.vue +2 -2
- package/src/components/or-input-v3/OrInput.vue +21 -19
- package/src/components/or-radio-v3/OrRadio.stories3.ts +1 -1
- package/src/components/or-segmented-control-v3/OrSegmentedControl.docs.mdx +7 -0
- package/src/components/or-segmented-control-v3/OrSegmentedControl.stories3.ts +106 -0
- package/src/components/or-segmented-control-v3/OrSegmentedControl.vue +107 -0
- package/src/components/or-segmented-control-v3/components/or-segmented-control-item/OrSegmentedControlItem.vue +64 -0
- package/src/components/or-segmented-control-v3/components/or-segmented-control-item/styles.ts +50 -0
- package/src/components/or-segmented-control-v3/index.ts +3 -0
- package/src/components/or-segmented-control-v3/props.ts +4 -0
- package/src/components/or-segmented-control-v3/styles.ts +24 -0
- package/src/components/or-segmented-control-v3/types.ts +4 -0
- package/src/components/or-switch-v3/OrSwitch.stories3.ts +1 -1
- package/src/components/or-tabs-v3/OrTabs.stories3.ts +9 -4
- package/src/components/or-tabs-v3/OrTabs.vue +1 -1
- package/src/components/or-tooltip-v3/OrTooltip.vue +3 -2
- package/src/components/or-tooltip-v3/styles.ts +55 -0
- package/src/hooks/useClassAttribute.ts +1 -1
- package/dist/v2/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -111
- package/dist/v2/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/v2/components/or-rich-text-editor-v3/styles.d.ts +0 -7
- package/dist/v3/components/or-rich-text-editor-v3/OrRichTextEditor.vue.d.ts +0 -111
- package/dist/v3/components/or-rich-text-editor-v3/index.d.ts +0 -1
- package/dist/v3/components/or-rich-text-editor-v3/styles.d.ts +0 -7
- 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 -57
- package/src/components/or-rich-text-editor-v3/OrRichTextEditor.vue +0 -322
- package/src/components/or-rich-text-editor-v3/index.ts +0 -1
- package/src/components/or-rich-text-editor-v3/styles.ts +0 -71
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core';
|
|
2
|
-
declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
3
|
-
editor: Editor | null;
|
|
4
|
-
editorRef: import("@vue/composition-api").Ref<HTMLDivElement | undefined>;
|
|
5
|
-
containerRef: import("@vue/composition-api").Ref<HTMLDivElement | undefined>;
|
|
6
|
-
iconsEnum: import("@vue/composition-api").Ref<{
|
|
7
|
-
[x: string]: string;
|
|
8
|
-
}>;
|
|
9
|
-
handleToolbarClick: (item: string) => void;
|
|
10
|
-
handleEditorClick: () => void;
|
|
11
|
-
isActive: import("@vue/composition-api").Ref<{
|
|
12
|
-
[x: string]: boolean;
|
|
13
|
-
}>;
|
|
14
|
-
iconTooltipsEnum: import("@vue/composition-api").Ref<{
|
|
15
|
-
[x: string]: string;
|
|
16
|
-
}>;
|
|
17
|
-
containerStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
18
|
-
toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
19
|
-
toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
20
|
-
rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
|
|
21
|
-
toolbarButtonStyles: (item: string) => string[];
|
|
22
|
-
editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
23
|
-
}> & import("@vue/composition-api").Data, {}, {}, {
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: StringConstructor;
|
|
26
|
-
default: string;
|
|
27
|
-
required: false;
|
|
28
|
-
};
|
|
29
|
-
toolbar: {
|
|
30
|
-
type: ArrayConstructor;
|
|
31
|
-
default: () => string[][];
|
|
32
|
-
};
|
|
33
|
-
description: {
|
|
34
|
-
type: StringConstructor;
|
|
35
|
-
default: string;
|
|
36
|
-
};
|
|
37
|
-
placeholder: {
|
|
38
|
-
type: StringConstructor;
|
|
39
|
-
default: string;
|
|
40
|
-
};
|
|
41
|
-
autofocus: {
|
|
42
|
-
type: BooleanConstructor;
|
|
43
|
-
default: boolean;
|
|
44
|
-
};
|
|
45
|
-
}, import("@vue/composition-api").ExtractPropTypes<{
|
|
46
|
-
modelValue: {
|
|
47
|
-
type: StringConstructor;
|
|
48
|
-
default: string;
|
|
49
|
-
required: false;
|
|
50
|
-
};
|
|
51
|
-
toolbar: {
|
|
52
|
-
type: ArrayConstructor;
|
|
53
|
-
default: () => string[][];
|
|
54
|
-
};
|
|
55
|
-
description: {
|
|
56
|
-
type: StringConstructor;
|
|
57
|
-
default: string;
|
|
58
|
-
};
|
|
59
|
-
placeholder: {
|
|
60
|
-
type: StringConstructor;
|
|
61
|
-
default: string;
|
|
62
|
-
};
|
|
63
|
-
autofocus: {
|
|
64
|
-
type: BooleanConstructor;
|
|
65
|
-
default: boolean;
|
|
66
|
-
};
|
|
67
|
-
}>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
68
|
-
modelValue: string;
|
|
69
|
-
toolbar: unknown[];
|
|
70
|
-
description: string;
|
|
71
|
-
placeholder: string;
|
|
72
|
-
autofocus: boolean;
|
|
73
|
-
} & {} & {
|
|
74
|
-
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
75
|
-
}, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
76
|
-
editor: Editor | null;
|
|
77
|
-
editorRef: import("@vue/composition-api").Ref<HTMLDivElement | undefined>;
|
|
78
|
-
containerRef: import("@vue/composition-api").Ref<HTMLDivElement | undefined>;
|
|
79
|
-
iconsEnum: import("@vue/composition-api").Ref<{
|
|
80
|
-
[x: string]: string;
|
|
81
|
-
}>;
|
|
82
|
-
handleToolbarClick: (item: string) => void;
|
|
83
|
-
handleEditorClick: () => void;
|
|
84
|
-
isActive: import("@vue/composition-api").Ref<{
|
|
85
|
-
[x: string]: boolean;
|
|
86
|
-
}>;
|
|
87
|
-
iconTooltipsEnum: import("@vue/composition-api").Ref<{
|
|
88
|
-
[x: string]: string;
|
|
89
|
-
}>;
|
|
90
|
-
containerStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
91
|
-
toolbarContainerStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
92
|
-
toolbarStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
93
|
-
rootStyles: import("@vue/composition-api").ComputedRef<(string | undefined)[]>;
|
|
94
|
-
toolbarButtonStyles: (item: string) => string[];
|
|
95
|
-
editorInputStyles: import("@vue/composition-api").ComputedRef<string[]>;
|
|
96
|
-
}>, import("@vue/composition-api").Data, {}, {}, {}, {}, string[], {
|
|
97
|
-
modelValue: string;
|
|
98
|
-
toolbar: unknown[];
|
|
99
|
-
description: string;
|
|
100
|
-
placeholder: string;
|
|
101
|
-
autofocus: boolean;
|
|
102
|
-
} & {} & {
|
|
103
|
-
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
104
|
-
}, {
|
|
105
|
-
modelValue: string;
|
|
106
|
-
toolbar: unknown[];
|
|
107
|
-
description: string;
|
|
108
|
-
placeholder: string;
|
|
109
|
-
autofocus: boolean;
|
|
110
|
-
}, true>);
|
|
111
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as OrRichTextEditor } from './OrRichTextEditor.vue';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const EditorContainer: string[];
|
|
2
|
-
export declare const EditorContainerFilled: string[];
|
|
3
|
-
export declare const ToolbarContainer: string[];
|
|
4
|
-
export declare const Toolbar: string[];
|
|
5
|
-
export declare const ToolbarButton: string[];
|
|
6
|
-
export declare const ToolbarButtonActive: string[];
|
|
7
|
-
export declare const EditorInput: string[];
|
|
@@ -1,16 +0,0 @@
|
|
|
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 />
|
|
@@ -1,57 +0,0 @@
|
|
|
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({});
|
|
@@ -1,322 +0,0 @@
|
|
|
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'], ['link'], ['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
|
-
autolink: false,
|
|
152
|
-
protocols: ['ftp', 'mailto', 'http', 'https'],
|
|
153
|
-
validate: href => /^https?:\/\//.test(href),
|
|
154
|
-
HTMLAttributes: {
|
|
155
|
-
class: 'text-primary cursor-pointer',
|
|
156
|
-
},
|
|
157
|
-
}),
|
|
158
|
-
Highlight,
|
|
159
|
-
Placeholder
|
|
160
|
-
.configure({
|
|
161
|
-
placeholder: props.placeholder,
|
|
162
|
-
emptyEditorClass: 'is-editor-empty text-outline',
|
|
163
|
-
}),
|
|
164
|
-
],
|
|
165
|
-
editorProps: {
|
|
166
|
-
attributes: {
|
|
167
|
-
class: 'focus:outline-none',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
setActiveFormats();
|
|
172
|
-
isFilled.value = props.modelValue !== '';
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
onBeforeUnmount(() => {
|
|
176
|
-
editor?.destroy();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// Methods
|
|
180
|
-
const handleEditorClick = () => {
|
|
181
|
-
setActiveFormats();
|
|
182
|
-
editor?.commands.focus();
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const handleToolbarClick = (item: string) => {
|
|
186
|
-
if (item === 'bulletList' || item === 'orderedList') {
|
|
187
|
-
item === 'bulletList' ? editor?.commands.toggleBulletList() : editor?.commands.toggleOrderedList();
|
|
188
|
-
}
|
|
189
|
-
else if (item === 'link') {
|
|
190
|
-
setLink();
|
|
191
|
-
}
|
|
192
|
-
else if (item === 'undo' || item === 'redo') {
|
|
193
|
-
item === 'undo' ? editor?.commands.undo() : editor?.commands.redo();
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
editor?.chain().focus().toggleMark(item).run();
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const setLink = () => {
|
|
201
|
-
const previousUrl = editor?.getAttributes('link').href;
|
|
202
|
-
const url = window.prompt('URL', previousUrl);
|
|
203
|
-
|
|
204
|
-
// cancelled
|
|
205
|
-
if (url === null) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// empty
|
|
210
|
-
if (url === '') {
|
|
211
|
-
editor?.chain().focus().extendMarkRange('link').unsetLink().run();
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// update link
|
|
216
|
-
editor?.chain()
|
|
217
|
-
.focus()
|
|
218
|
-
.extendMarkRange('link')
|
|
219
|
-
.setLink({ href: url })
|
|
220
|
-
.run();
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const setActiveFormats = () => {
|
|
224
|
-
const toolbarList = flatMap(props.toolbar) as string[];
|
|
225
|
-
toolbarList.forEach((item) => {
|
|
226
|
-
isActive.value[item] = editor?.isActive(item) || false;
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
// Styles
|
|
231
|
-
const classAttribute = useClassAttribute();
|
|
232
|
-
|
|
233
|
-
const rootStyles = computed(() => {
|
|
234
|
-
return [
|
|
235
|
-
'or-rich-text-editor',
|
|
236
|
-
classAttribute.value,
|
|
237
|
-
];
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
const containerStyles = computed(() => {
|
|
241
|
-
return [
|
|
242
|
-
...EditorContainer,
|
|
243
|
-
...(isFilled.value ? EditorContainerFilled : []),
|
|
244
|
-
];
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
const toolbarContainerStyles = computed(() => {
|
|
248
|
-
return [
|
|
249
|
-
...ToolbarContainer,
|
|
250
|
-
];
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
const toolbarStyles = computed(() => {
|
|
254
|
-
return [
|
|
255
|
-
...Toolbar,
|
|
256
|
-
];
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const editorInputStyles = computed(() => {
|
|
260
|
-
return [
|
|
261
|
-
'tiptap-editor',
|
|
262
|
-
...EditorInput,
|
|
263
|
-
];
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
const toolbarButtonStyles = (item: string) => {
|
|
267
|
-
return [
|
|
268
|
-
// Layout
|
|
269
|
-
'flex',
|
|
270
|
-
// Spacing
|
|
271
|
-
'gap-md',
|
|
272
|
-
...isActive.value[item] ? ToolbarButtonActive : ToolbarButton,
|
|
273
|
-
];
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
//Effects
|
|
277
|
-
watch(() => props.modelValue, (value) => {
|
|
278
|
-
if (value !== editor?.getHTML()) {
|
|
279
|
-
editor?.commands.setContent(value);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
return {
|
|
284
|
-
editor,
|
|
285
|
-
editorRef,
|
|
286
|
-
containerRef,
|
|
287
|
-
iconsEnum,
|
|
288
|
-
handleToolbarClick,
|
|
289
|
-
handleEditorClick,
|
|
290
|
-
isActive,
|
|
291
|
-
iconTooltipsEnum,
|
|
292
|
-
containerStyles,
|
|
293
|
-
toolbarContainerStyles,
|
|
294
|
-
toolbarStyles,
|
|
295
|
-
rootStyles,
|
|
296
|
-
toolbarButtonStyles,
|
|
297
|
-
editorInputStyles,
|
|
298
|
-
};
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
</script>
|
|
302
|
-
|
|
303
|
-
<style lang="scss">
|
|
304
|
-
.tiptap-editor {
|
|
305
|
-
ol { //see if editor can not inherit it
|
|
306
|
-
margin: 0 24px;
|
|
307
|
-
list-style: decimal;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
ul {
|
|
311
|
-
margin: 0 24px;
|
|
312
|
-
list-style: initial;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
.is-editor-empty::before {
|
|
316
|
-
content: attr(data-placeholder);
|
|
317
|
-
height: 0;
|
|
318
|
-
pointer-events: none;
|
|
319
|
-
float: left;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as OrRichTextEditor } from './OrRichTextEditor.vue';
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
];
|