@bagelink/vue 0.0.356 → 0.0.360
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/components/Card.vue.d.ts +2 -2
- package/dist/components/form/inputs/RichText.vue.d.ts.map +1 -1
- package/dist/index.cjs +12 -3
- package/dist/index.mjs +13 -4
- package/dist/style.css +28 -22
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts +15 -5
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/form/inputs/RichText.vue +182 -161
- package/src/types/index.ts +12 -11
- package/src/utils/BagelFormUtils.ts +19 -6
|
@@ -4,14 +4,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
4
4
|
h100?: boolean | undefined;
|
|
5
5
|
overflowX?: boolean | undefined;
|
|
6
6
|
overflowY?: boolean | undefined;
|
|
7
|
-
bg?: "info" | "light" | "warning" | "
|
|
7
|
+
bg?: "info" | "light" | "warning" | "white" | "gray" | "primary" | "transparent" | "dark" | "secondary" | "success" | "danger" | undefined;
|
|
8
8
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
9
9
|
thin?: boolean | undefined;
|
|
10
10
|
outline?: boolean | undefined;
|
|
11
11
|
h100?: boolean | undefined;
|
|
12
12
|
overflowX?: boolean | undefined;
|
|
13
13
|
overflowY?: boolean | undefined;
|
|
14
|
-
bg?: "info" | "light" | "warning" | "
|
|
14
|
+
bg?: "info" | "light" | "warning" | "white" | "gray" | "primary" | "transparent" | "dark" | "secondary" | "success" | "danger" | undefined;
|
|
15
15
|
}>>>, {}, {}>, {
|
|
16
16
|
default?(_: {}): any;
|
|
17
17
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/RichText.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RichText.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/RichText.vue"],"names":[],"mappings":"AAcA;;gBAgQyD,MAAM;;;;gBAAN,MAAM;;;;AAL/D,wBAOG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -4928,7 +4928,7 @@ function slctField(id, label, options, config) {
|
|
|
4928
4928
|
required: config == null ? void 0 : config.required,
|
|
4929
4929
|
label,
|
|
4930
4930
|
defaultValue: config == null ? void 0 : config.defaultValue,
|
|
4931
|
-
attrs: { disabled: config == null ? void 0 : config.disabled }
|
|
4931
|
+
attrs: { disabled: config == null ? void 0 : config.disabled, searchable: config == null ? void 0 : config.searchable }
|
|
4932
4932
|
};
|
|
4933
4933
|
}
|
|
4934
4934
|
function numField(id, label, options) {
|
|
@@ -39216,13 +39216,22 @@ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
|
39216
39216
|
}
|
|
39217
39217
|
];
|
|
39218
39218
|
const emit2 = __emit;
|
|
39219
|
-
|
|
39219
|
+
function initEditor() {
|
|
39220
39220
|
editor.value = new Editor({
|
|
39221
39221
|
extensions: [StarterKit],
|
|
39222
39222
|
content: props2.modelValue,
|
|
39223
39223
|
onUpdate: ({ editor: editor2 }) => emit2("update:modelValue", editor2.getHTML())
|
|
39224
39224
|
});
|
|
39225
|
-
}
|
|
39225
|
+
}
|
|
39226
|
+
vue.watch(
|
|
39227
|
+
() => props2.modelValue,
|
|
39228
|
+
(value) => {
|
|
39229
|
+
var _a2;
|
|
39230
|
+
return (_a2 = editor.value) == null ? void 0 : _a2.commands.setContent(value);
|
|
39231
|
+
},
|
|
39232
|
+
{ immediate: true }
|
|
39233
|
+
);
|
|
39234
|
+
vue.onMounted(initEditor);
|
|
39226
39235
|
vue.onBeforeUnmount(() => {
|
|
39227
39236
|
var _a2;
|
|
39228
39237
|
return (_a2 = editor.value) == null ? void 0 : _a2.destroy();
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField2 = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { pushScopeId, popScopeId, defineComponent, nextTick, openBlock, createBlock, createElementBlock, normalizeClass, renderSlot, normalizeProps, guardReactiveProps, withScopeId, resolveComponent, normalizeStyle, withKeys, createElementVNode, Fragment as Fragment$1, createCommentVNode, mergeProps, withCtx, createVNode, ref, createApp, h as h$2, toDisplayString, inject, unref, renderList, resolveDynamicComponent, useCssVars, useSlots, computed, withModifiers, createTextVNode, watch, onMounted, onUnmounted, mergeModels, useModel, createSlots, Transition, reactive, provide, withDirectives, vModelCheckbox, toRef, isRef, Teleport, render as render$f, onBeforeUpdate, vShow, getCurrentScope, onScopeDispose, TransitionGroup, vModelDynamic, vModelText, vModelRadio, onBeforeUnmount,
|
|
7
|
+
import { pushScopeId, popScopeId, defineComponent, nextTick, openBlock, createBlock, createElementBlock, normalizeClass, renderSlot, normalizeProps, guardReactiveProps, withScopeId, resolveComponent, normalizeStyle, withKeys, createElementVNode, Fragment as Fragment$1, createCommentVNode, mergeProps, withCtx, createVNode, ref, createApp, h as h$2, toDisplayString, inject, unref, renderList, resolveDynamicComponent, useCssVars, useSlots, computed, withModifiers, createTextVNode, watch, onMounted, onUnmounted, mergeModels, useModel, createSlots, Transition, reactive, provide, withDirectives, vModelCheckbox, toRef, isRef, Teleport, render as render$f, onBeforeUpdate, vShow, getCurrentScope, onScopeDispose, TransitionGroup, vModelDynamic, vModelText, vModelRadio, onBeforeUnmount, getCurrentInstance, watchEffect, markRaw, customRef, resolveDirective } from "vue";
|
|
8
8
|
const sides = ["top", "right", "bottom", "left"];
|
|
9
9
|
const alignments = ["start", "end"];
|
|
10
10
|
const placements$1 = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
@@ -4926,7 +4926,7 @@ function slctField(id, label, options, config) {
|
|
|
4926
4926
|
required: config == null ? void 0 : config.required,
|
|
4927
4927
|
label,
|
|
4928
4928
|
defaultValue: config == null ? void 0 : config.defaultValue,
|
|
4929
|
-
attrs: { disabled: config == null ? void 0 : config.disabled }
|
|
4929
|
+
attrs: { disabled: config == null ? void 0 : config.disabled, searchable: config == null ? void 0 : config.searchable }
|
|
4930
4930
|
};
|
|
4931
4931
|
}
|
|
4932
4932
|
function numField(id, label, options) {
|
|
@@ -39214,13 +39214,22 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
39214
39214
|
}
|
|
39215
39215
|
];
|
|
39216
39216
|
const emit2 = __emit;
|
|
39217
|
-
|
|
39217
|
+
function initEditor() {
|
|
39218
39218
|
editor.value = new Editor({
|
|
39219
39219
|
extensions: [StarterKit],
|
|
39220
39220
|
content: props2.modelValue,
|
|
39221
39221
|
onUpdate: ({ editor: editor2 }) => emit2("update:modelValue", editor2.getHTML())
|
|
39222
39222
|
});
|
|
39223
|
-
}
|
|
39223
|
+
}
|
|
39224
|
+
watch(
|
|
39225
|
+
() => props2.modelValue,
|
|
39226
|
+
(value) => {
|
|
39227
|
+
var _a2;
|
|
39228
|
+
return (_a2 = editor.value) == null ? void 0 : _a2.commands.setContent(value);
|
|
39229
|
+
},
|
|
39230
|
+
{ immediate: true }
|
|
39231
|
+
);
|
|
39232
|
+
onMounted(initEditor);
|
|
39224
39233
|
onBeforeUnmount(() => {
|
|
39225
39234
|
var _a2;
|
|
39226
39235
|
return (_a2 = editor.value) == null ? void 0 : _a2.destroy();
|
package/dist/style.css
CHANGED
|
@@ -1622,12 +1622,12 @@ img.preview[data-v-1be8d7b1] {
|
|
|
1622
1622
|
}
|
|
1623
1623
|
|
|
1624
1624
|
/* Basic editor styles */
|
|
1625
|
-
.tiptap
|
|
1626
|
-
|
|
1625
|
+
.tiptap > * + * {
|
|
1626
|
+
margin-top: 0.75em;
|
|
1627
1627
|
}
|
|
1628
1628
|
.tiptap ul,
|
|
1629
1629
|
.tiptap ol {
|
|
1630
|
-
|
|
1630
|
+
padding: 0 1rem;
|
|
1631
1631
|
}
|
|
1632
1632
|
.tiptap h1,
|
|
1633
1633
|
.tiptap h2,
|
|
@@ -1635,37 +1635,43 @@ img.preview[data-v-1be8d7b1] {
|
|
|
1635
1635
|
.tiptap h4,
|
|
1636
1636
|
.tiptap h5,
|
|
1637
1637
|
.tiptap h6 {
|
|
1638
|
-
|
|
1638
|
+
line-height: 1.1;
|
|
1639
1639
|
}
|
|
1640
1640
|
.tiptap code {
|
|
1641
|
-
|
|
1642
|
-
|
|
1641
|
+
background-color: rgba(97, 97, 97, 0.1);
|
|
1642
|
+
color: #616161;
|
|
1643
1643
|
}
|
|
1644
1644
|
.tiptap pre {
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1645
|
+
background: #0d0d0d;
|
|
1646
|
+
color: #fff;
|
|
1647
|
+
font-family: 'JetBrainsMono', monospace;
|
|
1648
|
+
padding: 0.75rem 1rem;
|
|
1649
|
+
border-radius: 0.5rem;
|
|
1650
1650
|
}
|
|
1651
1651
|
.tiptap pre code {
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1652
|
+
color: inherit;
|
|
1653
|
+
padding: 0;
|
|
1654
|
+
background: none;
|
|
1655
|
+
font-size: 0.8rem;
|
|
1656
1656
|
}
|
|
1657
1657
|
.tiptap img {
|
|
1658
|
-
|
|
1659
|
-
|
|
1658
|
+
max-width: 100%;
|
|
1659
|
+
height: auto;
|
|
1660
1660
|
}
|
|
1661
1661
|
.tiptap blockquote {
|
|
1662
|
-
|
|
1663
|
-
|
|
1662
|
+
padding-left: 1rem;
|
|
1663
|
+
border-left: 2px solid rgba(13, 13, 13, 0.1);
|
|
1664
1664
|
}
|
|
1665
1665
|
.tiptap hr {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1666
|
+
border: none;
|
|
1667
|
+
border-top: 2px solid rgba(13, 13, 13, 0.1);
|
|
1668
|
+
margin: 2rem 0;
|
|
1669
|
+
}
|
|
1670
|
+
.tiptap {
|
|
1671
|
+
min-height: 500px;
|
|
1672
|
+
background: var(--input-bg);
|
|
1673
|
+
overflow: auto;
|
|
1674
|
+
max-height: 600px;
|
|
1669
1675
|
}
|
|
1670
1676
|
|
|
1671
1677
|
.chart-line {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export type Tab = {
|
|
|
11
11
|
id: string;
|
|
12
12
|
icon?: MaterialIcons;
|
|
13
13
|
} | string;
|
|
14
|
-
export type ThemeType = 'light' | 'red' | 'gray' | 'gray-light' | 'black' | 'green' | 'primary' | 'blue';
|
|
14
|
+
export type ThemeType = 'light' | 'white' | 'red' | 'gray' | 'gray-light' | 'black' | 'green' | 'primary' | 'blue';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA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@ export type Option = string | number | Record<string, any> | {
|
|
|
3
3
|
label: string;
|
|
4
4
|
value: string | number;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
interface InputOptions {
|
|
7
7
|
required?: boolean;
|
|
8
|
-
type?: 'text' | 'tel' | 'email';
|
|
9
8
|
placeholder?: string;
|
|
10
9
|
class?: string;
|
|
11
10
|
defaultValue?: string;
|
|
12
11
|
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface TextInputOptions extends InputOptions {
|
|
14
|
+
type?: 'text' | 'tel' | 'email';
|
|
13
15
|
pattern?: string;
|
|
14
|
-
}
|
|
16
|
+
}
|
|
17
|
+
interface SlctInputOptions extends InputOptions {
|
|
18
|
+
searchable?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface NumFieldOptions extends InputOptions {
|
|
21
|
+
max?: number;
|
|
22
|
+
min?: number;
|
|
23
|
+
step?: number;
|
|
24
|
+
}
|
|
15
25
|
export declare function txtField(id: string, label?: string, options?: TextInputOptions): Field;
|
|
16
|
-
export declare function slctField(id: string, label?: string, options?: Option[] | (() => Option[]), config?:
|
|
17
|
-
export declare function numField(id: string, label?: string, options?:
|
|
26
|
+
export declare function slctField(id: string, label?: string, options?: Option[] | (() => Option[]), config?: SlctInputOptions): Field;
|
|
27
|
+
export declare function numField(id: string, label?: string, options?: NumFieldOptions): Field;
|
|
18
28
|
export declare function frmRow(...children: Field[]): {
|
|
19
29
|
$el: string;
|
|
20
30
|
class: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BagelFormUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BagelFormUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAA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E,gBAAgB,GAAG,KAAK,CAY7H;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,KAAK,CAUrF;AAED,wBAAgB,MAAM,CAAC,GAAG,QAAQ,EAAE,KAAK,EAAE;;;;EAM1C"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<div v-if="editor">
|
|
3
|
+
<Btn
|
|
4
|
+
:flat="!editor.isActive(item.name, item.option)"
|
|
5
|
+
@click="item.command"
|
|
6
|
+
thin
|
|
7
|
+
v-for="item in config"
|
|
8
|
+
v-tooltip="item.name"
|
|
9
|
+
:key="item.name"
|
|
10
|
+
:icon="item.icon"
|
|
11
|
+
:disabled="item.disabled?.()" />
|
|
12
|
+
</div>
|
|
13
|
+
<editor-content :editor="editor" />
|
|
7
14
|
</template>
|
|
8
15
|
|
|
9
16
|
<script setup lang="ts">
|
|
10
17
|
import { Btn } from '@bagelink/vue';
|
|
11
|
-
import { onMounted, onBeforeUnmount } from 'vue';
|
|
18
|
+
import { onMounted, onBeforeUnmount, watch } from 'vue';
|
|
12
19
|
import StarterKit from '@tiptap/starter-kit';
|
|
13
20
|
import { Editor, EditorContent } from '@tiptap/vue-3';
|
|
14
21
|
import type { MaterialIcons } from '@bagelink/vue';
|
|
@@ -18,158 +25,165 @@ let editor = $ref<Editor>();
|
|
|
18
25
|
const props = defineProps<{ modelValue: string }>();
|
|
19
26
|
|
|
20
27
|
const focus = () => {
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
if (!editor) throw new Error('editor is not defined');
|
|
29
|
+
return editor.chain().focus();
|
|
23
30
|
};
|
|
24
31
|
|
|
25
|
-
const config: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
32
|
+
const config: {
|
|
33
|
+
name: string;
|
|
34
|
+
command: any;
|
|
35
|
+
icon: MaterialIcons;
|
|
36
|
+
option?: Record<string, any>;
|
|
37
|
+
disabled?: () => boolean;
|
|
38
|
+
}[] = [
|
|
39
|
+
{
|
|
40
|
+
name: 'bold',
|
|
41
|
+
command: () => focus()?.toggleBold().run(),
|
|
42
|
+
icon: 'format_bold',
|
|
43
|
+
disabled: () => !editor?.can().chain().focus().toggleBold().run(),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'italic',
|
|
47
|
+
command: () => focus().toggleItalic().run(),
|
|
48
|
+
icon: 'format_italic',
|
|
49
|
+
disabled: () => !editor?.can().chain().focus().toggleItalic().run(),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'strike',
|
|
53
|
+
command: () => focus().toggleStrike().run(),
|
|
54
|
+
icon: 'format_strikethrough',
|
|
55
|
+
disabled: () => !editor?.can().chain().focus().toggleStrike().run(),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'code',
|
|
59
|
+
command: () => focus().toggleCode().run(),
|
|
60
|
+
icon: 'code',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'clearMarks',
|
|
64
|
+
command: () => focus().unsetAllMarks(),
|
|
65
|
+
icon: 'clear',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'clearNodes',
|
|
69
|
+
command: () => focus().clearNodes().run(),
|
|
70
|
+
icon: 'clear',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'paragraph',
|
|
74
|
+
command: () => focus().setParagraph().run(),
|
|
75
|
+
icon: 'format_paragraph',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'heading',
|
|
79
|
+
command: () => focus().toggleHeading({ level: 1 }).run(),
|
|
80
|
+
icon: 'format_h1',
|
|
81
|
+
option: { level: 1 },
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'heading',
|
|
85
|
+
command: () => focus().toggleHeading({ level: 2 }).run(),
|
|
86
|
+
icon: 'format_h2',
|
|
87
|
+
option: { level: 2 },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'heading',
|
|
91
|
+
command: () => focus().toggleHeading({ level: 3 }).run(),
|
|
92
|
+
icon: 'format_h3',
|
|
93
|
+
option: { level: 3 },
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'heading',
|
|
97
|
+
command: () => focus().toggleHeading({ level: 4 }).run(),
|
|
98
|
+
icon: 'format_h4',
|
|
99
|
+
option: { level: 4 },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'heading',
|
|
103
|
+
command: () => focus().toggleHeading({ level: 5 }).run(),
|
|
104
|
+
icon: 'format_h5',
|
|
105
|
+
option: { level: 5 },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'heading',
|
|
109
|
+
command: () => focus().toggleHeading({ level: 6 }).run(),
|
|
110
|
+
icon: 'format_h6',
|
|
111
|
+
option: { level: 6 },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'bulletList',
|
|
115
|
+
command: () => focus().toggleBulletList().run(),
|
|
116
|
+
icon: 'format_list_bulleted',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'orderedList',
|
|
120
|
+
command: () => focus().toggleOrderedList().run(),
|
|
121
|
+
icon: 'format_list_numbered',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'codeBlock',
|
|
125
|
+
command: () => focus().toggleCodeBlock().run(),
|
|
126
|
+
icon: 'code',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'blockquote',
|
|
130
|
+
command: () => focus().toggleBlockquote().run(),
|
|
131
|
+
icon: 'format_quote',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'horizontalRule',
|
|
135
|
+
command: () => focus().setHorizontalRule().run(),
|
|
136
|
+
icon: 'horizontal_rule',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'hardBreak',
|
|
140
|
+
command: () => focus().setHardBreak().run(),
|
|
141
|
+
icon: 'keyboard_return',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'undo',
|
|
145
|
+
command: () => focus().undo().run(),
|
|
146
|
+
icon: 'undo',
|
|
147
|
+
disabled: () => !editor?.can().chain().focus().undo().run(),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'redo',
|
|
151
|
+
command: () => focus().redo().run(),
|
|
152
|
+
icon: 'redo',
|
|
153
|
+
disabled: () => !editor?.can().chain().focus().redo().run(),
|
|
154
|
+
},
|
|
149
155
|
];
|
|
150
156
|
|
|
151
157
|
const emit = defineEmits(['update:modelValue']);
|
|
152
158
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
159
|
+
function initEditor() {
|
|
160
|
+
editor = new Editor({
|
|
161
|
+
extensions: [StarterKit],
|
|
162
|
+
content: props.modelValue,
|
|
163
|
+
onUpdate: ({ editor }) => emit('update:modelValue', editor.getHTML()),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
watch(
|
|
168
|
+
() => props.modelValue,
|
|
169
|
+
(value) => editor?.commands.setContent(value),
|
|
170
|
+
{ immediate: true }
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
onMounted(initEditor);
|
|
160
174
|
|
|
161
175
|
onBeforeUnmount(() => editor?.destroy());
|
|
162
176
|
</script>
|
|
163
177
|
|
|
164
178
|
<style>
|
|
165
179
|
/* Basic editor styles */
|
|
166
|
-
.tiptap
|
|
167
|
-
|
|
180
|
+
.tiptap > * + * {
|
|
181
|
+
margin-top: 0.75em;
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
.tiptap ul,
|
|
171
185
|
.tiptap ol {
|
|
172
|
-
|
|
186
|
+
padding: 0 1rem;
|
|
173
187
|
}
|
|
174
188
|
|
|
175
189
|
.tiptap h1,
|
|
@@ -178,42 +192,49 @@ onBeforeUnmount(() => editor?.destroy());
|
|
|
178
192
|
.tiptap h4,
|
|
179
193
|
.tiptap h5,
|
|
180
194
|
.tiptap h6 {
|
|
181
|
-
|
|
195
|
+
line-height: 1.1;
|
|
182
196
|
}
|
|
183
197
|
|
|
184
198
|
.tiptap code {
|
|
185
|
-
|
|
186
|
-
|
|
199
|
+
background-color: rgba(97, 97, 97, 0.1);
|
|
200
|
+
color: #616161;
|
|
187
201
|
}
|
|
188
202
|
|
|
189
203
|
.tiptap pre {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
background: #0d0d0d;
|
|
205
|
+
color: #fff;
|
|
206
|
+
font-family: 'JetBrainsMono', monospace;
|
|
207
|
+
padding: 0.75rem 1rem;
|
|
208
|
+
border-radius: 0.5rem;
|
|
195
209
|
}
|
|
196
210
|
|
|
197
211
|
.tiptap pre code {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
color: inherit;
|
|
213
|
+
padding: 0;
|
|
214
|
+
background: none;
|
|
215
|
+
font-size: 0.8rem;
|
|
202
216
|
}
|
|
203
217
|
|
|
204
218
|
.tiptap img {
|
|
205
|
-
|
|
206
|
-
|
|
219
|
+
max-width: 100%;
|
|
220
|
+
height: auto;
|
|
207
221
|
}
|
|
208
222
|
|
|
209
223
|
.tiptap blockquote {
|
|
210
|
-
|
|
211
|
-
|
|
224
|
+
padding-left: 1rem;
|
|
225
|
+
border-left: 2px solid rgba(13, 13, 13, 0.1);
|
|
212
226
|
}
|
|
213
227
|
|
|
214
228
|
.tiptap hr {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
229
|
+
border: none;
|
|
230
|
+
border-top: 2px solid rgba(13, 13, 13, 0.1);
|
|
231
|
+
margin: 2rem 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.tiptap {
|
|
235
|
+
min-height: 500px;
|
|
236
|
+
background: var(--input-bg);
|
|
237
|
+
overflow: auto;
|
|
238
|
+
max-height: 600px;
|
|
218
239
|
}
|
|
219
240
|
</style>
|
package/src/types/index.ts
CHANGED
|
@@ -13,17 +13,18 @@ export * from './BtnOptions';
|
|
|
13
13
|
export * from './BagelForm';
|
|
14
14
|
|
|
15
15
|
export type Tab = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
label: string;
|
|
17
|
+
id: string;
|
|
18
|
+
icon?: MaterialIcons;
|
|
19
19
|
} | string
|
|
20
20
|
|
|
21
21
|
export type ThemeType = |
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
'light'
|
|
23
|
+
| 'white'
|
|
24
|
+
| 'red'
|
|
25
|
+
| 'gray'
|
|
26
|
+
| 'gray-light'
|
|
27
|
+
| 'black'
|
|
28
|
+
| 'green'
|
|
29
|
+
| 'primary'
|
|
30
|
+
| 'blue' // ! blue does nothing
|
|
@@ -2,16 +2,29 @@ import type { Field } from '@bagelink/vue';
|
|
|
2
2
|
|
|
3
3
|
export type Option = string | number | Record<string, any> | { label: string, value: string | number };
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface InputOptions {
|
|
6
6
|
required?: boolean;
|
|
7
|
-
type?: 'text' | 'tel' | 'email';
|
|
8
7
|
placeholder?: string;
|
|
9
|
-
class?: string
|
|
8
|
+
class?: string;
|
|
10
9
|
defaultValue?: string;
|
|
11
10
|
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface TextInputOptions extends InputOptions {
|
|
14
|
+
type?: 'text' | 'tel' | 'email';
|
|
12
15
|
pattern?: string;
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
interface SlctInputOptions extends InputOptions {
|
|
19
|
+
searchable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface NumFieldOptions extends InputOptions {
|
|
23
|
+
max?: number;
|
|
24
|
+
min?: number;
|
|
25
|
+
step?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
export function txtField(id: string, label?: string, options?: TextInputOptions): Field {
|
|
16
29
|
return {
|
|
17
30
|
$el: 'text',
|
|
@@ -24,7 +37,7 @@ export function txtField(id: string, label?: string, options?: TextInputOptions)
|
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
39
|
|
|
27
|
-
export function slctField(id: string, label?: string, options?: Option[] | (() => Option[]), config?:
|
|
40
|
+
export function slctField(id: string, label?: string, options?: Option[] | (() => Option[]), config?: SlctInputOptions): Field {
|
|
28
41
|
return {
|
|
29
42
|
$el: 'select',
|
|
30
43
|
id,
|
|
@@ -34,11 +47,11 @@ export function slctField(id: string, label?: string, options?: Option[] | (() =
|
|
|
34
47
|
required: config?.required,
|
|
35
48
|
label,
|
|
36
49
|
defaultValue: config?.defaultValue,
|
|
37
|
-
attrs: { disabled: config?.disabled },
|
|
50
|
+
attrs: { disabled: config?.disabled, searchable: config?.searchable },
|
|
38
51
|
};
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
export function numField(id: string, label?: string, options?:
|
|
54
|
+
export function numField(id: string, label?: string, options?: NumFieldOptions): Field {
|
|
42
55
|
return {
|
|
43
56
|
$el: 'text',
|
|
44
57
|
class: options?.class,
|