@fastkit/vui 0.7.57 → 0.7.64

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.
Files changed (36) hide show
  1. package/dist/tool/index.js +1 -0
  2. package/dist/tool/vite-plugin.d.ts.map +1 -1
  3. package/dist/vui.cjs.js +615 -44
  4. package/dist/vui.cjs.prod.js +615 -44
  5. package/dist/vui.css +221 -0
  6. package/dist/vui.d.ts +139 -4
  7. package/dist/vui.min.css +1 -1
  8. package/dist/vui.min.css.map +1 -1
  9. package/dist/vui.mjs +605 -44
  10. package/package.json +7 -6
  11. package/src/components/VButton/VButtonGroup.scss +4 -0
  12. package/src/components/VButton/VButtonGroup.tsx +12 -1
  13. package/src/components/VWysiwygEditor/.DS_Store +0 -0
  14. package/src/components/VWysiwygEditor/VWysiwygEditor.scss +6 -0
  15. package/src/components/VWysiwygEditor/VWysiwygEditor.tsx +97 -56
  16. package/src/components/VWysiwygEditor/extensions/.DS_Store +0 -0
  17. package/src/components/VWysiwygEditor/extensions/color.ts +72 -0
  18. package/src/components/VWysiwygEditor/extensions/index.ts +2 -0
  19. package/src/components/VWysiwygEditor/extensions/linter/.DS_Store +0 -0
  20. package/src/components/VWysiwygEditor/extensions/linter/Linter.scss +140 -0
  21. package/src/components/VWysiwygEditor/extensions/linter/Linter.tsx +210 -0
  22. package/src/components/VWysiwygEditor/extensions/linter/LinterPlugin.ts +62 -0
  23. package/src/components/VWysiwygEditor/extensions/linter/index.ts +5 -0
  24. package/src/components/VWysiwygEditor/extensions/linter/plugins/BadWords.tsx +50 -0
  25. package/src/components/VWysiwygEditor/extensions/linter/plugins/HeadingLevel.ts +39 -0
  26. package/src/components/VWysiwygEditor/extensions/linter/plugins/Punctuation.ts +49 -0
  27. package/src/components/VWysiwygEditor/extensions/linter/plugins/index.ts +3 -0
  28. package/src/components/VWysiwygEditor/extensions/linter/utils.ts +28 -0
  29. package/src/components/VWysiwygEditor/index.ts +1 -0
  30. package/src/components/VWysiwygEditor/schemes.ts +190 -4
  31. package/src/components/VWysiwygEditor/tools/color.scss +140 -0
  32. package/src/components/VWysiwygEditor/tools/color.tsx +90 -0
  33. package/src/components/VWysiwygEditor/tools/index.ts +1 -1
  34. package/src/service.tsx +5 -0
  35. package/src/tool/vite-plugin.ts +1 -0
  36. package/src/components/VWysiwygEditor/tools/text-color.ts +0 -14
@@ -0,0 +1,140 @@
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
+ }
@@ -0,0 +1,90 @@
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
+ }
@@ -5,4 +5,4 @@ export * from './format-underline';
5
5
  export * from './history';
6
6
  export * from './link';
7
7
  export * from './ordered-list';
8
- export * from './text-color';
8
+ export * from './color';
package/src/service.tsx CHANGED
@@ -40,6 +40,7 @@ export interface VuiServiceUISettings {
40
40
  primaryScope: ScopeName;
41
41
  plainVariant: ColorVariant;
42
42
  containedVariant: ColorVariant;
43
+ warningScope: ScopeName;
43
44
  errorScope: ScopeName;
44
45
  buttonDefault: {
45
46
  color: ScopeName;
@@ -258,6 +259,10 @@ export class VuiService {
258
259
  return this.stack.snackbar(...args);
259
260
  }
260
261
 
262
+ menu(...args: Parameters<VueStackService['menu']>) {
263
+ return this.stack.menu(...args);
264
+ }
265
+
261
266
  formPrompt<T extends { [key: string]: any } = { [key: string]: any }>(
262
267
  settings: VuiFormPromptSettings<T>,
263
268
  slot: (
@@ -143,6 +143,7 @@ export function viteVuiPlugin(
143
143
  primaryScope: 'primary' as any,
144
144
  plainVariant: 'plain' as any,
145
145
  containedVariant: 'contained' as any,
146
+ warningScope: 'warning' as any,
146
147
  errorScope: 'error' as any,
147
148
  buttonDefault: {
148
149
  color: 'base' as any,
@@ -1,14 +0,0 @@
1
- import { WysiwygEditorToolFactory, WysiwygEditorTool } from '../schemes';
2
-
3
- export const WysiwygTextColorTool: WysiwygEditorToolFactory = (vui) => {
4
- const tool: WysiwygEditorTool = {
5
- key: 'textColor',
6
- icon: vui.icon('editorTextColor'),
7
- // icon: (gen) => vui.icon('editorTextColor'),
8
- onClick: (ctx) => {
9
- ctx.vui.alert('ok');
10
- },
11
- floating: true,
12
- };
13
- return tool;
14
- };