@vunk/form 1.1.80 → 1.1.82

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.
@@ -72,8 +72,8 @@ var _sfc_main = defineComponent({
72
72
  const modelValue = computed({
73
73
  get: () => [props2.startValue, props2.endValue],
74
74
  set: (val) => {
75
- emit("update:startValue", val[0]);
76
- emit("update:endValue", val[1]);
75
+ emit("update:startValue", val?.[0]);
76
+ emit("update:endValue", val?.[1]);
77
77
  }
78
78
  });
79
79
  const prop = computed(() => {
@@ -1004,7 +1004,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1004
1004
  createVNode(_component_ViewerVue, {
1005
1005
  view: _ctx.view,
1006
1006
  "view-component": _ctx.viewComponent,
1007
- viewComponentAttrs: _ctx.viewComponentAttrs
1007
+ "view-component-attrs": _ctx.viewComponentAttrs
1008
1008
  }, {
1009
1009
  default: withCtx(() => [
1010
1010
  createVNode(_component_VaGraphicsLayer, {
@@ -1021,9 +1021,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1021
1021
  multiple: _ctx.multiple,
1022
1022
  "available-creature-tools": _ctx.availableCreatureTools,
1023
1023
  "model-value": _ctx.sketchValue,
1024
+ "visible-elements": _ctx.visibleElements,
1024
1025
  "onUpdate:modelValue": _ctx.handleUpdateSketchValue,
1025
- onLoad: _ctx.sketchLoad,
1026
- visibleElements: _ctx.visibleElements
1026
+ onLoad: _ctx.sketchLoad
1027
1027
  }, {
1028
1028
  default: withCtx(() => [
1029
1029
  !_ctx.skipSave && _ctx.shetchPanel ? (openBlock(), createBlock(_component_VkAsyncTeleport, {
@@ -1048,7 +1048,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1048
1048
  ]),
1049
1049
  _: 1
1050
1050
  /* STABLE */
1051
- }, 8, ["view-model-active-fill-symbol", "view-model-active-line-symbol", "view-model-active-point-symbol", "multiple", "available-creature-tools", "model-value", "onUpdate:modelValue", "onLoad", "visibleElements"])) : createCommentVNode("v-if", true)
1051
+ }, 8, ["view-model-active-fill-symbol", "view-model-active-line-symbol", "view-model-active-point-symbol", "multiple", "available-creature-tools", "model-value", "visible-elements", "onUpdate:modelValue", "onLoad"])) : createCommentVNode("v-if", true)
1052
1052
  ]),
1053
1053
  _: 1
1054
1054
  /* STABLE */
@@ -1056,7 +1056,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1056
1056
  ]),
1057
1057
  _: 1
1058
1058
  /* STABLE */
1059
- }, 8, ["view", "view-component", "viewComponentAttrs"])
1059
+ }, 8, ["view", "view-component", "view-component-attrs"])
1060
1060
  ]),
1061
1061
  _: 1
1062
1062
  /* STABLE */
@@ -0,0 +1,12 @@
1
+ .vkf-vditor ul,li {
2
+ list-style: initial;
3
+ }
4
+ .vkf-vditor ol,li {
5
+ list-style: decimal;
6
+ }
7
+ .vkf-vditor.vditor{
8
+ --textarea-background-color: var(--el-fill-color-extra-light);
9
+ }
10
+ .vkf-vditor-footer.is-textarea-focus{
11
+ background-color: var(--textarea-background-color);
12
+ }
@@ -1,58 +1,308 @@
1
1
  import Vditor from 'vditor';
2
- import { defineComponent, ref, onMounted, provide, openBlock, createElementBlock } from 'vue';
2
+ import { inject, unref, ref, watch, defineComponent, nextTick, shallowRef, provide, onMounted, resolveComponent, openBlock, createElementBlock, Fragment, createElementVNode, createBlock, withCtx, normalizeClass, renderSlot, createCommentVNode } from 'vue';
3
3
  import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
4
+ import { VkAsyncTeleport } from '@vunk/core';
4
5
 
