@opentiny/vue-renderless 3.1.0-alpha.0 → 3.4.7

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 (177) hide show
  1. package/action-menu/index.js +10 -0
  2. package/action-menu/vue.js +26 -0
  3. package/amount/index.js +334 -0
  4. package/amount/vue.js +206 -0
  5. package/area/index.js +162 -0
  6. package/area/vue.js +68 -0
  7. package/autonavi-map/index.js +28 -0
  8. package/avatar/index.js +5 -1
  9. package/avatar/vue.js +2 -1
  10. package/baidu-map/index.js +28 -0
  11. package/breadcrumb/index.js +9 -0
  12. package/breadcrumb/vue.js +25 -3
  13. package/breadcrumb-item/index.js +26 -0
  14. package/breadcrumb-item/vue.js +20 -11
  15. package/bulletin-board/index.js +4 -1
  16. package/button-group/vue.js +1 -1
  17. package/calendar/index.js +14 -14
  18. package/card-template/index.js +1 -1
  19. package/cascader/index.js +21 -7
  20. package/cascader/vue.js +1 -2
  21. package/cascader-node/index.js +3 -1
  22. package/cascader-panel/index.js +12 -4
  23. package/cascader-panel/vue.js +1 -2
  24. package/chart-bar/index.js +533 -0
  25. package/chart-boxplot/index.js +270 -0
  26. package/chart-candle/index.js +428 -0
  27. package/chart-core/deps/constants.js +65 -0
  28. package/chart-core/deps/numerify.js +286 -0
  29. package/chart-core/deps/utils.js +205 -0
  30. package/chart-core/index.js +541 -0
  31. package/chart-core/modules/animation.js +10 -0
  32. package/chart-core/modules/extend.js +36 -0
  33. package/chart-core/modules/mark.js +7 -0
  34. package/chart-core/vue.js +128 -0
  35. package/chart-funnel/index.js +155 -0
  36. package/chart-gauge/index.js +153 -0
  37. package/chart-graph/index.js +38 -0
  38. package/chart-heatmap/index.js +407 -0
  39. package/chart-line/index.js +358 -0
  40. package/chart-liquidfill/index.js +119 -0
  41. package/chart-map/index.js +261 -0
  42. package/chart-pie/index.js +327 -0
  43. package/chart-radar/index.js +181 -0
  44. package/chart-sankey/index.js +166 -0
  45. package/chart-scatter/index.js +360 -0
  46. package/chart-sunburst/index.js +36 -0
  47. package/chart-tree/index.js +107 -0
  48. package/chart-waterfall/index.js +231 -0
  49. package/chart-wordcloud/index.js +109 -0
  50. package/checkbox/index.js +4 -4
  51. package/checkbox-button/index.js +3 -1
  52. package/common/bigInt.js +5 -2
  53. package/common/date.js +17 -17
  54. package/common/deps/date-util.js +15 -5
  55. package/common/deps/date.js +6 -6
  56. package/common/deps/dom.js +18 -6
  57. package/common/deps/eSpaceCtrl.js +286 -0
  58. package/common/deps/fullscreen/apis.js +22 -22
  59. package/common/deps/memorize.js +3 -3
  60. package/common/deps/modal-queue.js +2 -0
  61. package/common/deps/popper.js +12 -10
  62. package/common/deps/popup-manager.js +16 -5
  63. package/common/deps/resize-event.js +6 -2
  64. package/common/deps/scrollbar-width.js +6 -2
  65. package/common/deps/tree-model/node.js +30 -10
  66. package/common/deps/tree-model/tree-store.js +33 -21
  67. package/common/deps/tree-model/util.js +6 -2
  68. package/common/deps/upload-ajax.js +7 -1
  69. package/common/deps/vue-popper.js +2 -2
  70. package/common/string.js +1 -1
  71. package/company/index.js +56 -0
  72. package/company/vue.js +35 -0
  73. package/country/index.js +54 -0
  74. package/country/vue.js +35 -0
  75. package/credit-card-form/index.js +1 -0
  76. package/currency/index.js +78 -0
  77. package/currency/vue.js +39 -0
  78. package/date-panel/index.js +16 -6
  79. package/date-picker/index.js +9 -5
  80. package/date-range/index.js +28 -9
  81. package/date-table/index.js +3 -1
  82. package/dept/index.js +318 -0
  83. package/dept/vue.js +163 -0
  84. package/detail-page/index.js +4 -1
  85. package/dialog-box/index.js +14 -4
  86. package/dialog-box/vue.js +7 -3
  87. package/drop-roles/index.js +73 -0
  88. package/drop-roles/vue.js +38 -0
  89. package/dropdown/index.js +5 -4
  90. package/dropdown/vue.js +5 -3
  91. package/dropdown-item/index.js +15 -0
  92. package/dropdown-item/vue.js +27 -13
  93. package/espace/index.js +129 -0
  94. package/espace/vue.js +52 -0
  95. package/file-upload/index.js +336 -291
  96. package/form/index.js +3 -1
  97. package/form/vue.js +15 -0
  98. package/form-item/index.js +15 -5
  99. package/fullscreen/index.js +4 -4
  100. package/fullscreen/vue.js +3 -3
  101. package/grid/core/interceptor.js +4 -7
  102. package/grid/plugins/export.js +2 -2
  103. package/grid/plugins/exportExcel.js +28 -10
  104. package/grid/static/array/findTree.js +1 -1
  105. package/grid/static/base/helperCreateGetObjects.js +1 -1
  106. package/grid/static/base/helperEqualCompare.js +2 -2
  107. package/grid/static/base/helperGetHGSKeys.js +1 -1
  108. package/grid/static/base/uniqueId.js +1 -1
  109. package/grid/static/object/assign.js +3 -3
  110. package/grid/static/string/toString.js +3 -3
  111. package/hrapprover/index.js +118 -0
  112. package/hrapprover/vue.js +102 -0
  113. package/locales/index.js +116 -0
  114. package/locales/vue.js +46 -0
  115. package/logon-user/index.js +23 -0
  116. package/logon-user/vue.js +22 -0
  117. package/logout/index.js +118 -0
  118. package/logout/vue.js +22 -0
  119. package/milestone/index.js +2 -1
  120. package/mini-picker/index.js +1 -1
  121. package/mini-picker/vue.js +1 -1
  122. package/modal/index.js +4 -2
  123. package/month-table/index.js +2 -2
  124. package/nav-menu/index.js +2 -2
  125. package/numeric/index.js +4 -2
  126. package/package.json +33 -136
  127. package/pager-item/vue.js +6 -2
  128. package/picker/index.js +43 -17
  129. package/picker/timezone.js +2 -2
  130. package/picker-column/index.js +7 -3
  131. package/pop-upload/index.js +5 -3
  132. package/popeditor/index.js +15 -7
  133. package/popover/index.js +87 -54
  134. package/popover/vue.js +13 -9
  135. package/rate/index.js +2 -2
  136. package/rich-text/clipboard.js +77 -0
  137. package/rich-text/index.js +176 -0
  138. package/rich-text/module/file-upload.js +118 -0
  139. package/rich-text/module/image-drop.js +54 -0
  140. package/rich-text/module/image-upload.js +84 -0
  141. package/rich-text/options.js +187 -0
  142. package/rich-text/table-module.js +557 -0
  143. package/rich-text/vue.js +149 -0
  144. package/roles/index.js +87 -0
  145. package/roles/vue.js +39 -0
  146. package/search/index.js +32 -27
  147. package/search/vue.js +7 -2
  148. package/select/index.js +328 -304
  149. package/select/vue.js +19 -9
  150. package/select-dropdown/index.js +1 -1
  151. package/slider/index.js +9 -11
  152. package/slider/vue.js +3 -3
  153. package/split/vue.js +1 -1
  154. package/tab-nav/index.js +0 -6
  155. package/tab-nav/vue.js +0 -14
  156. package/table/index.js +1 -1
  157. package/text-popup/index.js +6 -4
  158. package/time/index.js +3 -1
  159. package/time-range/index.js +6 -2
  160. package/time-spinner/index.js +15 -5
  161. package/toggle-menu/index.js +11 -0
  162. package/toggle-menu/vue.js +2 -1
  163. package/tooltip/index.js +46 -35
  164. package/tooltip/vue.js +5 -1
  165. package/tree/index.js +57 -21
  166. package/tree-menu/index.js +3 -1
  167. package/tree-node/index.js +7 -3
  168. package/upload/index.js +14 -5
  169. package/user/index.js +634 -0
  170. package/user/vue.js +113 -0
  171. package/user-account/index.js +23 -0
  172. package/user-account/vue.js +25 -0
  173. package/user-contact/index.js +1 -4
  174. package/user-head/index.js +9 -11
  175. package/user-head/vue.js +2 -6
  176. package/user-link/index.js +43 -0
  177. package/user-link/vue.js +60 -0
