@opentiny/vue-renderless 3.13.2 → 3.14.1
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/action-sheet/index.js +20 -13
- package/action-sheet/vue.js +8 -7
- package/amount/index.js +100 -25
- package/amount/vue.js +102 -26
- package/anchor/index.js +1 -0
- package/area/index.js +8 -8
- package/area/vue.js +5 -5
- package/async-flowchart/index.js +16 -3
- package/autocomplete/index.js +58 -14
- package/autocomplete/vue.js +40 -12
- package/badge/index.js +12 -0
- package/badge/vue.js +6 -4
- package/breadcrumb/vue.js +3 -1
- package/breadcrumb-item/vue.js +6 -2
- package/button/index.js +5 -1
- package/calendar/index.js +2 -86
- package/calendar-bar/index.js +18 -4
- package/calendar-view/index.js +5 -1
- package/calendar-view/vue.js +16 -3
- package/card-group/vue.js +4 -2
- package/cascader/index.js +86 -34
- package/cascader/vue.js +61 -20
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +36 -23
- package/cascader-mobile/vue.js +6 -0
- package/cascader-node/index.js +13 -1
- package/cascader-node/vue.js +15 -4
- package/cascader-panel/index.js +1 -1
- package/cascader-select/column-index.js +150 -0
- package/cascader-select/column.js +120 -0
- package/cascader-select/index.js +29 -165
- package/cascader-select/usePicker.js +251 -0
- package/cascader-select/useTouch.js +65 -0
- package/cascader-select/vue.js +35 -47
- package/cell/vue.js +2 -1
- package/chart-bar/index.js +2 -3
- package/chart-core/deps/constants.js +43 -43
- package/chart-core/index.js +1 -1
- package/chart-gauge/index.js +2 -2
- package/chart-heatmap/index.js +17 -10
- package/chart-line/index.js +8 -9
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +4 -6
- package/checkbox/index.js +18 -1
- package/checkbox/vue.js +15 -7
- package/checkbox-group/vue.js +1 -0
- package/col/vue.js +1 -1
- package/collapse/index.js +3 -3
- package/color-select-panel/vue.js +0 -7
- package/column-list-item/index.js +17 -1
- package/column-list-item/vue.js +8 -3
- package/common/bigInt.js +2 -2
- package/common/date.js +7 -5
- package/common/deps/clickoutside.js +6 -2
- package/common/deps/date-util.js +4 -2
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +44 -11
- package/common/deps/resize-event.js +1 -0
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +2 -2
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +38 -20
- package/common/index.js +2 -2
- package/common/runtime.js +1 -1
- package/common/string.js +2 -2
- package/common/type.js +2 -1
- package/common/validate/rules/enum.js +1 -1
- package/common/validate/rules/pattern.js +2 -2
- package/common/validate/rules/range.js +8 -5
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +5 -5
- package/common/validate/rules/whitespace.js +1 -1
- package/common/validate/util.js +15 -16
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/currency/index.js +74 -7
- package/currency/vue.js +21 -5
- package/date-panel/index.js +16 -0
- package/date-panel/vue.js +8 -2
- package/date-picker-mobile/index.js +12 -0
- package/date-picker-mobile/vue.js +7 -1
- package/date-range/vue.js +15 -6
- package/date-table/index.js +35 -53
- package/date-table/vue.js +4 -2
- package/dialog-box/index.js +46 -14
- package/dialog-box/vue.js +30 -7
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +27 -5
- package/drawer/vue.js +14 -7
- package/dropdown/index.js +7 -7
- package/dropdown/vue.js +6 -2
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +6 -10
- package/dropdown-item/vue.js +20 -7
- package/dropdown-menu/index.js +20 -7
- package/dropdown-menu/vue.js +4 -3
- package/exception/index.js +2 -7
- package/exception/vue.js +7 -10
- package/fall-menu/index.js +5 -1
- package/fall-menu/vue.js +13 -2
- package/file-upload/index.js +68 -18
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -0
- package/float-button/index.js +42 -0
- package/float-button/vue.js +101 -0
- package/floating-button/index.js +62 -16
- package/floating-button/vue.js +27 -9
- package/flowchart/index.js +134 -25
- package/flowchart/node.js +13 -4
- package/flowchart/vue.js +16 -4
- package/form/vue.js +8 -0
- package/form-item/index.js +5 -5
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/plugins/export.js +5 -2
- package/grid/utils/column.js +1 -0
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -1
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +81 -20
- package/input/vue.js +44 -18
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/link/vue.js +3 -1
- package/loading/index.js +2 -2
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/menu/index.js +15 -2
- package/menu/vue.js +22 -17
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/modal/index.js +44 -4
- package/modal/vue.js +18 -4
- package/multi-select/index.js +186 -11
- package/multi-select/vue.js +60 -15
- package/multi-select-item/index.js +23 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +48 -12
- package/numeric/vue.js +44 -19
- package/option/index.js +27 -9
- package/option/vue.js +37 -21
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +18 -4
- package/pager/vue.js +16 -5
- package/picker/index.js +290 -77
- package/picker/mb.js +42 -0
- package/picker/vue.js +76 -20
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +3 -0
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +73 -34
- package/popeditor/vue.js +15 -11
- package/popover/index.js +4 -4
- package/popover/vue.js +6 -6
- package/popup/index.js +3 -3
- package/popup/vue.js +5 -5
- package/pull-refresh/index.js +13 -13
- package/pull-refresh/vue.js +5 -4
- package/radio/index.js +0 -17
- package/radio/vue.js +4 -10
- package/rate/index.js +1 -1
- package/rate/vue.js +0 -2
- package/record/index.js +4 -1
- package/rich-text/clipboard.js +54 -0
- package/rich-text/index.js +192 -0
- package/rich-text/module/file-upload.js +107 -0
- package/rich-text/module/image-drop.js +63 -0
- package/rich-text/module/image-upload.js +89 -0
- package/rich-text/options.js +141 -0
- package/rich-text/table-module.js +382 -0
- package/rich-text/vue.js +102 -0
- package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
- package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
- package/scrollbar/index.js +11 -11
- package/scrollbar/vue-bar.js +3 -3
- package/scrollbar/vue.js +5 -5
- package/search/index.js +9 -9
- package/search/vue.js +8 -6
- package/select/index.js +442 -393
- package/select/vue.js +278 -164
- package/select-dropdown/index.js +61 -3
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- package/selected-box/index.js +2 -0
- package/selected-box/vue.js +6 -3
- package/signature/index.js +241 -0
- package/signature/vue.js +88 -0
- package/skeleton/index.js +14 -0
- package/skeleton/vue.js +15 -0
- package/skeleton-item/vue.js +15 -0
- package/slider/index.js +70 -17
- package/slider/vue.js +16 -7
- package/split/index.js +5 -3
- package/split/vue.js +4 -6
- package/standard-list-item/index.js +15 -1
- package/standard-list-item/vue.js +6 -5
- package/steps/index.js +25 -2
- package/steps/slide-bar.js +8 -1
- package/steps/vue.js +15 -3
- package/tab-item-mf/vue.js +14 -8
- package/tab-nav/index.js +30 -5
- package/tab-nav/vue.js +16 -4
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +16 -4
- package/tabs/vue.js +2 -1
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tabs-mf/wheel.js +1 -0
- package/tag/index.js +1 -1
- package/tag-group/index.js +2 -1
- package/time/index.js +5 -2
- package/time/vue.js +1 -1
- package/time-line/index.js +3 -3
- package/time-line/vue.js +2 -2
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +6 -3
- package/tooltip/vue.js +4 -4
- package/transfer/index.js +20 -22
- package/transfer/vue.js +1 -6
- package/transfer-panel/vue.js +3 -5
- package/tree/index.js +21 -4
- package/tree/vue.js +10 -8
- package/tree-menu/index.js +29 -3
- package/tree-menu/vue.js +28 -15
- package/tree-node/index.js +18 -18
- package/tree-node/vue.js +6 -5
- package/types/action-sheet.type.d.ts +118 -1
- package/types/amount.type.d.ts +168 -1
- package/types/area.type.d.ts +134 -1
- package/types/async-flowchart.type.d.ts +72 -0
- package/types/autocomplete.type.d.ts +199 -1
- package/types/badge.type.d.ts +3 -1
- package/types/breadcrumb-item.type.d.ts +2 -0
- package/types/breadcrumb.type.d.ts +2 -0
- package/types/button-group.type.d.ts +3 -3
- package/types/button.type.d.ts +4 -0
- package/types/cascader-menu.type.d.ts +3 -4
- package/types/cascader-node.type.d.ts +5 -2
- package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
- package/types/cascader-panel.type.d.ts +3 -241
- package/types/cascader.type.d.ts +329 -1
- package/types/checkbox.type.d.ts +6 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +38 -1
- package/types/dialog-box.type.d.ts +13 -3
- package/types/drawer.type.d.ts +133 -1
- package/types/{dropdown-item.type-8ea6c633.d.ts → dropdown-item.type-8475a549.d.ts} +7 -13
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +1 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/float-button.type.d.ts +123 -0
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-a2dc0099.d.ts} +4 -1
- package/types/form.type.d.ts +1 -1
- package/types/{index-e0250f63.d.ts → index-b012f687.d.ts} +9 -0
- package/types/input.type.d.ts +2 -6
- package/types/ip-address.type.d.ts +160 -1
- package/types/link.type.d.ts +6 -3
- package/types/loading.type.d.ts +7 -0
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +29 -2
- package/types/numeric.type.d.ts +41 -10
- package/types/pager.type.d.ts +12 -0
- package/types/picker.type.d.ts +18 -0
- package/types/popconfirm.type.d.ts +86 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +2 -0
- package/types/radio.type.d.ts +0 -4
- package/types/rate.type.d.ts +236 -1
- package/types/search.type.d.ts +88 -1
- package/types/shared.type.d.ts +1 -1
- package/types/skeleton-item.type.d.ts +38 -0
- package/types/skeleton.type.d.ts +45 -0
- package/types/slider.type.d.ts +49 -10
- package/types/steps.type.d.ts +14 -3
- package/types/tab-bar.type.d.ts +1 -1
- package/types/tab-nav.type.d.ts +7 -2
- package/types/tabs.type.d.ts +9 -1
- package/types/tag-group.type.d.ts +64 -1
- package/types/{time-line.type-d7daa669.d.ts → time-line.type-b155cb4f.d.ts} +12 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/tooltip.type.d.ts +2 -2
- package/types/transfer.type.d.ts +185 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-6d6e3d0e.d.ts} +35 -8
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-head.type.d.ts +146 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +64 -34
- package/upload/vue.js +9 -5
- package/upload-dragger/index.js +22 -20
- package/upload-list/index.js +24 -18
- package/upload-list/vue.js +9 -4
- package/user/index.js +35 -26
- package/user/vue.js +1 -1
- package/user-head/index.js +3 -3
- package/watermark/index.js +11 -0
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
- package/common/deps/modal-queue.js +0 -6
- package/common/deps/requestAnimationFrame.js +0 -25
package/popover/vue.js
CHANGED
|
@@ -52,7 +52,7 @@ const initState = ({
|
|
|
52
52
|
});
|
|
53
53
|
return state;
|
|
54
54
|
};
|
|
55
|
-
const initApi = ({ api: api2, props, state,
|
|
55
|
+
const initApi = ({ api: api2, props, state, emit, doDestroy, constants, nextTick, vm, mode }) => {
|
|
56
56
|
Object.assign(api2, {
|
|
57
57
|
state,
|
|
58
58
|
mounted: mounted({ api: api2, state, constants, props, nextTick, mode }),
|
|
@@ -71,8 +71,8 @@ const initApi = ({ api: api2, props, state, refs, emit, doDestroy, constants, ne
|
|
|
71
71
|
handleMouseLeave: handleMouseLeave({ props, state }),
|
|
72
72
|
handleAfterLeave: handleAfterLeave(emit),
|
|
73
73
|
handleMouseEnter: handleMouseEnter({ props, state }),
|
|
74
|
-
handleDocumentClick: handleDocumentClick({
|
|
75
|
-
wrapMounted: wrapMounted({ api: api2, props,
|
|
74
|
+
handleDocumentClick: handleDocumentClick({ vm, state }),
|
|
75
|
+
wrapMounted: wrapMounted({ api: api2, props, vm, state }),
|
|
76
76
|
handleItemClick: handleItemClick({ emit, state }),
|
|
77
77
|
observeCallback: observeCallback({ vm, state })
|
|
78
78
|
});
|
|
@@ -130,13 +130,13 @@ const renderless = (props, {
|
|
|
130
130
|
onUnmounted,
|
|
131
131
|
onActivated,
|
|
132
132
|
onDeactivated
|
|
133
|
-
}, { $prefix, emit, vm,
|
|
133
|
+
}, { $prefix, emit, vm, slots, nextTick, mode }) => {
|
|
134
134
|
const api2 = {};
|
|
135
135
|
const constants = { IDPREFIX: `${$prefix.toLowerCase()}-popover` };
|
|
136
|
-
const options = { emit, onBeforeUnmount, nextTick, reactive, props, watch, onDeactivated,
|
|
136
|
+
const options = { emit, onBeforeUnmount, nextTick, reactive, props, watch, onDeactivated, vm, slots, toRefs };
|
|
137
137
|
const { showPopper, popperElm, referenceElm, doDestroy, updatePopper } = userPopper(options);
|
|
138
138
|
const state = initState({ reactive, computed, api: api2, popperElm, showPopper, referenceElm });
|
|
139
|
-
initApi({ api: api2, constants, props, state,
|
|
139
|
+
initApi({ api: api2, constants, props, state, emit, doDestroy, nextTick, vm, mode });
|
|
140
140
|
onDeactivated(() => {
|
|
141
141
|
api2.destroyed();
|
|
142
142
|
api2.cleanup();
|
package/popup/index.js
CHANGED
|
@@ -52,10 +52,10 @@ const close = ({ api, constants, emit, props, state }) => () => {
|
|
|
52
52
|
emit("update:modelValue", false);
|
|
53
53
|
emit("close");
|
|
54
54
|
};
|
|
55
|
-
const onTouchMove = ({
|
|
55
|
+
const onTouchMove = ({ vm, state }) => (event) => {
|
|
56
56
|
touchMove(event);
|
|
57
57
|
const direction = state.deltaY > 0 ? "10" : "01";
|
|
58
|
-
const el = getScroller()(event.target, refs.$el);
|
|
58
|
+
const el = getScroller()(event.target, vm.$refs.$el);
|
|
59
59
|
const { scrollHeight, offsetHeight, scrollTop } = el;
|
|
60
60
|
let status = "11";
|
|
61
61
|
if (scrollTop === 0) {
|
|
@@ -78,7 +78,7 @@ const renderOverlay = ({ api, nextTick, props, state }) => () => {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
const updateZIndex = ({
|
|
81
|
+
const updateZIndex = ({ vm, state }) => (value = 0) => vm.$refs.popup.style.zIndex = ++state.context.zIndex + value;
|
|
82
82
|
const clickOverlay = ({ api, props, emit }) => () => {
|
|
83
83
|
if (props.closeOnClickOverlay) {
|
|
84
84
|
api.close();
|
package/popup/vue.js
CHANGED
|
@@ -38,25 +38,25 @@ const initState = ({ reactive, computed, props, api: api2 }) => {
|
|
|
38
38
|
});
|
|
39
39
|
return state;
|
|
40
40
|
};
|
|
41
|
-
const initApi = ({ api: api2, props, state,
|
|
41
|
+
const initApi = ({ api: api2, props, state, vm, emit, nextTick, constants }) => {
|
|
42
42
|
Object.assign(api2, {
|
|
43
43
|
state,
|
|
44
44
|
opened: opened(emit),
|
|
45
45
|
closed: closed(emit),
|
|
46
46
|
getStyle: getStyle(props),
|
|
47
47
|
watchValue: watchValue(api2),
|
|
48
|
-
updateZIndex: updateZIndex({
|
|
48
|
+
updateZIndex: updateZIndex({ vm, state }),
|
|
49
49
|
clickOverlay: clickOverlay({ api: api2, emit, props }),
|
|
50
50
|
renderOverlay: renderOverlay({ api: api2, nextTick, props, state }),
|
|
51
|
-
onTouchMove: onTouchMove({
|
|
51
|
+
onTouchMove: onTouchMove({ vm, state }),
|
|
52
52
|
open: open({ api: api2, constants, emit, props, state }),
|
|
53
53
|
close: close({ api: api2, constants, emit, props, state })
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
-
const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { constants,
|
|
56
|
+
const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { constants, vm, emit }) => {
|
|
57
57
|
const api2 = {};
|
|
58
58
|
const state = initState({ reactive, computed, props, api: api2 });
|
|
59
|
-
initApi({ api: api2, props, state,
|
|
59
|
+
initApi({ api: api2, props, state, vm, emit, nextTick, constants });
|
|
60
60
|
watch(() => props.modelValue, api2.watchValue, { immediate: true });
|
|
61
61
|
onMounted(() => {
|
|
62
62
|
props.modelValue && api2.open();
|
package/pull-refresh/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
__spreadValues
|
|
3
3
|
} from "../chunk-G2ADBYYC.js";
|
|
4
4
|
import { on, off } from "../common/deps/dom";
|
|
5
|
+
const PULL_UP_TIME_OUT = 300;
|
|
5
6
|
const initPullRefresh = ({ t, props, state }) => () => {
|
|
6
7
|
var _a, _b, _c;
|
|
7
8
|
const defaultOption = {
|
|
@@ -21,22 +22,15 @@ const onTouchstart = (state) => (event) => {
|
|
|
21
22
|
state.draggposition = event.touches[0].clientY;
|
|
22
23
|
};
|
|
23
24
|
const onTouchmove = ({ state, refs }) => (event) => {
|
|
24
|
-
if (event.touches[0].clientY
|
|
25
|
-
pullUpTouchMove(state);
|
|
26
|
-
} else {
|
|
25
|
+
if (event.touches[0].clientY > state.draggposition) {
|
|
27
26
|
pullDownTouchMove(state, refs, event);
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
const pullUpTouchMove = (state) => {
|
|
31
|
-
if (state.disabledPullUp || state.pullUpLoading || !state.hasMore) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
29
|
const pullDownTouchMove = (state, refs, event) => {
|
|
36
30
|
if (state.disabledPullDown || state.pullDownLoading) {
|
|
37
31
|
return;
|
|
38
32
|
}
|
|
39
|
-
if (refs.content.scrollTop <= 0) {
|
|
33
|
+
if (refs.content.scrollTop <= 0 && window.scrollY <= 0 && event.cancelable) {
|
|
40
34
|
event.preventDefault();
|
|
41
35
|
state.translate3d = (event.touches[0].clientY - state.draggposition) / 2;
|
|
42
36
|
state.pullDownReplaces = Math.abs(state.translate3d) > state.pullDown.headHeight ? state.loosingText : state.pullDown.pullingDownText;
|
|
@@ -63,7 +57,8 @@ const pullDownTouchEnd = (api, state, emit) => {
|
|
|
63
57
|
emit("pullDown");
|
|
64
58
|
};
|
|
65
59
|
const pullUpTouchEnd = (state, emit, refs) => {
|
|
66
|
-
|
|
60
|
+
clearTimeout(state.timer);
|
|
61
|
+
state.timer = setTimeout(() => {
|
|
67
62
|
const footNode = refs.foot;
|
|
68
63
|
if (!state.hasMore || !footNode) {
|
|
69
64
|
return;
|
|
@@ -75,19 +70,24 @@ const pullUpTouchEnd = (state, emit, refs) => {
|
|
|
75
70
|
emit("update:modelValue", true);
|
|
76
71
|
emit("pullUp");
|
|
77
72
|
}
|
|
78
|
-
},
|
|
73
|
+
}, PULL_UP_TIME_OUT);
|
|
74
|
+
};
|
|
75
|
+
const onScroll = ({ state, emit, refs }) => () => {
|
|
76
|
+
pullUpTouchEnd(state, emit, refs);
|
|
79
77
|
};
|
|
80
78
|
const mountedHandler = ({ api, refs }) => () => {
|
|
81
79
|
const track = refs.track;
|
|
82
80
|
on(track, "touchstart", api.onTouchstart);
|
|
83
81
|
on(track, "touchmove", api.onTouchmove);
|
|
84
82
|
on(track, "touchend", api.onTouchend);
|
|
83
|
+
on(track, "scroll", api.onScroll);
|
|
85
84
|
};
|
|
86
85
|
const beforeUnmountHandler = ({ api, refs }) => () => {
|
|
87
86
|
const track = refs.track;
|
|
88
87
|
off(track, "touchstart", api.onTouchstart);
|
|
89
88
|
off(track, "touchmove", api.onTouchmove);
|
|
90
89
|
off(track, "touchend", api.onTouchend);
|
|
90
|
+
off(track, "scroll", api.onScroll);
|
|
91
91
|
};
|
|
92
92
|
const handlerModelValue = ({ api, state }) => (value, result) => {
|
|
93
93
|
state.pullUpLoading = false;
|
|
@@ -113,11 +113,11 @@ export {
|
|
|
113
113
|
handlerModelValue,
|
|
114
114
|
initPullRefresh,
|
|
115
115
|
mountedHandler,
|
|
116
|
+
onScroll,
|
|
116
117
|
onTouchend,
|
|
117
118
|
onTouchmove,
|
|
118
119
|
onTouchstart,
|
|
119
120
|
pullDownTouchEnd,
|
|
120
121
|
pullDownTouchMove,
|
|
121
|
-
pullUpTouchEnd
|
|
122
|
-
pullUpTouchMove
|
|
122
|
+
pullUpTouchEnd
|
|
123
123
|
};
|
package/pull-refresh/vue.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
onTouchstart,
|
|
7
7
|
onTouchmove,
|
|
8
8
|
onTouchend,
|
|
9
|
+
onScroll,
|
|
9
10
|
initPullRefresh,
|
|
10
11
|
clearPullRefresh
|
|
11
12
|
} from "./index";
|
|
@@ -32,13 +33,15 @@ const renderless = (props, { watch, onMounted, reactive, onBeforeUnmount }, { t,
|
|
|
32
33
|
animationDuration: props.animationDuration,
|
|
33
34
|
disabledPullDown: props.disabledPullDown,
|
|
34
35
|
disabledPullUp: props.disabledPullUp,
|
|
35
|
-
pullUpDistance: typeof props.pullUpDistance === "string" ? Number(props.pullUpDistance) : props.pullUpDistance
|
|
36
|
+
pullUpDistance: typeof props.pullUpDistance === "string" ? Number(props.pullUpDistance) : props.pullUpDistance,
|
|
37
|
+
timer: null
|
|
36
38
|
});
|
|
37
39
|
Object.assign(api2, {
|
|
38
40
|
state,
|
|
39
41
|
onTouchstart: onTouchstart(state),
|
|
40
42
|
onTouchmove: onTouchmove({ state, refs }),
|
|
41
43
|
onTouchend: onTouchend({ api: api2, props, state, emit, refs }),
|
|
44
|
+
onScroll: onScroll({ state, emit, refs }),
|
|
42
45
|
mountedHandler: mountedHandler({ api: api2, refs }),
|
|
43
46
|
beforeUnmountHandler: beforeUnmountHandler({ api: api2, refs }),
|
|
44
47
|
handlerModelValue: handlerModelValue({ api: api2, state }),
|
|
@@ -48,9 +51,7 @@ const renderless = (props, { watch, onMounted, reactive, onBeforeUnmount }, { t,
|
|
|
48
51
|
watch(
|
|
49
52
|
() => props.hasMore,
|
|
50
53
|
(value) => {
|
|
51
|
-
|
|
52
|
-
state.hasMore = false;
|
|
53
|
-
}
|
|
54
|
+
state.hasMore = value;
|
|
54
55
|
},
|
|
55
56
|
{ immediate: true }
|
|
56
57
|
);
|
package/radio/index.js
CHANGED
|
@@ -61,24 +61,7 @@ const toggleEvent = ({ props, vm, type }) => {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
const dispatchDisplayedValue = ({ state, dispatch, api }) => () => {
|
|
65
|
-
if (state.isDisplayOnly) {
|
|
66
|
-
dispatch("FormItem", "displayed-value-changed", {
|
|
67
|
-
type: "radio",
|
|
68
|
-
val: api.getDisplayedValue()
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const getDisplayedValue = ({ vm, state, props }) => () => {
|
|
73
|
-
if (state.model === props.label) {
|
|
74
|
-
return vm.$refs.label && vm.$refs.label.innerText || props.text || props.label;
|
|
75
|
-
} else {
|
|
76
|
-
return "";
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
64
|
export {
|
|
80
|
-
dispatchDisplayedValue,
|
|
81
|
-
getDisplayedValue,
|
|
82
65
|
getModel,
|
|
83
66
|
handleChange,
|
|
84
67
|
isDisabled,
|
package/radio/vue.js
CHANGED
|
@@ -8,17 +8,15 @@ import {
|
|
|
8
8
|
tabIndex,
|
|
9
9
|
getModel,
|
|
10
10
|
setModel,
|
|
11
|
-
toggleEvent
|
|
12
|
-
dispatchDisplayedValue,
|
|
13
|
-
getDisplayedValue
|
|
11
|
+
toggleEvent
|
|
14
12
|
} from "./index";
|
|
15
13
|
const api = ["state", "handleChange"];
|
|
16
|
-
const renderless = (props, { onMounted, onBeforeUnmount, computed, reactive, inject
|
|
14
|
+
const renderless = (props, { onMounted, onBeforeUnmount, computed, reactive, inject }, { vm, parent, emit, constants, nextTick, dispatch }) => {
|
|
17
15
|
parent.tinyForm = parent.tinyForm || inject("form", null);
|
|
18
16
|
const api2 = {};
|
|
19
17
|
const state = reactive({
|
|
20
18
|
vertical: inject("radioVertical", false),
|
|
21
|
-
size: props.size || inject("size", null),
|
|
19
|
+
size: computed(() => props.size || inject("size", null) || (parent.tinyForm || {}).size),
|
|
22
20
|
focus: false,
|
|
23
21
|
radioGroup: null,
|
|
24
22
|
isGroup: computed(() => api2.isGroup()),
|
|
@@ -41,13 +39,9 @@ const renderless = (props, { onMounted, onBeforeUnmount, computed, reactive, inj
|
|
|
41
39
|
isDisabled: isDisabled({ props, state }),
|
|
42
40
|
isDisplayOnly: isDisplayOnly({ props }),
|
|
43
41
|
setModel: setModel({ constants, dispatch, emit, props, vm, state }),
|
|
44
|
-
handleChange: handleChange({ constants, dispatch, emit, state, nextTick })
|
|
45
|
-
dispatchDisplayedValue: dispatchDisplayedValue({ state, api: api2, dispatch }),
|
|
46
|
-
getDisplayedValue: getDisplayedValue({ vm, state, props })
|
|
42
|
+
handleChange: handleChange({ constants, dispatch, emit, state, nextTick })
|
|
47
43
|
});
|
|
48
|
-
watch(() => state.isDisplayOnly, api2.dispatchDisplayedValue);
|
|
49
44
|
onMounted(() => {
|
|
50
|
-
api2.dispatchDisplayedValue();
|
|
51
45
|
dispatch("Tooltip", "tooltip-update");
|
|
52
46
|
toggleEvent({ props, vm, type: "add" });
|
|
53
47
|
});
|
package/rate/index.js
CHANGED
|
@@ -136,7 +136,7 @@ const computedText = ({ props, state }) => {
|
|
|
136
136
|
currentValue = props.texts.length;
|
|
137
137
|
}
|
|
138
138
|
if (props.showScore) {
|
|
139
|
-
result = props.scoreTemplate.replace(/\{\s*value\s*\}/, currentValue);
|
|
139
|
+
result = props.scoreTemplate.replace(/\{\s*value\s*\}/, String(currentValue));
|
|
140
140
|
return result;
|
|
141
141
|
}
|
|
142
142
|
if (props.showText && currentValue > 0) {
|
package/rate/vue.js
CHANGED
|
@@ -30,7 +30,6 @@ const api = [
|
|
|
30
30
|
"resetCurrentValue"
|
|
31
31
|
];
|
|
32
32
|
const useChangeValue = ({
|
|
33
|
-
computed,
|
|
34
33
|
constants,
|
|
35
34
|
emit,
|
|
36
35
|
props,
|
|
@@ -85,7 +84,6 @@ const useChangeValue = ({
|
|
|
85
84
|
const renderless = (props, { computed, reactive, toRefs, watch, onMounted, onUnmounted, inject }, { constants, emit, parent }) => {
|
|
86
85
|
const api2 = {};
|
|
87
86
|
const changeValue = useChangeValue({
|
|
88
|
-
computed,
|
|
89
87
|
constants,
|
|
90
88
|
emit,
|
|
91
89
|
props,
|
package/record/index.js
CHANGED
|
@@ -148,7 +148,9 @@ const toogleRecord = ({ state, api, emit, constants, props }) => ($event) => {
|
|
|
148
148
|
};
|
|
149
149
|
const handleConfirm = ({ state, emit, props, constants, api }) => ($event) => {
|
|
150
150
|
if (props.isHwh5) {
|
|
151
|
-
api.triggerClick($event, constants.HWH5_STATUS.
|
|
151
|
+
api.triggerClick($event, constants.HWH5_STATUS.END, () => {
|
|
152
|
+
emit("update:modelValue", false);
|
|
153
|
+
});
|
|
152
154
|
} else {
|
|
153
155
|
state.isClickConfirm = true;
|
|
154
156
|
emit("update:modelValue", false);
|
|
@@ -195,6 +197,7 @@ const calcVoice = (analyser) => {
|
|
|
195
197
|
if (highValue <= val) {
|
|
196
198
|
return voiceNum = idx + 1 + (val === 0 ? lowValue / 1e3 : highValue / val);
|
|
197
199
|
}
|
|
200
|
+
return false;
|
|
198
201
|
});
|
|
199
202
|
!ismatch && (voiceNum = 6);
|
|
200
203
|
return voiceNum;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
let selectors = [];
|
|
3
|
+
let doms = [];
|
|
4
|
+
let scrolls = [];
|
|
5
|
+
function backup() {
|
|
6
|
+
doms.push(window);
|
|
7
|
+
scrolls.push({ left: window.pageXOffset, top: window.pageYOffset });
|
|
8
|
+
selectors.forEach((selector) => {
|
|
9
|
+
const dom = document.querySelector(`.${selector}`);
|
|
10
|
+
if (dom) {
|
|
11
|
+
doms.push(dom);
|
|
12
|
+
scrolls.push({ left: dom.scrollLeft, top: dom.scrollTop });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function restore() {
|
|
17
|
+
doms.forEach((dom, i) => dom.scrollTo(scrolls[i]));
|
|
18
|
+
doms = [];
|
|
19
|
+
scrolls = [];
|
|
20
|
+
}
|
|
21
|
+
function registerCustomClipboard(Quill, keepClass) {
|
|
22
|
+
const Clipboard = Quill.import("modules/clipboard");
|
|
23
|
+
const Delta = Quill.import("delta");
|
|
24
|
+
if (typeof keepClass === "string") {
|
|
25
|
+
selectors.push(keepClass);
|
|
26
|
+
} else if (Array.isArray(keepClass)) {
|
|
27
|
+
selectors = keepClass.slice(0);
|
|
28
|
+
}
|
|
29
|
+
class CustomClipboard extends Clipboard {
|
|
30
|
+
onPaste(e) {
|
|
31
|
+
backup();
|
|
32
|
+
if (e.defaultPrevented || !this.quill.isEnabled())
|
|
33
|
+
return;
|
|
34
|
+
const range = this.quill.getSelection();
|
|
35
|
+
let delta = new Delta().retain(range.index);
|
|
36
|
+
const scrollTop = this.quill.scrollingContainer.scrollTop;
|
|
37
|
+
this.container.focus();
|
|
38
|
+
this.quill.selection.update(Quill.sources.SILENT);
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
delta = delta.concat(this.convert()).delete(range.length);
|
|
41
|
+
this.quill.updateContents(delta, Quill.sources.USER);
|
|
42
|
+
this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT);
|
|
43
|
+
this.quill.scrollingContainer.scrollTop = scrollTop;
|
|
44
|
+
this.quill.focus();
|
|
45
|
+
restore();
|
|
46
|
+
}, 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Quill.register("modules/clipboard", CustomClipboard, true);
|
|
50
|
+
}
|
|
51
|
+
var clipboard_default = registerCustomClipboard;
|
|
52
|
+
export {
|
|
53
|
+
clipboard_default as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
import { extend } from "../common/object";
|
|
3
|
+
import { xss } from "../common/xss";
|
|
4
|
+
import { getToolbarTips, defaultOptions } from "./options";
|
|
5
|
+
import registerTableModule from "./table-module";
|
|
6
|
+
import registerCustomClipboard from "./clipboard";
|
|
7
|
+
const initContent = ({ state, props, nextTick }) => () => {
|
|
8
|
+
if (state.quill) {
|
|
9
|
+
const flag = state.quill.selection.hasFocus();
|
|
10
|
+
if (state.content && state.content !== state.innerContent) {
|
|
11
|
+
state.innerContent = state.content;
|
|
12
|
+
state.quill.pasteHTML(xss.filterHtml(state.content));
|
|
13
|
+
} else {
|
|
14
|
+
if (!state.content) {
|
|
15
|
+
state.quill.setText("");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
nextTick(() => {
|
|
19
|
+
if (!props.disabled && !props.displayOnly) {
|
|
20
|
+
state.quill.enable(true);
|
|
21
|
+
}
|
|
22
|
+
flag ? state.quill.selection.focus() : state.quill.blur();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const initQuill = ({ api, emit, props, vm, service, state, Quill, ImageDrop, ImageUpload, FileUpload }) => () => {
|
|
27
|
+
state.innerOptions = extend(true, {}, defaultOptions, props.globalOptions, props.options);
|
|
28
|
+
if (document.caretRangeFromPoint) {
|
|
29
|
+
if (props.imageDrop) {
|
|
30
|
+
Quill.register("modules/imageDrop", ImageDrop, true);
|
|
31
|
+
state.innerOptions.modules.imageDrop = props.imageDrop;
|
|
32
|
+
}
|
|
33
|
+
if (props.imageUpload) {
|
|
34
|
+
Quill.register("modules/imageUpload", ImageUpload, true);
|
|
35
|
+
state.innerOptions.modules.imageUpload = props.imageUpload;
|
|
36
|
+
}
|
|
37
|
+
if (props.fileUpload) {
|
|
38
|
+
Quill.register("modules/fileUpload", FileUpload, true);
|
|
39
|
+
state.innerOptions.modules.fileUpload = extend(
|
|
40
|
+
true,
|
|
41
|
+
{},
|
|
42
|
+
{ httpRequest: service && service.network.request },
|
|
43
|
+
props.fileUpload,
|
|
44
|
+
{ url: state.fileUploadUrl }
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
registerTableModule(Quill);
|
|
49
|
+
if (state.innerOptions.modules) {
|
|
50
|
+
state.innerOptions.modules.tableModule = props.tableModule === true;
|
|
51
|
+
}
|
|
52
|
+
registerCustomClipboard(Quill, props.keepClass);
|
|
53
|
+
state.quill = Object.freeze(new Quill(vm.$refs.editor, state.innerOptions));
|
|
54
|
+
state.quill.enable(false);
|
|
55
|
+
state.quill.on("selection-change", api.selectionChange);
|
|
56
|
+
state.quill.on("text-change", api.textChange);
|
|
57
|
+
if (state.content) {
|
|
58
|
+
state.quill.pasteHTML(xss.filterHtml(state.content));
|
|
59
|
+
api.textChange();
|
|
60
|
+
}
|
|
61
|
+
if (!props.disabled && !props.displayOnly) {
|
|
62
|
+
state.quill.enable(true);
|
|
63
|
+
}
|
|
64
|
+
emit("ready", state.quill);
|
|
65
|
+
api.setToolbarTips();
|
|
66
|
+
};
|
|
67
|
+
const setToolbarTips = ({ t, vm }) => () => {
|
|
68
|
+
let tip;
|
|
69
|
+
const item = getToolbarTips(t);
|
|
70
|
+
const length = item.length;
|
|
71
|
+
const richTextEl = vm.$el;
|
|
72
|
+
for (let i = 0; i < length; i++) {
|
|
73
|
+
tip = richTextEl.querySelectorAll(".quill-editor " + item[i].Choice);
|
|
74
|
+
if (tip.length) {
|
|
75
|
+
Array.prototype.slice.call(tip).forEach((ite) => {
|
|
76
|
+
ite.setAttribute("title", item[i].title);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
tip = richTextEl.querySelectorAll(".quill-editor .ql-file");
|
|
81
|
+
if (tip.length) {
|
|
82
|
+
const iconEl = vm.$refs.iconFile.$el;
|
|
83
|
+
Array.prototype.slice.call(tip).forEach((ite) => {
|
|
84
|
+
ite.innerHTML = getOuterHTML(iconEl);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const setPlaceholder = ({ state, props }) => () => {
|
|
89
|
+
if (state.quill) {
|
|
90
|
+
state.quill.root.setAttribute("data-placeholder", props.options.placeholder);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const getFileUploadUrl = ({ service }) => () => {
|
|
94
|
+
return service ? service.common.getFileUploadUrl() : Promise.resolve("");
|
|
95
|
+
};
|
|
96
|
+
const selectionChange = ({ emit, state }) => (range) => {
|
|
97
|
+
if (!range) {
|
|
98
|
+
emit("blur", state.quill);
|
|
99
|
+
} else {
|
|
100
|
+
emit("focus", state.quill);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const handlePaste = ({ state }) => (event) => {
|
|
104
|
+
const rangeLength = state.quill.selection.savedRange.length || 0;
|
|
105
|
+
const newLength = event.clipboardData.getData("text").length || 0;
|
|
106
|
+
const currentLength = state.quill.getText().length || 0;
|
|
107
|
+
const totalLength = currentLength - rangeLength + newLength;
|
|
108
|
+
if (totalLength > state.maxLength) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
state.pasteCanceled = true;
|
|
111
|
+
} else {
|
|
112
|
+
state.pasteCanceled = false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const maxLength = ({ props, constants }) => () => {
|
|
116
|
+
return props.maxLength > 0 ? props.maxLength : constants.MAX_LENGTH;
|
|
117
|
+
};
|
|
118
|
+
const isDisplayOnly = ({ state, props, parent, nextTick }) => () => {
|
|
119
|
+
let displayOnly = props.displayOnly || (parent.auiForm || {}).displayOnly;
|
|
120
|
+
nextTick(() => {
|
|
121
|
+
if (state.quill && !props.disabled) {
|
|
122
|
+
state.quill.root.setAttribute("contenteditable", !displayOnly);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return displayOnly;
|
|
126
|
+
};
|
|
127
|
+
const textChange = ({ emit, vm, state, Modal, t }) => (delta, oldDelta) => {
|
|
128
|
+
const quill = state.quill;
|
|
129
|
+
if (state.pasteCanceled) {
|
|
130
|
+
state.pasteCanceled = false;
|
|
131
|
+
quill.setContents(oldDelta);
|
|
132
|
+
Modal.message({ message: `${t("ui.richText.maxLength")}${state.maxLength}`, status: "warning" });
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const text = quill.getText();
|
|
136
|
+
const currentLength = text.length;
|
|
137
|
+
const maxLength2 = state.maxLength;
|
|
138
|
+
if (currentLength > maxLength2) {
|
|
139
|
+
quill.setContents(oldDelta);
|
|
140
|
+
Modal.message({ message: `${t("ui.richText.maxLength")}${state.maxLength}`, status: "warning" });
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
let html = xss.filterHtml(vm.$refs.editor.children[0].innerHTML);
|
|
144
|
+
if (html === "<p><br></p>")
|
|
145
|
+
html = "";
|
|
146
|
+
state.innerContent = html;
|
|
147
|
+
emit("update:modelValue", html);
|
|
148
|
+
emit("change", { html, text, quill });
|
|
149
|
+
};
|
|
150
|
+
const getOuterHTML = (el) => {
|
|
151
|
+
if (!el.outerHTML) {
|
|
152
|
+
const container = document.createElement("div");
|
|
153
|
+
container.appendChild(el);
|
|
154
|
+
return xss.filterHtml(container.innerHTML);
|
|
155
|
+
} else {
|
|
156
|
+
return xss.filterHtml(el.outerHTML);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const mounted = ({ api, props, state, i18n, watch }) => () => {
|
|
160
|
+
if (props.fileUpload && !props.fileUpload.url) {
|
|
161
|
+
api.getFileUploadUrl().then((url) => {
|
|
162
|
+
url = xss.filterUrl(url);
|
|
163
|
+
state.fileUploadUrl = url;
|
|
164
|
+
api.initQuill();
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
api.initQuill();
|
|
168
|
+
}
|
|
169
|
+
if (i18n) {
|
|
170
|
+
watch(() => i18n.locale, api.setToolbarTips);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const beforeUnmount = ({ api, state }) => () => {
|
|
174
|
+
state.quill.off("selection-change", api.selectionChange);
|
|
175
|
+
state.quill.off("text-change", api.textChange);
|
|
176
|
+
state.quill = null;
|
|
177
|
+
delete state.quill;
|
|
178
|
+
};
|
|
179
|
+
export {
|
|
180
|
+
beforeUnmount,
|
|
181
|
+
getFileUploadUrl,
|
|
182
|
+
handlePaste,
|
|
183
|
+
initContent,
|
|
184
|
+
initQuill,
|
|
185
|
+
isDisplayOnly,
|
|
186
|
+
maxLength,
|
|
187
|
+
mounted,
|
|
188
|
+
selectionChange,
|
|
189
|
+
setPlaceholder,
|
|
190
|
+
setToolbarTips,
|
|
191
|
+
textChange
|
|
192
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "../../chunk-G2ADBYYC.js";
|
|
2
|
+
import { xss } from "../../common/xss";
|
|
3
|
+
const Upload = function(quill, options) {
|
|
4
|
+
this.quill = quill;
|
|
5
|
+
this.options = options || {};
|
|
6
|
+
this.quill.getModule("toolbar").addHandler("file", this.selectLocalFile.bind(this));
|
|
7
|
+
};
|
|
8
|
+
const FormDataRequest = function({ file, url, method, name, headers, callbackOK, callbackKO }) {
|
|
9
|
+
const fd = new FormData();
|
|
10
|
+
url = xss.filterUrl(url);
|
|
11
|
+
fd.append(name, file, file.name);
|
|
12
|
+
this.options.csrf && fd.append(this.options.csrf.token, this.options.csrf.hash);
|
|
13
|
+
if (this.options.httpRequest) {
|
|
14
|
+
const option = {
|
|
15
|
+
url,
|
|
16
|
+
headers,
|
|
17
|
+
method,
|
|
18
|
+
data: fd,
|
|
19
|
+
onSuccess: function(res) {
|
|
20
|
+
callbackOK(res && res.data, this.insert.bind(this));
|
|
21
|
+
}.bind(this),
|
|
22
|
+
onError(error) {
|
|
23
|
+
callbackKO(error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const req = this.options.httpRequest(option);
|
|
27
|
+
if (req && req.then) {
|
|
28
|
+
req.then(option.onSuccess, option.onError);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
const xmlRequest = new XMLHttpRequest();
|
|
32
|
+
xmlRequest.withCredentials = this.options.withCredentials !== false;
|
|
33
|
+
xmlRequest.open(method, url, true);
|
|
34
|
+
for (let index in headers) {
|
|
35
|
+
xmlRequest.setRequestHeader(index, headers[index]);
|
|
36
|
+
}
|
|
37
|
+
xmlRequest.onload = function() {
|
|
38
|
+
if (xmlRequest.status === 200 || xmlRequest.status === 201) {
|
|
39
|
+
callbackOK(JSON.parse(xmlRequest.responseText), this.insert.bind(this));
|
|
40
|
+
} else {
|
|
41
|
+
callbackKO({
|
|
42
|
+
code: xmlRequest.status,
|
|
43
|
+
type: xmlRequest.statusText,
|
|
44
|
+
body: xmlRequest.responseText
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}.bind(this);
|
|
48
|
+
xmlRequest.send(fd);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const defaultUploader = function(file) {
|
|
52
|
+
const url = this.options.url;
|
|
53
|
+
const method = this.options.method || "POST";
|
|
54
|
+
const name = this.options.name || "file";
|
|
55
|
+
const headers = this.options.headers || {};
|
|
56
|
+
const callbackOK = this.options.success || this.uploadCallbackOK.bind(this);
|
|
57
|
+
const callbackKO = this.options.fail || this.uploadCallbackKO.bind(this);
|
|
58
|
+
if (url) {
|
|
59
|
+
FormDataRequest.call(this, { file, url, method, name, headers, callbackOK, callbackKO });
|
|
60
|
+
} else {
|
|
61
|
+
const reader = new FileReader();
|
|
62
|
+
reader.onload = function(event) {
|
|
63
|
+
callbackOK(event.target.result, this.insert.bind(this));
|
|
64
|
+
}.bind(this);
|
|
65
|
+
reader.readAsDataURL(file);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
Upload.prototype.selectLocalFile = function() {
|
|
69
|
+
const input = document.createElement("input");
|
|
70
|
+
input.setAttribute("type", "file");
|
|
71
|
+
input.click();
|
|
72
|
+
input.onchange = function() {
|
|
73
|
+
const file = input.files[0];
|
|
74
|
+
const checkBeforeSend = this.options.checkBeforeSend || this.checkBeforeSend.bind(this);
|
|
75
|
+
checkBeforeSend(file, this.sendToServer.bind(this));
|
|
76
|
+
}.bind(this);
|
|
77
|
+
};
|
|
78
|
+
Upload.prototype.checkBeforeSend = function(file, next) {
|
|
79
|
+
next(file);
|
|
80
|
+
};
|
|
81
|
+
Upload.prototype.sendToServer = function(file) {
|
|
82
|
+
if (this.options.customUploader) {
|
|
83
|
+
this.options.customUploader(
|
|
84
|
+
file,
|
|
85
|
+
function(file2) {
|
|
86
|
+
this.insert(file2);
|
|
87
|
+
}.bind(this)
|
|
88
|
+
);
|
|
89
|
+
} else {
|
|
90
|
+
defaultUploader.call(this, file);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
Upload.prototype.insert = function(file) {
|
|
94
|
+
const index = (this.quill.getSelection() || {}).index || this.quill.getLength();
|
|
95
|
+
this.quill.insertText(index, file.name, "link", file.url);
|
|
96
|
+
this.quill.setSelection(index + file.name.length);
|
|
97
|
+
};
|
|
98
|
+
Upload.prototype.uploadCallbackOK = function(response, next) {
|
|
99
|
+
next(response);
|
|
100
|
+
};
|
|
101
|
+
Upload.prototype.uploadCallbackKO = function(error) {
|
|
102
|
+
throw new Error(error);
|
|
103
|
+
};
|
|
104
|
+
var file_upload_default = Upload;
|
|
105
|
+
export {
|
|
106
|
+
file_upload_default as default
|
|
107
|
+
};
|