5
6
  const props = {
6
7
  modelValue: {
7
- type: Object,
8
- default: () => ({})
8
+ type: String,
9
+ default: ""
9
10
  },
10
11
  defaultOptions: {
11
12
  type: Object,
12
13
  default: () => ({})
14
+ },
15
+ placeholder: {
16
+ type: String,
17
+ default: "\u95EE\u6211\u4EFB\u4F55\u95EE\u9898...(Crtl + Enter \u53D1\u9001)"
18
+ },
19
+ toolbar: {
20
+ type: Array,
21
+ default: () => [
22
+ "headings",
23
+ "bold",
24
+ "italic",
25
+ "strike",
26
+ "link",
27
+ "|",
28
+ "list",
29
+ "ordered-list",
30
+ "outdent",
31
+ "indent",
32
+ "|",
33
+ "line",
34
+ "code",
35
+ "inline-code",
36
+ "insert-before",
37
+ "insert-after",
38
+ "|",
39
+ "table",
40
+ "|",
41
+ "undo",
42
+ "redo",
43
+ "|",
44
+ "fullscreen",
45
+ "outline",
46
+ "export",
47
+ "|"
48
+ ]
13
49
  }
14
50
  };
15
51
  const emits = {
16
- load: (e) => e
52
+ load: (e) => e,
53
+ "update:modelValue": (e) => e,
54
+ ctrlEnter: (e) => e
55
+ };
56
+
57
+ function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}}
58
+
59
+ const useVditor = () => {
60
+ const core = inject("vkfVditorRef", null);
61
+ if (!core) {
62
+ throw new Error("useVditor must be used after VditorProvider");
63
+ }
64
+ return unref(core);
65
+ };
66
+ const useVditorMitter = () => {
67
+ const core = inject("vkfVditorMitter", null);
68
+ if (!core) {
69
+ throw new Error("useVditorMitter must be used after VditorProvider");
70
+ }
71
+ return core;
72
+ };
73
+
74
+ var _a;
75
+ const isClient = typeof window !== "undefined";
76
+ isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
77
+
78
+ function createFilterWrapper(filter, fn) {
79
+ function wrapper(...args) {
80
+ filter(() => fn.apply(this, args), { fn, thisArg: this, args });
81
+ }
82
+ return wrapper;
83
+ }
84
+ const bypassFilter = (invoke) => {
85
+ return invoke();
86
+ };
87
+ function pausableFilter(extendFilter = bypassFilter) {
88
+ const isActive = ref(true);
89
+ function pause() {
90
+ isActive.value = false;
91
+ }
92
+ function resume() {
93
+ isActive.value = true;
94
+ }
95
+ const eventFilter = (...args) => {
96
+ if (isActive.value)
97
+ extendFilter(...args);
98
+ };
99
+ return { isActive, pause, resume, eventFilter };
100
+ }
101
+
102
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
103
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
104
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
105
+ var __objRest$5 = (source, exclude) => {
106
+ var target = {};
107
+ for (var prop in source)
108
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
109
+ target[prop] = source[prop];
110
+ if (source != null && __getOwnPropSymbols$6)
111
+ for (var prop of __getOwnPropSymbols$6(source)) {
112
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
113
+ target[prop] = source[prop];
114
+ }
115
+ return target;
116
+ };
117
+ function watchWithFilter(source, cb, options = {}) {
118
+ const _a = options, {
119
+ eventFilter = bypassFilter
120
+ } = _a, watchOptions = __objRest$5(_a, [
121
+ "eventFilter"
122
+ ]);
123
+ return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
124
+ }
125
+
126
+ var __defProp$2 = Object.defineProperty;
127
+ var __defProps$2 = Object.defineProperties;
128
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
129
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
130
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
131
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
132
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
133
+ var __spreadValues$2 = (a, b) => {
134
+ for (var prop in b || (b = {}))
135
+ if (__hasOwnProp$2.call(b, prop))
136
+ __defNormalProp$2(a, prop, b[prop]);
137
+ if (__getOwnPropSymbols$2)
138
+ for (var prop of __getOwnPropSymbols$2(b)) {
139
+ if (__propIsEnum$2.call(b, prop))
140
+ __defNormalProp$2(a, prop, b[prop]);
141
+ }
142
+ return a;
143
+ };
144
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
145
+ var __objRest$1 = (source, exclude) => {
146
+ var target = {};
147
+ for (var prop in source)
148
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
149
+ target[prop] = source[prop];
150
+ if (source != null && __getOwnPropSymbols$2)
151
+ for (var prop of __getOwnPropSymbols$2(source)) {
152
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
153
+ target[prop] = source[prop];
154
+ }
155
+ return target;
17
156
  };