@@ -0,0 +1,176 @@
1
+ import { extend } from '@opentiny/vue-renderless/common/object';
2
+ import { xss } from '@opentiny/vue-renderless/common';
3
+ import { getToolbarTips, defaultOptions } from './options';
4
+ import registerTableModule from './table-module';
5
+ import registerCustomClipboard from './clipboard';
6
+ export var initContent = function initContent(_ref) {
7
+ var state = _ref.state;
8
+ return function () {
9
+ if (state.quill) {
10
+ if (state.content && state.content !== state.innerContent) {
11
+ state.innerContent = state.content;
12
+ state.quill.pasteHTML(state.content);
13
+ } else if (!state.content) {
14
+ state.quill.setText('');
15
+ }
16
+ }
17
+ };
18
+ };
19
+ var getOuterHTML = function getOuterHTML(el) {
20
+ if (!el.outerHTML) {
21
+ var container = document.createElement('div');
22
+ container.appendChild(el);
23
+ return container.innerHTML;
24
+ } else {
25
+ return el.outerHTML;
26
+ }
27
+ };
28
+ export var initQuill = function initQuill(_ref2) {
29
+ var api = _ref2.api,
30
+ emit = _ref2.emit,
31
+ props = _ref2.props,
32
+ refs = _ref2.refs,
33
+ service = _ref2.service,
34
+ state = _ref2.state,
35
+ Quill = _ref2.Quill,
36
+ ImageDrop = _ref2.ImageDrop,
37
+ ImageUpload = _ref2.ImageUpload,
38
+ FileUpload = _ref2.FileUpload;
39
+ return function () {
40
+ state.innerOptions = extend(true, {}, defaultOptions, props.globalOptions, props.options);
41
+ if (document.caretRangeFromPoint) {
42
+ if (props.imageDrop) {
43
+ Quill.register('modules/imageDrop', ImageDrop, true);
44
+ state.innerOptions.modules.imageDrop = props.imageDrop;
45
+ }
46
+ if (props.imageUpload) {
47
+ Quill.register('modules/imageUpload', ImageUpload, true);
48
+ state.innerOptions.modules.imageUpload = props.imageUpload;
49
+ }
50
+ if (props.fileUpload) {
51
+ Quill.register('modules/fileUpload', FileUpload, true);
52
+ state.innerOptions.modules.fileUpload = extend(true, {}, {
53
+ httpRequest: service && service.network.request
54
+ }, props.fileUpload, {
55
+ url: state.fileUploadUrl
56
+ });
57
+ }
58
+ }
59
+ registerTableModule(Quill);
60
+ if (state.innerOptions.modules) {
61
+ state.innerOptions.modules.tableModule = props.tableModule === true;
62
+ }
63
+ registerCustomClipboard(Quill, props.keepClass);
64
+ state.quill = Object.freeze(new Quill(refs.editor, state.innerOptions));
65
+ state.quill.enable(false);
66
+ state.quill.on('selection-change', api.selectionChange);
67
+ state.quill.on('text-change', api.textChange);
68
+ if (state.content) {
69
+ state.quill.pasteHTML(state.content);
70
+ }
71
+ if (!props.disabled) {
72
+ state.quill.enable(true);
73
+ }
74
+ emit('ready', state.quill);
75
+ api.setToolbarTips();
76
+ };
77
+ };
78
+ export var setToolbarTips = function setToolbarTips(_ref3) {
79
+ var refs = _ref3.refs,
80
+ t = _ref3.t,
81
+ vm = _ref3.vm;
82
+ return function () {
83
+ var tip;
84
+ var item = getToolbarTips(t);
85
+ var length = item.length;
86
+ var richTextEl = vm.$el;
87
+ var _loop = function _loop(i) {
88
+ tip = richTextEl.querySelectorAll('.quill-editor ' + item[i].Choice);
89
+ if (tip.length) {
90
+ Array.prototype.slice.call(tip).forEach(function (ite) {
91
+ ite.setAttribute('title', item[i].title);
92
+ });
93
+ }
94
+ };
95
+ for (var i = 0; i < length; i++) {
96
+ _loop(i);
97
+ }
98
+ tip = richTextEl.querySelectorAll('.quill-editor .ql-file');
99
+ if (tip.length) {
100
+ var iconEl = refs.iconFile.$el;
101
+ Array.prototype.slice.call(tip).forEach(function (ite) {
102
+ ite.innerHTML = getOuterHTML(iconEl);
103
+ });
104
+ }
105
+ };
106
+ };
107
+ export var getFileUploadUrl = function getFileUploadUrl(_ref4) {
108
+ var service = _ref4.service;
109
+ return function () {
110
+ return service ? service.common.getFileUploadUrl() : Promise.resolve('');
111
+ };
112
+ };
113
+ export var selectionChange = function selectionChange(_ref5) {
114
+ var emit = _ref5.emit,
115
+ state = _ref5.state;
116
+ return function (range) {
117
+ if (!range) {
118
+ emit('blur', state.quill);
119
+ } else {
120
+ emit('focus', state.quill);
121
+ }
122
+ };
123
+ };
124
+ export var textChange = function textChange(_ref6) {
125
+ var emit = _ref6.emit,
126
+ refs = _ref6.refs,
127
+ state = _ref6.state;
128
+ return function () {
129
+ var html = refs.editor.children[0].innerHTML;
130
+ var quill = state.quill;
131
+ var text = state.quill.getText();
132
+ if (html === '<p><br></p>') {
133
+ html = '';
134
+ }
135
+ state.innerContent = html;
136
+ emit('update:modelValue', html);
137
+ emit('change', {
138
+ html: html,
139
+ text: text,
140
+ quill: quill
141
+ });
142
+ };
143
+ };
144
+ export var mounted = function mounted(_ref7) {
145
+ var api = _ref7.api,
146
+ props = _ref7.props,
147
+ state = _ref7.state,
148
+ i18n = _ref7.i18n,
149
+ watch = _ref7.watch;
150
+ return function () {
151
+ if (props.fileUpload && !props.fileUpload.url) {
152
+ api.getFileUploadUrl().then(function (url) {
153
+ url = xss.filterUrl(url);
154
+ state.fileUploadUrl = url;
155
+ api.initQuill();
156
+ });
157
+ } else {
158
+ api.initQuill();
159
+ }
160
+ if (i18n) {
161
+ watch(function () {
162
+ return i18n.locale;
163
+ }, api.setToolbarTips);
164
+ }
165
+ };
166
+ };
167
+ export var beforeUnmount = function beforeUnmount(_ref8) {
168
+ var api = _ref8.api,
169
+ state = _ref8.state;
170
+ return function () {
171
+ state.quill.off('selection-change', api.selectionChange);
172
+ state.quill.off('text-change', api.textChange);
173
+ state.quill = null;
174
+ delete state.quill;
175
+ };
176
+ };
@@ -0,0 +1,118 @@
1
+ import { xss } from '@opentiny/vue-renderless/common';
2
+ var Upload = function Upload(quill, options) {
3
+ this.quill = quill;
4
+ this.options = options || {};
5
+ this.quill.getModule('toolbar').addHandler('file', this.selectLocalFile.bind(this));
6
+ };
7
+ var FormDataRequest = function FormDataRequest(_ref) {
8
+ var file = _ref.file,
9
+ url = _ref.url,
10
+ method = _ref.method,
11
+ name = _ref.name,
12
+ headers = _ref.headers,
13
+ callbackOK = _ref.callbackOK,
14
+ callbackKO = _ref.callbackKO;
15
+ var fd = new FormData();
16
+ url = xss.filterUrl(url);
17
+ fd.append(name, file, file.name);
18
+ this.options.csrf && fd.append(this.options.csrf.token, this.options.csrf.hash);
19
+ if (this.options.httpRequest) {
20
+ var option = {
21
+ url: url,
22
+ headers: headers,
23
+ method: method,
24
+ data: fd,
25
+ onSuccess: function (res) {
26
+ callbackOK(res && res.data, this.insert.bind(this));
27
+ }.bind(this),
28
+ onError: function onError(error) {
29
+ callbackKO(error);
30
+ }
31
+ };
32
+ var req = this.options.httpRequest(option);
33
+ if (req && req.then) {
34
+ req.then(option.onSuccess, option.onError);
35
+ }
36
+ } else {
37
+ var xmlRequest = new XMLHttpRequest();
38
+ xmlRequest.withCredentials = this.options.withCredentials !== false;
39
+ xmlRequest.open(method, url, true);
40
+ for (var index in headers) {
41
+ if (Object.prototype.hasOwnProperty.call(headers, index)) {
42
+ xmlRequest.setRequestHeader(index, headers[index]);
43
+ }
44
+ }
45
+ xmlRequest.onload = function () {
46
+ if (xmlRequest.status === 200) {
47
+ callbackOK(JSON.parse(xmlRequest.responseText), this.insert.bind(this));
48
+ } else {
49
+ callbackKO({
50
+ code: xmlRequest.status,
51
+ type: xmlRequest.statusText,
52
+ body: xmlRequest.responseText
53
+ });
54
+ }
55
+ }.bind(this);
56
+ xmlRequest.send(fd);
57
+ }
58
+ };
59
+ var defaultUploader = function defaultUploader(file) {
60
+ var url = this.options.url,
61
+ method = this.options.method || 'POST',
62
+ name = this.options.name || 'file',
63
+ headers = this.options.headers || {},
64
+ callbackOK = this.options.success || this.uploadCallbackOK.bind(this),
65
+ callbackKO = this.options.fail || this.uploadCallbackKO.bind(this);
66
+ if (url) {
67
+ FormDataRequest.call(this, {
68
+ file: file,
69
+ url: url,
70
+ method: method,
71
+ name: name,
72
+ headers: headers,
73
+ callbackOK: callbackOK,
74
+ callbackKO: callbackKO
75
+ });
76
+ } else {
77
+ var reader = new FileReader();
78
+ reader.onload = function (event) {
79
+ callbackOK(event.target.result, this.insert.bind(this));
80
+ }.bind(this);
81
+ reader.readAsDataURL(file);
82
+ }
83
+ };
84
+ Upload.prototype.selectLocalFile = function () {
85
+ var input = document.createElement('input');
86
+ input.setAttribute('type', 'file');
87
+ input.click();
88
+ input.onchange = function () {
89
+ var file = input.files[0];
90
+ var checkBeforeSend = this.options.checkBeforeSend || this.checkBeforeSend.bind(this);
91
+ checkBeforeSend(file, this.sendToServer.bind(this));
92
+ }.bind(this);
93
+ };
94
+ Upload.prototype.checkBeforeSend = function (file, next) {
95
+ next(file);
96
+ };
97
+ Upload.prototype.sendToServer = function (file) {
98
+ var _this = this;
99
+ if (this.options.customUploader) {
100
+ this.options.customUploader(file, function (file) {
101
+ _this.insert(file).bind(_this);
102
+ });
103
+ } else {
104
+ defaultUploader.call(this, file);
105
+ }
106
+ };
107
+ Upload.prototype.insert = function (file) {
108
+ var index = (this.quill.getSelection() || {}).index || this.quill.getLength();
109
+ this.quill.insertText(index, file.name, 'link', file.url);
110
+ this.quill.setSelection(index + file.name.length);
111
+ };
112
+ Upload.prototype.uploadCallbackOK = function (response, next) {
113
+ next(response);
114
+ };
115
+ Upload.prototype.uploadCallbackKO = function (error) {
116
+ throw new Error(error);
117
+ };
118
+ export default Upload;
@@ -0,0 +1,54 @@
1
+ var ImageDrop = function ImageDrop(quill) {
2
+ this.quill = quill;
3
+ this.handleDrop = this.handleDrop.bind(this);
4
+ this.handlePaste = this.handlePaste.bind(this);
5
+ this.quill.root.addEventListener('drop', this.handleDrop, false);
6
+ this.quill.root.addEventListener('paste', this.handlePaste, false);
7
+ };
8
+ ImageDrop.prototype.handleDrop = function (e) {
9
+ e.preventDefault();
10
+ if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length) {
11
+ if (document.caretRangeFromPoint) {
12
+ var selection = document.getSelection();
13
+ var range = document.caretRangeFromPoint(e.clientX, e.clientY);
14
+ if (selection && range) {
15
+ selection.setBaseAndExtent(range.startContainer, range.startOffset, range.startContainer, range.startOffset);
16
+ }
17
+ }
18
+ this.readFiles(e.dataTransfer.files, this.insert.bind(this));
19
+ }
20
+ };
21
+ ImageDrop.prototype.handlePaste = function (e) {
22
+ var _this = this;
23
+ if (!e.clipboardData || !e.clipboardData.items || !e.clipboardData.items.length) {
24
+ return;
25
+ }
26
+ this.readFiles(e.clipboardData.items, function (dataUrl) {
27
+ var selection = _this.quill.getSelection();
28
+ if (!selection) {
29
+ setTimeout(function () {
30
+ _this.insert(dataUrl);
31
+ }, 0);
32
+ }
33
+ });
34
+ };
35
+ ImageDrop.prototype.insert = function (dataUrl) {
36
+ var index = (this.quill.getSelection() || {}).index || this.quill.getLength();
37
+ this.quill.insertEmbed(index, 'image', dataUrl, 'user');
38
+ };
39
+ ImageDrop.prototype.readFiles = function (files, callback) {
40
+ [].forEach.call(files, function (file) {
41
+ if (!file.type.match(/^image\/(gif|jpe?g|a?png|svg|webp|bmp|vnd\.microsoft\.icon)/i)) {
42
+ return;
43
+ }
44
+ var reader = new FileReader();
45
+ reader.onload = function (e) {
46
+ callback(e.target.result);
47
+ };
48
+ var blob = file.getAsFile ? file.getAsFile() : file;
49
+ if (blob instanceof Blob) {
50
+ reader.readAsDataURL(blob);
51
+ }
52
+ });
53
+ };
54
+ export default ImageDrop;
@@ -0,0 +1,84 @@
1
+ import { xss } from '@opentiny/vue-renderless/common';
2
+ var ImageUpload = function ImageUpload(quill, options) {
3
+ this.quill = quill;
4
+ this.options = options || {};
5
+ this.quill.getModule('toolbar').addHandler('image', this.selectLocalImage.bind(this));
6
+ };
7
+ ImageUpload.prototype.selectLocalImage = function () {
8
+ var input = document.createElement('input');
9
+ input.setAttribute('type', 'file');
10
+ input.click();
11
+ input.onchange = function () {
12
+ var file = input.files[0];
13
+ if (/^image\//.test(file.type)) {
14
+ var checkBeforeSend = this.options.checkBeforeSend || this.checkBeforeSend.bind(this);
15
+ checkBeforeSend(file, this.sendToServer.bind(this));
16
+ } else {
17
+ throw new Error('You could only upload images.');
18
+ }
19
+ }.bind(this);
20
+ };
21
+ ImageUpload.prototype.checkBeforeSend = function (file, next) {
22
+ next(file);
23
+ };
24
+ ImageUpload.prototype.sendToServer = function (file) {
25
+ var _this = this;
26
+ if (this.options.customUploader) {
27
+ this.options.customUploader(file, function (dataUrl) {
28
+ _this.insert(dataUrl);
29
+ });
30
+ } else {
31
+ var url = xss.filterUrl(this.options.url),
32
+ method = this.options.method || 'POST',
33
+ name = this.options.name || 'image',
34
+ headers = this.options.headers || {},
35
+ callbackOK = this.options.success || this.uploadImageCallbackOK.bind(this),
36
+ callbackKO = this.options.fail || this.uploadImageCallbackKO.bind(this);
37
+ if (url) {
38
+ var fd = new FormData();
39
+ fd.append(name, file);
40
+ if (this.options.csrf) {
41
+ fd.append(this.options.csrf.token, this.options.csrf.hash);
42
+ }
43
+ var xmlHttpRequest = new XMLHttpRequest();
44
+ xmlHttpRequest.open(method, url, true);
45
+ for (var index in headers) {
46
+ if (Object.prototype.hasOwnProperty.call(headers, index)) {
47
+ xmlHttpRequest.setRequestHeader(index, headers[index]);
48
+ }
49
+ }
50
+ xmlHttpRequest.onload = function () {
51
+ if (xmlHttpRequest.status === 200) {
52
+ callbackOK(JSON.parse(xmlHttpRequest.responseText), this.insert.bind(this));
53
+ } else {
54
+ callbackKO({
55
+ code: xmlHttpRequest.status,
56
+ type: xmlHttpRequest.statusText,
57
+ body: xmlHttpRequest.responseText
58
+ });
59
+ }
60
+ }.bind(this);
61
+ if (this.options.withCredentials) {
62
+ xmlHttpRequest.withCredentials = true;
63
+ }
64
+ xmlHttpRequest.send(fd);
65
+ } else {
66
+ var reader = new FileReader();
67
+ reader.onload = function (event) {
68
+ callbackOK(event.target.result, this.insert.bind(this));
69
+ }.bind(this);
70
+ reader.readAsDataURL(file);
71
+ }
72
+ }
73
+ };
74
+ ImageUpload.prototype.insert = function (dataUrl) {
75
+ var index = (this.quill.getSelection() || {}).index || this.quill.getLength();
76
+ this.quill.insertEmbed(index, 'image', dataUrl, 'user');
77
+ };
78
+ ImageUpload.prototype.uploadImageCallbackOK = function (response, next) {
79
+ next(response);
80
+ };
81
+ ImageUpload.prototype.uploadImageCallbackKO = function (error) {
82
+ throw new Error(error);
83
+ };
84
+ export default ImageUpload;
@@ -0,0 +1,187 @@
1
+ var size = ['small', false, 'large', 'huge'];
2
+ var underline = ['bold', 'italic', 'underline', 'strike'];
3
+ var media = ['link', 'image', 'video', 'file'];
4
+ var header = [{
5
+ header: [1, 2, 3, 4, 5, 6, false]
6
+ }];
7
+ var script = [{
8
+ script: 'sub'
9
+ }, {
10
+ script: 'super'
11
+ }];
12
+ var defaultOptions = {
13
+ theme: 'snow',
14
+ boundary: document.body,
15
+ modules: {
16
+ tableModule: true,
17
+ toolbar: {
18
+ container: [underline, ['blockquote', 'code-block'], [{
19
+ header: 1
20
+ }, {
21
+ header: 2
22
+ }], [{
23
+ list: 'ordered'
24
+ }, {
25
+ list: 'bullet'
26
+ }], script, [{
27
+ indent: '-1'
28
+ }, {
29
+ indent: '+1'
30
+ }], [{
31
+ direction: 'rtl'
32
+ }], [{
33
+ size: size
34
+ }], header, [{
35
+ color: []
36
+ }, {
37
+ background: []
38
+ }], [{
39
+ font: []
40
+ }], [{
41
+ align: []
42
+ }], ['clean'], media],
43
+ handlers: {
44
+ file: function file(value) {
45
+ if (!value) {
46
+ this.quill.format('file', false);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ },
52
+ placeholder: 'Insert text here ...',
53
+ readOnly: false
54
+ };
55
+ var getToolbarTips = function getToolbarTips(t) {
56
+ return [{
57
+ Choice: '.ql-bold',
58
+ title: t('ui.richText.bold')
59
+ }, {
60
+ Choice: '.ql-italic',
61
+ title: t('ui.richText.italic')
62
+ }, {
63
+ Choice: '.ql-underline',
64
+ title: t('ui.richText.underline')
65
+ }, {
66
+ Choice: '.ql-header',
67
+ title: t('ui.richText.header')
68
+ }, {
69
+ Choice: '.ql-strike',
70
+ title: t('ui.richText.strike')
71
+ }, {
72
+ Choice: '.ql-blockquote',
73
+ title: t('ui.richText.blockquote')
74
+ }, {
75
+ Choice: '.ql-code-block',
76
+ title: t('ui.richText.codeBlock')
77
+ }, {
78
+ Choice: '.ql-size',
79
+ title: t('ui.richText.size')
80
+ }, {
81
+ Choice: '.ql-list[value="ordered"]',
82
+ title: t('ui.richText.listOrdered')
83
+ }, {
84
+ Choice: '.ql-list[value="bullet"]',
85
+ title: t('ui.richText.listBullet')
86
+ }, {
87
+ Choice: '.ql-header[value="1"]',
88
+ title: t('ui.richText.header1')
89
+ }, {
90
+ Choice: '.ql-header[value="2"]',
91
+ title: t('ui.richText.header2')
92
+ }, {
93
+ Choice: '.ql-align',
94
+ title: t('ui.richText.align')
95
+ }, {
96
+ Choice: '.ql-color',
97
+ title: t('ui.richText.color')
98
+ }, {
99
+ Choice: '.ql-background',
100
+ title: t('ui.richText.background')
101
+ }, {
102
+ Choice: '.ql-image',
103
+ title: t('ui.richText.image')
104
+ }, {
105
+ Choice: '.ql-video',
106
+ title: t('ui.richText.video')
107
+ }, {
108
+ Choice: '.ql-link',
109
+ title: t('ui.richText.link')
110
+ }, {
111
+ Choice: '.ql-formula',
112
+ title: t('ui.richText.formula')
113
+ }, {
114
+ Choice: '.ql-clean',
115
+ title: t('ui.richText.clean')
116
+ }, {
117
+ Choice: '.ql-indent[value="-1"]',
118
+ title: t('ui.richText.indent1')
119
+ }, {
120
+ Choice: '.ql-indent[value="+1"]',
121
+ title: t('ui.richText.indent2')
122
+ }, {
123
+ Choice: '.ql-header .ql-picker-label',
124
+ title: t('ui.richText.pickerLabel')
125
+ }, {
126
+ Choice: '.ql-header .ql-picker-item[data-value="1"]',
127
+ title: t('ui.richText.headerPicker1')
128
+ }, {
129
+ Choice: '.ql-header .ql-picker-item[data-value="2"]',
130
+ title: t('ui.richText.headerPicker2')
131
+ }, {
132
+ Choice: '.ql-header .ql-picker-item[data-value="3"]',
133
+ title: t('ui.richText.headerPicker3')
134
+ }, {
135
+ Choice: '.ql-header .ql-picker-item[data-value="4"]',
136
+ title: t('ui.richText.headerPicker4')
137
+ }, {
138
+ Choice: '.ql-header .ql-picker-item[data-value="5"]',
139
+ title: t('ui.richText.headerPicker5')
140
+ }, {
141
+ Choice: '.ql-header .ql-picker-item[data-value="6"]',
142
+ title: t('ui.richText.headerPicker6')
143
+ }, {
144
+ Choice: '.ql-header .ql-picker-item:last-child',
145
+ title: t('ui.richText.normal')
146
+ }, {
147
+ Choice: '.ql-size .ql-picker-item[data-value="small"]',
148
+ title: t('ui.richText.sizeSmall')
149
+ }, {
150
+ Choice: '.ql-size .ql-picker-item[data-value="large"]',
151
+ title: t('ui.richText.sizeLarge')
152
+ }, {
153
+ Choice: '.ql-size .ql-picker-item[data-value="huge"]',
154
+ title: t('ui.richText.sizeHuge')
155
+ }, {
156
+ Choice: '.ql-size .ql-picker-item:nth-child(2)',
157
+ title: t('ui.richText.normal')
158
+ }, {
159
+ Choice: '.ql-align .ql-picker-item:first-child',
160
+ title: t('ui.richText.alignPicker1')
161
+ }, {
162
+ Choice: '.ql-align .ql-picker-item[data-value="center"]',
163
+ title: t('ui.richText.alignPicker2')
164
+ }, {
165
+ Choice: '.ql-align .ql-picker-item[data-value="right"]',
166
+ title: t('ui.richText.alignPicker3')
167
+ }, {
168
+ Choice: '.ql-align .ql-picker-item[data-value="justify"]',
169
+ title: t('ui.richText.alignPicker4')
170
+ }, {
171
+ Choice: '.ql-script[value="sub"]',
172
+ title: t('ui.richText.subScript')
173
+ }, {
174
+ Choice: '.ql-script[value="super"]',
175
+ title: t('ui.richText.superScript')
176
+ }, {
177
+ Choice: '.ql-direction[value="rtl"]',
178
+ title: t('ui.richText.directionRTL')
179
+ }, {
180
+ Choice: '.ql-font',
181
+ title: t('ui.richText.font')
182
+ }, {
183
+ Choice: '.ql-file',
184
+ title: t('ui.richText.file')
185
+ }];
186
+ };
187
+ export { defaultOptions, getToolbarTips };