@fastkit/vui 0.12.8 → 0.12.10
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/LICENSE +1 -1
- package/dist/vui.css +2522 -2723
- package/dist/vui.css.map +1 -0
- package/dist/vui.d.ts +8760 -10172
- package/dist/vui.mjs +1704 -2490
- package/dist/vui.mjs.map +1 -0
- package/package.json +69 -61
- package/src/components/VApp/VApp.tsx +3 -1
- package/src/components/VAvatar/VAvatar.scss +62 -60
- package/src/components/VAvatar/VAvatar.tsx +6 -1
- package/src/components/VBreadcrumbs/VBreadcrumbs.scss +53 -51
- package/src/components/VBusyImage/VBusyImage.scss +50 -51
- package/src/components/VButton/VButton.scss +120 -118
- package/src/components/VButton/VButton.tsx +6 -1
- package/src/components/VButton/VButtonGroup.scss +21 -19
- package/src/components/VCard/VCard.scss +41 -42
- package/src/components/VCard/VCard.tsx +5 -0
- package/src/components/VCard/VCardActions.scss +9 -7
- package/src/components/VCard/VCardContent.scss +4 -2
- package/src/components/VCheckable/VCheckable.scss +79 -80
- package/src/components/VCheckable/VCheckable.tsx +1 -1
- package/src/components/VCheckbox/VCheckbox.scss +50 -48
- package/src/components/VCheckbox/VCheckbox.tsx +2 -2
- package/src/components/VChip/VChip.scss +61 -59
- package/src/components/VChip/VChip.tsx +6 -1
- package/src/components/VContentSwitcher/VContentSwitcher.scss +52 -50
- package/src/components/VControlField/VControlField.scss +148 -146
- package/src/components/VControlField/VControlField.tsx +3 -3
- package/src/components/VDataTable/VDataTable.scss +167 -168
- package/src/components/VDrawerLayout/VDrawerLayout.scss +27 -25
- package/src/components/VForm/VForm.tsx +3 -4
- package/src/components/VFormControl/VFormControl.scss +84 -82
- package/src/components/VFormControl/VFormControl.tsx +2 -3
- package/src/components/VGrid/VGridContainer.scss +5 -3
- package/src/components/VGrid/VGridItem.scss +4 -2
- package/src/components/VHero/VHero.scss +23 -21
- package/src/components/VIcon/VIcon.scss +19 -17
- package/src/components/VListTile/VListTile.scss +60 -58
- package/src/components/VListTile/VListTile.tsx +5 -0
- package/src/components/VNavigation/VNavigation.scss +12 -10
- package/src/components/VNavigation/VNavigationItem.scss +21 -19
- package/src/components/VNavigation/VNavigationItem.tsx +5 -0
- package/src/components/VOption/VOption.scss +55 -56
- package/src/components/VOption/VOption.tsx +2 -2
- package/src/components/VOptionGroup/VOptionGroup.scss +14 -12
- package/src/components/VOptionGroup/VOptionGroup.tsx +3 -1
- package/src/components/VPagination/VPagination.scss +81 -79
- package/src/components/VPagination/VPagination.tsx +1 -1
- package/src/components/VPaper/VPaper.scss +43 -41
- package/src/components/VRadio/VRadio.scss +52 -53
- package/src/components/VRadio/VRadio.tsx +2 -2
- package/src/components/VSelect/VSelect.scss +77 -75
- package/src/components/VSelect/VSelect.tsx +5 -2
- package/src/components/VSkeltonLoader/VSkeltonLoaderBone.scss +24 -22
- package/src/components/VSwitch/VSwitch.scss +96 -94
- package/src/components/VSwitch/VSwitch.tsx +2 -2
- package/src/components/VTabs/VTab.scss +59 -57
- package/src/components/VTabs/VTabs.scss +41 -39
- package/src/components/VTabs/VTabs.tsx +5 -2
- package/src/components/VTextCounter/VTextCounter.scss +4 -2
- package/src/components/VTextField/VTextField.scss +37 -35
- package/src/components/VTextField/VTextField.tsx +2 -2
- package/src/components/VTextarea/VTextarea.scss +33 -31
- package/src/components/VTextarea/VTextarea.tsx +2 -2
- package/src/components/VToolbar/VToolbar.scss +19 -17
- package/src/components/VToolbar/VToolbarEdge.scss +21 -19
- package/src/components/VToolbar/VToolbarMenu.scss +6 -4
- package/src/components/VToolbar/VToolbarMenu.tsx +5 -0
- package/src/components/VToolbar/VToolbarTitle.scss +19 -17
- package/src/components/index.ts +3 -1
- package/src/components/kits.ts +1 -1
- package/src/composables/control.ts +1 -1
- package/src/composables/form-selector.scss +20 -18
- package/src/composables/form-selector.tsx +5 -3
- package/src/index.ts +13 -2
- package/src/injections.ts +1 -1
- package/src/plugin.tsx +4 -4
- package/src/schemes/control.ts +2 -2
- package/src/service.tsx +5 -5
- package/src/styles/core/functions.scss +2 -2
- package/src/styles/index.scss +23 -9
- package/dist/tool/index.d.ts +0 -2
- package/dist/tool/index.d.ts.map +0 -1
- package/dist/tool/index.mjs +0 -193
- package/dist/tool/vite-plugin.d.ts +0 -25
- package/dist/tool/vite-plugin.d.ts.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/assets/builtins/color-scheme.ts +0 -9
- package/src/assets/builtins/media-match.ts +0 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/VAvatar/.DS_Store +0 -0
- package/src/components/VChip/.DS_Store +0 -0
- package/src/components/VSkeltonLoader/.DS_Store +0 -0
- package/src/components/VTextField/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/VWysiwygEditor.scss +0 -66
- package/src/components/VWysiwygEditor/VWysiwygEditor.tsx +0 -354
- package/src/components/VWysiwygEditor/extensions/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/color.ts +0 -72
- package/src/components/VWysiwygEditor/extensions/index.ts +0 -2
- package/src/components/VWysiwygEditor/extensions/linter/.DS_Store +0 -0
- package/src/components/VWysiwygEditor/extensions/linter/Linter.scss +0 -140
- package/src/components/VWysiwygEditor/extensions/linter/Linter.tsx +0 -210
- package/src/components/VWysiwygEditor/extensions/linter/LinterPlugin.ts +0 -65
- package/src/components/VWysiwygEditor/extensions/linter/index.ts +0 -5
- package/src/components/VWysiwygEditor/extensions/linter/plugins/BadWords.tsx +0 -50
- package/src/components/VWysiwygEditor/extensions/linter/plugins/HeadingLevel.ts +0 -39
- package/src/components/VWysiwygEditor/extensions/linter/plugins/Punctuation.ts +0 -49
- package/src/components/VWysiwygEditor/extensions/linter/plugins/index.ts +0 -3
- package/src/components/VWysiwygEditor/extensions/linter/utils.ts +0 -28
- package/src/components/VWysiwygEditor/index.ts +0 -4
- package/src/components/VWysiwygEditor/schemes.ts +0 -251
- package/src/components/VWysiwygEditor/tools/bullet-list.ts +0 -18
- package/src/components/VWysiwygEditor/tools/color.scss +0 -140
- package/src/components/VWysiwygEditor/tools/color.tsx +0 -90
- package/src/components/VWysiwygEditor/tools/format-bold.ts +0 -19
- package/src/components/VWysiwygEditor/tools/format-italic.ts +0 -18
- package/src/components/VWysiwygEditor/tools/format-underline.ts +0 -18
- package/src/components/VWysiwygEditor/tools/history.ts +0 -26
- package/src/components/VWysiwygEditor/tools/index.ts +0 -8
- package/src/components/VWysiwygEditor/tools/link.ts +0 -57
- package/src/components/VWysiwygEditor/tools/ordered-list.ts +0 -21
- package/src/tool/index.ts +0 -2
- package/src/tool/vite-plugin.ts +0 -266
- /package/{src/styles → dist}/after-effects/display-flow.scss +0 -0
- /package/{src/styles → dist}/after-effects/spacing.scss +0 -0
- /package/{src/styles → dist}/after-effects/text.scss +0 -0
- /package/{src/styles → dist}/after-effects.scss +0 -0
- /package/dist/{assets/builtins → builtins}/color-scheme.ts +0 -0
- /package/dist/{assets/builtins → builtins}/media-match.ts +0 -0
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { type VuiService } from '../../service';
|
|
2
|
-
import {
|
|
3
|
-
type Editor,
|
|
4
|
-
type Extensions,
|
|
5
|
-
type Node,
|
|
6
|
-
type Extension,
|
|
7
|
-
type Mark,
|
|
8
|
-
type AnyExtension,
|
|
9
|
-
type EditorOptions,
|
|
10
|
-
} from '@tiptap/vue-3';
|
|
11
|
-
import { type IconName } from '../VIcon';
|
|
12
|
-
import { VNodeChild } from 'vue';
|
|
13
|
-
|
|
14
|
-
const EDITOR_EVENTS = [
|
|
15
|
-
'beforeCreate',
|
|
16
|
-
'create',
|
|
17
|
-
'update',
|
|
18
|
-
'selectionUpdate',
|
|
19
|
-
'transaction',
|
|
20
|
-
'focus',
|
|
21
|
-
'blur',
|
|
22
|
-
'destroy',
|
|
23
|
-
] as const;
|
|
24
|
-
|
|
25
|
-
type PrefixedEventName<S extends string> = `on${Capitalize<S>}`;
|
|
26
|
-
|
|
27
|
-
const prefixedEventName = <S extends string>(
|
|
28
|
-
source: S,
|
|
29
|
-
): PrefixedEventName<S> => {
|
|
30
|
-
return `on${source.charAt(0).toUpperCase()}${source.slice(1)}` as any;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type WysiwygEditorEvent = typeof EDITOR_EVENTS[number];
|
|
34
|
-
|
|
35
|
-
export type WysiwygEditorPrefixedEvent = PrefixedEventName<WysiwygEditorEvent>;
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
38
|
-
export interface WysiwygEditorEventsOptions
|
|
39
|
-
extends Partial<Pick<EditorOptions, WysiwygEditorPrefixedEvent>> {}
|
|
40
|
-
|
|
41
|
-
export type WysiwygEditorEventsBucket = {
|
|
42
|
-
[EV in WysiwygEditorEvent]: NonNullable<
|
|
43
|
-
WysiwygEditorEventsOptions[PrefixedEventName<EV>]
|
|
44
|
-
>[];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export class WysiwygEditorInitializeContext {
|
|
48
|
-
readonly listeners: WysiwygEditorEventsBucket = {} as any;
|
|
49
|
-
private readonly _vui: () => VuiService;
|
|
50
|
-
|
|
51
|
-
get vui() {
|
|
52
|
-
return this._vui();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
constructor(
|
|
56
|
-
vuiGetter: () => VuiService,
|
|
57
|
-
opts: WysiwygEditorEventsOptions = {},
|
|
58
|
-
) {
|
|
59
|
-
this._vui = vuiGetter;
|
|
60
|
-
|
|
61
|
-
EDITOR_EVENTS.forEach((event) => {
|
|
62
|
-
this.listeners[event] = [];
|
|
63
|
-
const prefixed = prefixedEventName(event);
|
|
64
|
-
const fn = opts[prefixed];
|
|
65
|
-
fn && this.listeners[event].push(fn as any);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
on<EV extends WysiwygEditorEvent>(
|
|
70
|
-
ev: EV,
|
|
71
|
-
handler: NonNullable<WysiwygEditorEventsOptions[PrefixedEventName<EV>]>,
|
|
72
|
-
) {
|
|
73
|
-
this.listeners[ev].push(handler);
|
|
74
|
-
return () => this.off(ev, handler);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
off<EV extends WysiwygEditorEvent>(
|
|
78
|
-
ev: EV,
|
|
79
|
-
handler: NonNullable<WysiwygEditorEventsOptions[PrefixedEventName<EV>]>,
|
|
80
|
-
) {
|
|
81
|
-
this.listeners[ev] = this.listeners[ev].filter(
|
|
82
|
-
(_handler) => _handler !== handler,
|
|
83
|
-
) as any;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
editorOptions() {
|
|
87
|
-
const opts: WysiwygEditorEventsOptions = {};
|
|
88
|
-
|
|
89
|
-
EDITOR_EVENTS.forEach((event) => {
|
|
90
|
-
const prefixed = prefixedEventName(event);
|
|
91
|
-
opts[prefixed] = (props) => {
|
|
92
|
-
const handlers = this.listeners[event];
|
|
93
|
-
handlers.forEach((handler) => {
|
|
94
|
-
handler(props as any);
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
return opts;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface WysiwygEditorContext {
|
|
104
|
-
editor: Editor;
|
|
105
|
-
vui: VuiService;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export type WysiwygExtensionFactory<Options = any, Storage = any> = (
|
|
109
|
-
ctx: WysiwygEditorInitializeContext,
|
|
110
|
-
) =>
|
|
111
|
-
| Extension<Options, Storage>
|
|
112
|
-
| Node<Options, Storage>
|
|
113
|
-
| Mark<Options, Storage>;
|
|
114
|
-
|
|
115
|
-
export interface CreatedWysiwygExtension<Options = any, Storage = any> {
|
|
116
|
-
__isCreatedWysiwygExtension: true;
|
|
117
|
-
_configs: Partial<Options>[];
|
|
118
|
-
configure(
|
|
119
|
-
options?: Partial<Options>,
|
|
120
|
-
): CreatedWysiwygExtension<Options, Storage>;
|
|
121
|
-
raw: WysiwygExtensionSource<Options, Storage>;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export type WysiwygExtensionSource<Options = any, Storage = any> =
|
|
125
|
-
| Extension<Options, Storage>
|
|
126
|
-
| Node<Options, Storage>
|
|
127
|
-
| Mark<Options, Storage>
|
|
128
|
-
| WysiwygExtensionFactory<Options, Storage>;
|
|
129
|
-
|
|
130
|
-
export type RawWysiwygExtension<Options = any, Storage = any> =
|
|
131
|
-
| WysiwygExtensionSource<Options, Storage>
|
|
132
|
-
| CreatedWysiwygExtension<Options, Storage>;
|
|
133
|
-
|
|
134
|
-
// export function createWysiwygExtension<Options = any, Storage = any>(
|
|
135
|
-
// extension: Extension<Options, Storage>,
|
|
136
|
-
// ): Extension<Options, Storage>;
|
|
137
|
-
// export function createWysiwygExtension<Options = any, Storage = any>(
|
|
138
|
-
// node: Node<Options, Storage>,
|
|
139
|
-
// ): Node<Options, Storage>;
|
|
140
|
-
// export function createWysiwygExtension<Options = any, Storage = any>(
|
|
141
|
-
// mark: Mark<Options, Storage>,
|
|
142
|
-
// ): Mark<Options, Storage>;
|
|
143
|
-
// export function createWysiwygExtension<Options = any, Storage = any>(
|
|
144
|
-
// factory: WysiwygExtensionFactory<Options, Storage>,
|
|
145
|
-
// ): WysiwygExtensionFactory<Options, Storage>;
|
|
146
|
-
|
|
147
|
-
function isCreatedWysiwygExtension<Options = any, Storage = any>(
|
|
148
|
-
source: unknown,
|
|
149
|
-
): source is CreatedWysiwygExtension<Options, Storage> {
|
|
150
|
-
return (
|
|
151
|
-
!!source &&
|
|
152
|
-
typeof source === 'object' &&
|
|
153
|
-
(source as CreatedWysiwygExtension).__isCreatedWysiwygExtension === true
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function createWysiwygExtension<Options = any, Storage = any>(
|
|
158
|
-
extension: WysiwygExtensionSource<Options, Storage>,
|
|
159
|
-
) {
|
|
160
|
-
const ext: CreatedWysiwygExtension<Options, Storage> = {
|
|
161
|
-
__isCreatedWysiwygExtension: true,
|
|
162
|
-
_configs: [],
|
|
163
|
-
configure: (opts) => {
|
|
164
|
-
opts && ext._configs.push(opts);
|
|
165
|
-
return ext;
|
|
166
|
-
},
|
|
167
|
-
raw: extension,
|
|
168
|
-
};
|
|
169
|
-
return ext;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function resolveRawWysiwygExtension(
|
|
173
|
-
raw: RawWysiwygExtension,
|
|
174
|
-
ctx: WysiwygEditorInitializeContext,
|
|
175
|
-
): AnyExtension {
|
|
176
|
-
if (isCreatedWysiwygExtension(raw)) {
|
|
177
|
-
const { raw: _raw, _configs } = raw;
|
|
178
|
-
let ext = typeof _raw === 'function' ? _raw(ctx) : _raw;
|
|
179
|
-
_configs.forEach((config) => {
|
|
180
|
-
ext = ext.configure(config);
|
|
181
|
-
});
|
|
182
|
-
return ext;
|
|
183
|
-
}
|
|
184
|
-
return typeof raw === 'function' ? raw(ctx) : raw;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function resolveRawWysiwygExtensions(
|
|
188
|
-
raws: RawWysiwygExtension[],
|
|
189
|
-
ctx: WysiwygEditorInitializeContext,
|
|
190
|
-
) {
|
|
191
|
-
return raws.map((raw) => resolveRawWysiwygExtension(raw, ctx));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface WysiwygEditorTool {
|
|
195
|
-
key: string;
|
|
196
|
-
icon:
|
|
197
|
-
| IconName
|
|
198
|
-
| ((ctx: WysiwygEditorContext) => IconName | (() => VNodeChild));
|
|
199
|
-
active?: boolean | ((ctx: WysiwygEditorContext) => boolean);
|
|
200
|
-
disabled?: boolean | ((ctx: WysiwygEditorContext) => boolean);
|
|
201
|
-
onClick: (ctx: WysiwygEditorContext, ev: MouseEvent) => any;
|
|
202
|
-
floating?: boolean;
|
|
203
|
-
extensions?: Extensions;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export type WysiwygEditorToolFactory<Options = void> = (
|
|
207
|
-
vui: VuiService,
|
|
208
|
-
options?: Options,
|
|
209
|
-
) => WysiwygEditorTool | WysiwygEditorTool[];
|
|
210
|
-
|
|
211
|
-
export type RawWysiwygEditorTool =
|
|
212
|
-
| WysiwygEditorTool
|
|
213
|
-
| WysiwygEditorToolFactory<any>;
|
|
214
|
-
|
|
215
|
-
function resolveRawWysiwygEditorTool(
|
|
216
|
-
raw: RawWysiwygEditorTool,
|
|
217
|
-
vui: VuiService,
|
|
218
|
-
) {
|
|
219
|
-
return typeof raw === 'function' ? raw(vui) : raw;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface ResolvedWysiwygEditorSettings {
|
|
223
|
-
tools: WysiwygEditorTool[];
|
|
224
|
-
extensions: Extensions;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function resolveRawWysiwygEditorTools(
|
|
228
|
-
rawTools: RawWysiwygEditorTool[],
|
|
229
|
-
vui: VuiService,
|
|
230
|
-
): ResolvedWysiwygEditorSettings {
|
|
231
|
-
const tools: WysiwygEditorTool[] = [];
|
|
232
|
-
const extensions: Extensions = [];
|
|
233
|
-
|
|
234
|
-
rawTools.forEach((raw) => {
|
|
235
|
-
let resolved = resolveRawWysiwygEditorTool(raw, vui);
|
|
236
|
-
if (!Array.isArray(resolved)) {
|
|
237
|
-
resolved = [resolved];
|
|
238
|
-
}
|
|
239
|
-
resolved.forEach((tool) => {
|
|
240
|
-
tools.push(tool);
|
|
241
|
-
if (tool.extensions) {
|
|
242
|
-
extensions.push(...tool.extensions);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return {
|
|
248
|
-
tools,
|
|
249
|
-
extensions,
|
|
250
|
-
};
|
|
251
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { BulletList, BulletListOptions } from '@tiptap/extension-bullet-list';
|
|
3
|
-
|
|
4
|
-
export const WysiwygBulletListTool: WysiwygEditorToolFactory<
|
|
5
|
-
BulletListOptions
|
|
6
|
-
> = (vui, options) => {
|
|
7
|
-
const tool: WysiwygEditorTool = {
|
|
8
|
-
key: 'bulletList',
|
|
9
|
-
icon: vui.icon('editorformatListBulleted'),
|
|
10
|
-
active: ({ editor }) => editor.isActive('bulletList'),
|
|
11
|
-
onClick: ({ editor }) => {
|
|
12
|
-
editor.chain().focus().toggleBulletList().run();
|
|
13
|
-
},
|
|
14
|
-
floating: true,
|
|
15
|
-
extensions: [BulletList.configure(options)],
|
|
16
|
-
};
|
|
17
|
-
return tool;
|
|
18
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--v-wysiwyg-color-tool: 30px;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.v-wysiwyg-color-tool {
|
|
6
|
-
&__button {
|
|
7
|
-
position: relative;
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
vertical-align: bottom;
|
|
12
|
-
|
|
13
|
-
&__bar {
|
|
14
|
-
position: absolute;
|
|
15
|
-
right: 0;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
left: 0;
|
|
18
|
-
display: block;
|
|
19
|
-
height: 2px;
|
|
20
|
-
background: currentColor;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&__menu {
|
|
25
|
-
.v-dialog__content {
|
|
26
|
-
min-width: 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.v-dialog__body {
|
|
30
|
-
padding: 2px;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&__items {
|
|
35
|
-
--item-size: var(--v-wysiwyg-color-tool);
|
|
36
|
-
|
|
37
|
-
display: inline-flex;
|
|
38
|
-
flex-wrap: wrap;
|
|
39
|
-
align-items: center;
|
|
40
|
-
max-width: calc(var(--item-size) * 5);
|
|
41
|
-
vertical-align: bottom;
|
|
42
|
-
|
|
43
|
-
&--with-label {
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
// flex-wrap: nowrap;
|
|
47
|
-
align-items: flex-start;
|
|
48
|
-
max-width: none;
|
|
49
|
-
padding: 2px;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&__item {
|
|
54
|
-
--focus-offset: calc(var(--item-size) * 0.05);
|
|
55
|
-
|
|
56
|
-
position: relative;
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-basis: var(--item-size);
|
|
59
|
-
align-items: center;
|
|
60
|
-
width: var(--item-size);
|
|
61
|
-
height: var(--item-size);
|
|
62
|
-
padding: 0;
|
|
63
|
-
margin: 0;
|
|
64
|
-
// margin: 2px;
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
background: transparent;
|
|
67
|
-
border: 0;
|
|
68
|
-
border-radius: 0;
|
|
69
|
-
outline: 0;
|
|
70
|
-
appearance: none;
|
|
71
|
-
|
|
72
|
-
&__color {
|
|
73
|
-
position: relative;
|
|
74
|
-
flex: 0 0 var(--item-size);
|
|
75
|
-
width: var(--item-size);
|
|
76
|
-
height: var(--item-size);
|
|
77
|
-
|
|
78
|
-
&::before {
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: 0;
|
|
81
|
-
right: 0;
|
|
82
|
-
bottom: 0;
|
|
83
|
-
left: 0;
|
|
84
|
-
display: block;
|
|
85
|
-
content: '';
|
|
86
|
-
background: currentColor;
|
|
87
|
-
border: solid 1px transparent;
|
|
88
|
-
transition: all 0.15s;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&__name {
|
|
93
|
-
position: relative;
|
|
94
|
-
padding: 0 8px;
|
|
95
|
-
font-size: 12px;
|
|
96
|
-
white-space: nowrap;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&:hover &__color,
|
|
100
|
-
&:focus &__color {
|
|
101
|
-
&::before {
|
|
102
|
-
top: var(--focus-offset);
|
|
103
|
-
right: var(--focus-offset);
|
|
104
|
-
bottom: var(--focus-offset);
|
|
105
|
-
left: var(--focus-offset);
|
|
106
|
-
border-color: rgba(0, 0, 0, 0.1);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
&__items--with-label &__item {
|
|
112
|
-
flex-basis: auto;
|
|
113
|
-
width: auto;
|
|
114
|
-
width: 100%;
|
|
115
|
-
|
|
116
|
-
&::before {
|
|
117
|
-
position: absolute;
|
|
118
|
-
top: 0;
|
|
119
|
-
right: 0;
|
|
120
|
-
bottom: 0;
|
|
121
|
-
left: 0;
|
|
122
|
-
display: block;
|
|
123
|
-
content: '';
|
|
124
|
-
background: currentColor;
|
|
125
|
-
opacity: 0;
|
|
126
|
-
transition: opacity 0.15s;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&:hover,
|
|
130
|
-
&:focus {
|
|
131
|
-
&::before {
|
|
132
|
-
opacity: 0.1;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
& + .v-wysiwyg-color-tool__item {
|
|
137
|
-
margin-top: 2px;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import './color.scss';
|
|
2
|
-
|
|
3
|
-
import { VNodeChild } from 'vue';
|
|
4
|
-
import { WysiwygColorExtension } from '../extensions';
|
|
5
|
-
import { type VuiService } from '../../../service';
|
|
6
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
7
|
-
import TextStyle from '@tiptap/extension-text-style';
|
|
8
|
-
import { VIcon } from '../../VIcon';
|
|
9
|
-
|
|
10
|
-
export interface WysiwygColorItem {
|
|
11
|
-
key?: string | number;
|
|
12
|
-
name?: VNodeChild | ((vui: VuiService) => VNodeChild);
|
|
13
|
-
color: string | null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface CreateWysiwygColorToolOptions {
|
|
17
|
-
items: WysiwygColorItem[];
|
|
18
|
-
withLabel?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createWysiwygColorTool(opts: CreateWysiwygColorToolOptions) {
|
|
22
|
-
const WysiwygColorTool: WysiwygEditorToolFactory = (vui) => {
|
|
23
|
-
const tool: WysiwygEditorTool = {
|
|
24
|
-
key: 'textColor',
|
|
25
|
-
// active: ({ editor }) => editor.isActive('textStyle'),
|
|
26
|
-
icon:
|
|
27
|
-
({ editor }) =>
|
|
28
|
-
() => {
|
|
29
|
-
const color: string | undefined =
|
|
30
|
-
editor.getAttributes('textStyle').color;
|
|
31
|
-
const style = { color };
|
|
32
|
-
return (
|
|
33
|
-
<span class="v-wysiwyg-color-tool__button">
|
|
34
|
-
<VIcon
|
|
35
|
-
class="v-wysiwyg-color-tool__button__icon"
|
|
36
|
-
name={vui.icon('editorTextColor')}
|
|
37
|
-
/>
|
|
38
|
-
<span class="v-wysiwyg-color-tool__button__bar" style={style} />
|
|
39
|
-
</span>
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
onClick: (ctx, ev) => {
|
|
43
|
-
ctx.vui.menu({
|
|
44
|
-
class: 'v-wysiwyg-color-tool__menu',
|
|
45
|
-
activator: ev,
|
|
46
|
-
content: (stack) => (
|
|
47
|
-
<div
|
|
48
|
-
class={[
|
|
49
|
-
'v-wysiwyg-color-tool__items',
|
|
50
|
-
{ 'v-wysiwyg-color-tool__items--with-label': opts.withLabel },
|
|
51
|
-
]}>
|
|
52
|
-
{opts.items.map((item, index) => (
|
|
53
|
-
<button
|
|
54
|
-
key={item.key == null ? index : item.key}
|
|
55
|
-
class="v-wysiwyg-color-tool__item"
|
|
56
|
-
type="button"
|
|
57
|
-
onClick={() => {
|
|
58
|
-
const { color } = item;
|
|
59
|
-
let command = ctx.editor.chain().focus();
|
|
60
|
-
if (color) {
|
|
61
|
-
command = command.setColor(color);
|
|
62
|
-
} else {
|
|
63
|
-
command = command.unsetColor();
|
|
64
|
-
}
|
|
65
|
-
command.run();
|
|
66
|
-
stack.close();
|
|
67
|
-
}}>
|
|
68
|
-
<span
|
|
69
|
-
class="v-wysiwyg-color-tool__item__color"
|
|
70
|
-
style={item.color ? { color: item.color } : {}}
|
|
71
|
-
/>
|
|
72
|
-
{opts.withLabel && (
|
|
73
|
-
<span class="v-wysiwyg-color-tool__item__name">
|
|
74
|
-
{item.name}
|
|
75
|
-
</span>
|
|
76
|
-
)}
|
|
77
|
-
</button>
|
|
78
|
-
))}
|
|
79
|
-
</div>
|
|
80
|
-
),
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
floating: true,
|
|
84
|
-
extensions: [TextStyle, WysiwygColorExtension],
|
|
85
|
-
};
|
|
86
|
-
return tool;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return WysiwygColorTool;
|
|
90
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { Bold, BoldOptions } from '@tiptap/extension-bold';
|
|
3
|
-
|
|
4
|
-
export const WysiwygFormatBoldTool: WysiwygEditorToolFactory<BoldOptions> = (
|
|
5
|
-
vui,
|
|
6
|
-
options,
|
|
7
|
-
) => {
|
|
8
|
-
const tool: WysiwygEditorTool = {
|
|
9
|
-
key: 'formatBold',
|
|
10
|
-
icon: vui.icon('editorformatBold'),
|
|
11
|
-
active: ({ editor }) => editor.isActive('bold'),
|
|
12
|
-
onClick: ({ editor }) => {
|
|
13
|
-
editor.chain().focus().toggleBold().run();
|
|
14
|
-
},
|
|
15
|
-
floating: true,
|
|
16
|
-
extensions: [Bold.configure(options)],
|
|
17
|
-
};
|
|
18
|
-
return tool;
|
|
19
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { Italic, ItalicOptions } from '@tiptap/extension-italic';
|
|
3
|
-
|
|
4
|
-
export const WysiwygFormatItalicTool: WysiwygEditorToolFactory<
|
|
5
|
-
ItalicOptions
|
|
6
|
-
> = (vui, options) => {
|
|
7
|
-
const tool: WysiwygEditorTool = {
|
|
8
|
-
key: 'formatItalic',
|
|
9
|
-
icon: vui.icon('editorformatItalic'),
|
|
10
|
-
active: ({ editor }) => editor.isActive('italic'),
|
|
11
|
-
onClick: ({ editor }) => {
|
|
12
|
-
editor.chain().focus().toggleItalic().run();
|
|
13
|
-
},
|
|
14
|
-
floating: true,
|
|
15
|
-
extensions: [Italic.configure(options)],
|
|
16
|
-
};
|
|
17
|
-
return tool;
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { Underline, UnderlineOptions } from '@tiptap/extension-underline';
|
|
3
|
-
|
|
4
|
-
export const WysiwygFormatUnderlineTool: WysiwygEditorToolFactory<
|
|
5
|
-
UnderlineOptions
|
|
6
|
-
> = (vui, options) => {
|
|
7
|
-
const tool: WysiwygEditorTool = {
|
|
8
|
-
key: 'formatUnderline',
|
|
9
|
-
icon: vui.icon('editorformatUnderline'),
|
|
10
|
-
active: ({ editor }) => editor.isActive('underline'),
|
|
11
|
-
onClick: ({ editor }) => {
|
|
12
|
-
editor.chain().focus().toggleUnderline().run();
|
|
13
|
-
},
|
|
14
|
-
floating: true,
|
|
15
|
-
extensions: [Underline.configure(options)],
|
|
16
|
-
};
|
|
17
|
-
return tool;
|
|
18
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { History, HistoryOptions } from '@tiptap/extension-history';
|
|
3
|
-
|
|
4
|
-
export const WysiwygHistoryTool: WysiwygEditorToolFactory<HistoryOptions> = (
|
|
5
|
-
vui,
|
|
6
|
-
options,
|
|
7
|
-
) => {
|
|
8
|
-
const undo: WysiwygEditorTool = {
|
|
9
|
-
key: 'history-undo',
|
|
10
|
-
icon: vui.icon('editorUndo'),
|
|
11
|
-
disabled: ({ editor }) => !editor.can().undo(),
|
|
12
|
-
onClick: ({ editor }) => {
|
|
13
|
-
editor.chain().focus().undo().run();
|
|
14
|
-
},
|
|
15
|
-
extensions: [History.configure(options)],
|
|
16
|
-
};
|
|
17
|
-
const redo: WysiwygEditorTool = {
|
|
18
|
-
key: 'history-redo',
|
|
19
|
-
icon: vui.icon('editorRedo'),
|
|
20
|
-
disabled: ({ editor }) => !editor.can().redo(),
|
|
21
|
-
onClick: ({ editor }) => {
|
|
22
|
-
editor.chain().focus().redo().run();
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
return [undo, redo];
|
|
26
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import { Link, LinkOptions } from '@tiptap/extension-link';
|
|
3
|
-
import { validateIf, url } from '@fastkit/rules';
|
|
4
|
-
|
|
5
|
-
export const WysiwygLinkTool: WysiwygEditorToolFactory<LinkOptions> = (
|
|
6
|
-
vui,
|
|
7
|
-
options,
|
|
8
|
-
) => {
|
|
9
|
-
const tool: WysiwygEditorTool = {
|
|
10
|
-
key: 'link',
|
|
11
|
-
// icon: ({ editor }) => {
|
|
12
|
-
// return vui.icon(editor.isActive('link') ? 'editorLinkOff' : 'editorLink');
|
|
13
|
-
// },
|
|
14
|
-
icon: vui.icon('editorLink'),
|
|
15
|
-
active: ({ editor }) => editor.isActive('link'),
|
|
16
|
-
// disabled: ({ editor }) => {
|
|
17
|
-
// const { $from, $to } = editor.view.state.selection;
|
|
18
|
-
// return $to.pos - $from.pos === 0;
|
|
19
|
-
// },
|
|
20
|
-
onClick: async ({ vui, editor }) => {
|
|
21
|
-
const { href = '' } = editor.getAttributes('link');
|
|
22
|
-
const result = await vui.prompt({
|
|
23
|
-
input: {
|
|
24
|
-
label: 'Link URL',
|
|
25
|
-
rules: [validateIf, url],
|
|
26
|
-
initialValue: href,
|
|
27
|
-
size: 'sm',
|
|
28
|
-
autofocus: true,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (result === undefined || result === false) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const range = editor.chain().focus().extendMarkRange('link');
|
|
37
|
-
|
|
38
|
-
if (!result) {
|
|
39
|
-
range.unsetLink().run();
|
|
40
|
-
} else {
|
|
41
|
-
range
|
|
42
|
-
.setLink({
|
|
43
|
-
href: result,
|
|
44
|
-
})
|
|
45
|
-
.run();
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
floating: true,
|
|
49
|
-
extensions: [
|
|
50
|
-
Link.configure({
|
|
51
|
-
openOnClick: false,
|
|
52
|
-
...options,
|
|
53
|
-
}),
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
return tool;
|
|
57
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
|
|
2
|
-
import {
|
|
3
|
-
OrderedList,
|
|
4
|
-
OrderedListOptions,
|
|
5
|
-
} from '@tiptap/extension-ordered-list';
|
|
6
|
-
|
|
7
|
-
export const WysiwygOrderedListTool: WysiwygEditorToolFactory<
|
|
8
|
-
OrderedListOptions
|
|
9
|
-
> = (vui, options) => {
|
|
10
|
-
const tool: WysiwygEditorTool = {
|
|
11
|
-
key: 'orderedList',
|
|
12
|
-
icon: vui.icon('editorformatListNumbered'),
|
|
13
|
-
active: ({ editor }) => editor.isActive('orderedList'),
|
|
14
|
-
onClick: ({ editor }) => {
|
|
15
|
-
editor.chain().focus().toggleOrderedList().run();
|
|
16
|
-
},
|
|
17
|
-
floating: true,
|
|
18
|
-
extensions: [OrderedList.configure(options)],
|
|
19
|
-
};
|
|
20
|
-
return tool;
|
|
21
|
-
};
|
package/src/tool/index.ts
DELETED