157
+ function watchPausable(source, cb, options = {}) {
158
+ const _a = options, {
159
+ eventFilter: filter
160
+ } = _a, watchOptions = __objRest$1(_a, [
161
+ "eventFilter"
162
+ ]);
163
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
164
+ const stop = watchWithFilter(source, cb, __spreadProps$2(__spreadValues$2({}, watchOptions), {
165
+ eventFilter
166
+ }));
167
+ return { stop, pause, resume, isActive };
168
+ }
169
+
170
+ var _sfc_main$1 = defineComponent({
171
+ props: {
172
+ modelValue: {
173
+ type: String,
174
+ default: ""
175
+ }
176
+ },
177
+ emits: {
178
+ "update:modelValue": null
179
+ },
180
+ setup(props, { emit }) {
181
+ const vditor = useVditor();
182
+ const mitter = useVditorMitter();
183
+ if (props.modelValue) {
184
+ vditor.setValue(props.modelValue, true);
185
+ }
186
+ const { pause, resume } = watchPausable(() => props.modelValue, (value) => {
187
+ vditor.setValue(value, true);
188
+ });
189
+ mitter.on("input", (value) => {
190
+ pause();
191
+ emit("update:modelValue", value);
192
+ nextTick(resume);
193
+ });
194
+ return () => null;
195
+ }
196
+ });
197
+
198
+ var HandleValue = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/vditor/src/handle-value.vue"]]);
18
199
 
19
200
  var _sfc_main = defineComponent({
20
201
  name: "VkfVditor",
21
- emits,
202
+ components: {
203
+ HandleValue,
204
+ VkAsyncTeleport
205
+ },
22
206
  props,
207
+ emits,
23
208
  setup(props2, { emit }) {
24
209
  const vditorNode = ref();
25
210
  const ready = ref(false);
211
+ const mitter = mitt();
212
+ const vditorRef = shallowRef();
213
+ const isTextareaFocus = ref(false);
214
+ provide("vkfVditorMitter", mitter);
215
+ provide("vkfVditorRef", vditorRef);
26
216
  onMounted(() => {
27
217
  const vditor = new Vditor(vditorNode.value, {
28
218
  ...props2.defaultOptions,
219
+ placeholder: props2.placeholder,
29
220
  cache: {
30
221
  enable: true,
31
222
  id: "VkfVditorCache",
32
223
  ...props2.defaultOptions.cache || {}
33
224
  },
34
225
  after() {
226
+ vditorRef.value = vditor;
35
227
  ready.value = true;
36
228
  emit("load", vditor);
37
- provide("vkfVditor", vditor);
38
229
  props2.defaultOptions.after?.();
39
- }
230
+ },
231
+ input(value) {
232
+ mitter.emit("input", value);
233
+ props2.defaultOptions.input?.(value);
234
+ },
235
+ ctrlEnter(value) {
236
+ emit("ctrlEnter", value);
237
+ },
238
+ focus(v) {
239
+ isTextareaFocus.value = true;
240
+ props2.defaultOptions.focus?.(v);
241
+ },
242
+ blur(v) {
243
+ isTextareaFocus.value = false;
244
+ props2.defaultOptions.blur?.(v);
245
+ },
246
+ toolbar: props2.toolbar
40
247
  });
41
248
  });
42
249
  return {
43
- vditorNode
250
+ vditorNode,
251
+ isTextareaFocus,
252
+ ready
44
253
  };
45
254
  }
46
255
  });
47
256
 
48
- const _hoisted_1 = { ref: "vditorNode" };
257
+ const _hoisted_1 = {
258
+ ref: "vditorNode",
259
+ class: "vkf-vditor"
260
+ };
49
261
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
262
+ const _component_VkAsyncTeleport = resolveComponent("VkAsyncTeleport");
263
+ const _component_HandleValue = resolveComponent("HandleValue");
50
264
  return openBlock(), createElementBlock(
51
- "div",
52
- _hoisted_1,
265
+ Fragment,
53
266
  null,
54
- 512
55
- /* NEED_PATCH */
267
+ [
268
+ createElementVNode(
269
+ "div",
270
+ _hoisted_1,
271
+ null,
272
+ 512
273
+ /* NEED_PATCH */
274
+ ),
275
+ _ctx.ready ? (openBlock(), createBlock(_component_VkAsyncTeleport, {
276
+ key: 0,
277
+ to: _ctx.vditorNode
278
+ }, {
279
+ default: withCtx(() => [
280
+ createElementVNode(
281
+ "div",
282
+ {
283
+ class: normalizeClass(["vkf-vditor-footer", {
284
+ "is-textarea-focus": _ctx.isTextareaFocus
285
+ }])
286
+ },
287
+ [
288
+ renderSlot(_ctx.$slots, "footer")
289
+ ],
290
+ 2
291
+ /* CLASS */
292
+ )
293
+ ]),
294
+ _: 3
295
+ /* FORWARDED */
296
+ }, 8, ["to"])) : createCommentVNode("v-if", true),
297
+ _ctx.ready ? (openBlock(), createBlock(_component_HandleValue, {
298
+ key: 1,
299
+ "model-value": _ctx.modelValue,
300
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", $event))
301
+ }, null, 8, ["model-value"])) : createCommentVNode("v-if", true),
302
+ _ctx.ready ? renderSlot(_ctx.$slots, "default", { key: 2 }) : createCommentVNode("v-if", true)
303
+ ],
304
+ 64
305
+ /* STABLE_FRAGMENT */
56
306
  );
57
307
  }
58
308
  var VkfVditor = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/vditor/src/index.vue"]]);
@@ -62,7 +312,7 @@ var types = /*#__PURE__*/Object.freeze({
62
312
  });
63
313
 
64
314
  VkfVditor.install = (app) => {
65
- app.component(VkfVditor.name, VkfVditor);
315
+ app.component(VkfVditor.name || "VkfVditor", VkfVditor);
66
316
  };
67
317
 
68
318
  export { VkfVditor, types as __VkfVditor, VkfVditor as default };
@@ -3,14 +3,24 @@ import { DefaultOptions } from './types';
3
3
  import Vditor from 'vditor';
4
4
  export declare const props: {
5
5
  modelValue: {
6
- type: PropType<unknown>;
7
- default: () => {};
6
+ type: StringConstructor;
7
+ default: string;
8
8
  };
9
9
  defaultOptions: {
10
10
  type: PropType<DefaultOptions>;
11
11
  default: () => IOptions;
12
12
  };
13
+ placeholder: {
14
+ type: StringConstructor;
15
+ default: string;
16
+ };
17
+ toolbar: {
18
+ type: PropType<string[]>;
19
+ default: () => string[];
20
+ };
13
21
  };
14
22
  export declare const emits: {
15
23
  load: (e: Vditor) => Vditor;
24
+ 'update:modelValue': (e: string) => string;
25
+ ctrlEnter: (e: string) => string;
16
26
  };
@@ -0,0 +1,18 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ modelValue: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ }, () => any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ 'update:modelValue': any;
8
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
+ modelValue: {
10
+ type: StringConstructor;
11
+ default: string;
12
+ };
13
+ }>> & {
14
+ "onUpdate:modelValue"?: (...args: any[] | unknown[]) => any;
15
+ }, {
16
+ modelValue: string;
17
+ }, {}>;
18
+ export default _default;
@@ -2,30 +2,54 @@ import Vditor from 'vditor';
2
2
  import { Ref } from 'vue';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  modelValue: {
5
- type: import("vue").PropType<unknown>;
6
- default: () => {};
5
+ type: StringConstructor;
6
+ default: string;
7
7
  };
8
8
  defaultOptions: {
9
9
  type: import("vue").PropType<import("./types").DefaultOptions>;
10
10
  default: () => IOptions;
11
11
  };
12
+ placeholder: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ toolbar: {
17
+ type: import("vue").PropType<string[]>;
18
+ default: () => string[];
19
+ };
12
20
  }, {
13
21
  vditorNode: Ref<HTMLDivElement>;
22
+ isTextareaFocus: Ref<boolean>;
23
+ ready: Ref<boolean>;
14
24
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
25
  load: (e: Vditor) => Vditor;
26
+ 'update:modelValue': (e: string) => string;
27
+ ctrlEnter: (e: string) => string;
16
28
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
17
29
  modelValue: {
18
- type: import("vue").PropType<unknown>;
19
- default: () => {};
30
+ type: StringConstructor;
31
+ default: string;
20
32
  };
21
33
  defaultOptions: {
22
34
  type: import("vue").PropType<import("./types").DefaultOptions>;
23
35
  default: () => IOptions;
24
36
  };
37
+ placeholder: {
38
+ type: StringConstructor;
39
+ default: string;
40
+ };
41
+ toolbar: {
42
+ type: import("vue").PropType<string[]>;
43
+ default: () => string[];
44
+ };
25
45
  }>> & {
46
+ "onUpdate:modelValue"?: (e: string) => any;
26
47
  onLoad?: (e: Vditor) => any;
48
+ onCtrlEnter?: (e: string) => any;
27
49
  }, {
28
- modelValue: {};
50
+ placeholder: string;
51
+ modelValue: string;
29
52
  defaultOptions: IOptions;
53
+ toolbar: string[];
30
54
  }, {}>;
31
55
  export default _default;
@@ -1,4 +1,9 @@
1
1
  import { NonVoidable } from '@vunk/core';
2
2
  import Vditor from 'vditor';
3
+ import { Emitter } from 'mitt';
3
4
  export type DefaultOptions = NonVoidable<ConstructorParameters<typeof Vditor>[1]>;
5
+ export type Toolbar = DefaultOptions['toolbar'];
6
+ export type Mitter = Emitter<{
7
+ input: string;
8
+ }>;
4
9
  export {};
@@ -0,0 +1,4 @@
1
+ import Vditor from 'vditor';
2
+ import { Mitter } from './types';
3
+ export declare const useVditor: () => Vditor;
4
+ export declare const useVditorMitter: () => Mitter;
package/index.css CHANGED
@@ -439,3 +439,16 @@
439
439
  padding-left: var(--date-picker-title-padding);
440
440
  padding-right: var(--date-picker-title-padding);
441
441
  }
442
+
443
+ .vkf-vditor ul,li {
444
+ list-style: initial;
445
+ }
446
+ .vkf-vditor ol,li {
447
+ list-style: decimal;
448
+ }
449
+ .vkf-vditor.vditor{
450
+ --textarea-background-color: var(--el-fill-color-extra-light);
451
+ }
452
+ .vkf-vditor-footer.is-textarea-focus{
453
+ background-color: var(--textarea-background-color);
454
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "1.1.80",
3
+ "version": "1.1.82",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {
@@ -213,6 +213,9 @@
213
213
  "./index.css": {
214
214
  "import": "./index.css"
215
215
  },
216
+ "./components/vditor/index.css": {
217
+ "import": "./components/vditor/index.css"
218
+ },
216
219
  "./components/var-datetime-picker/index.css": {
217
220
  "import": "./components/var-datetime-picker/index.css"
218
221
  },