dtable-ui-component 0.1.75-beta3 → 0.1.75-beta4

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 (223) hide show
  1. package/lib/AutoNumberFormatter/index.js +27 -38
  2. package/lib/ButtonFormatter/index.js +47 -59
  3. package/lib/CTimeFormatter/index.js +39 -53
  4. package/lib/CheckboxFormatter/index.js +35 -48
  5. package/lib/CollaboratorFormatter/index.js +42 -64
  6. package/lib/CollaboratorItem/index.js +44 -61
  7. package/lib/CreatorFormatter/index.js +42 -62
  8. package/lib/DateFormatter/index.js +40 -55
  9. package/lib/DurationFormatter/index.js +29 -42
  10. package/lib/EmailFormatter/index.js +27 -38
  11. package/lib/FileFormatter/index.js +50 -65
  12. package/lib/FileItemFormatter/index.js +32 -44
  13. package/lib/FileUploader/index.js +34 -44
  14. package/lib/FormulaFormatter/index.js +81 -102
  15. package/lib/GeolocationFormatter/index.js +35 -50
  16. package/lib/ImageFormatter/images-lazy-load.js +73 -81
  17. package/lib/ImageFormatter/index.js +90 -109
  18. package/lib/ImagePreviewerLightbox/index.js +27 -60
  19. package/lib/LastModifierFormatter/index.js +42 -62
  20. package/lib/LinkFormatter/index.js +59 -80
  21. package/lib/Loading/index.js +4 -13
  22. package/lib/LongTextFormatter/html-long-text-formatter.js +49 -60
  23. package/lib/LongTextFormatter/index.js +9 -28
  24. package/lib/LongTextFormatter/simple-long-text-formatter.js +52 -58
  25. package/lib/MTimeFormatter/index.js +39 -53
  26. package/lib/ModalPortal/index.js +30 -37
  27. package/lib/MultipleSelectFormatter/index.js +39 -55
  28. package/lib/NumberFormatter/index.js +35 -50
  29. package/lib/RateFormatter/index.js +37 -52
  30. package/lib/SelectItem/index.js +31 -46
  31. package/lib/SingleSelectFormatter/index.js +38 -54
  32. package/lib/TextFormatter/index.js +31 -44
  33. package/lib/UrlFormatter/index.js +27 -38
  34. package/lib/app.js +75 -80
  35. package/lib/cellFormatterFactory/index.js +17 -20
  36. package/lib/components/cell-editor/checkbox-editor.js +59 -66
  37. package/lib/components/cell-editor/collaborator-editor.js +113 -126
  38. package/lib/components/cell-editor/date-editor.js +99 -119
  39. package/lib/components/cell-editor/index.js +9 -40
  40. package/lib/components/cell-editor/link-editor.js +122 -140
  41. package/lib/components/cell-editor/multiple-select-editor.js +114 -127
  42. package/lib/components/cell-editor/number-editor.js +78 -86
  43. package/lib/components/cell-editor/single-select-editor.js +106 -120
  44. package/lib/components/cell-editor/text-editor.js +65 -72
  45. package/lib/components/cell-editor-dialog/pc-file-editor-dialog.js +31 -51
  46. package/lib/components/cell-editor-dialog/pc-files-addition/index.js +0 -1
  47. package/lib/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -1
  48. package/lib/components/cell-editor-dialog/pc-files-preview/index.js +0 -1
  49. package/lib/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -1
  50. package/lib/components/cell-editor-popover/mb-collaborator-editor-popover.js +105 -111
  51. package/lib/components/cell-editor-popover/mb-date-editor-popover.js +140 -157
  52. package/lib/components/cell-editor-popover/mb-link-editor-popover.js +103 -109
  53. package/lib/components/cell-editor-popover/mb-select-editor-popover.js +142 -155
  54. package/lib/components/cell-editor-popover/pc-collaborator-editor-popover.js +74 -89
  55. package/lib/components/cell-editor-popover/pc-date-editor-popover.js +88 -102
  56. package/lib/components/cell-editor-popover/pc-link-editor-popover.js +77 -91
  57. package/lib/components/cell-editor-popover/pc-select-editor-popover.js +91 -105
  58. package/lib/components/common/collaborator-item.js +43 -59
  59. package/lib/components/common/edit-editor-button.js +28 -39
  60. package/lib/components/common/link-editor-option.js +63 -71
  61. package/lib/components/common/mobile/mb-editor-header.js +39 -52
  62. package/lib/components/common/select-editor-option.js +58 -74
  63. package/lib/constants/cell-types.js +25 -54
  64. package/lib/constants/index.js +5 -28
  65. package/lib/formatterConfig/index.js +28 -59
  66. package/lib/index.js +31 -139
  67. package/lib/lang/index.js +11 -27
  68. package/lib/locals/de.js +1 -6
  69. package/lib/locals/en.js +1 -6
  70. package/lib/locals/fr.js +1 -6
  71. package/lib/locals/zh-CN.js +1 -6
  72. package/lib/toaster/alert.js +92 -106
  73. package/lib/toaster/index.js +3 -12
  74. package/lib/toaster/toast.js +103 -147
  75. package/lib/toaster/toastManager.js +78 -97
  76. package/lib/toaster/toaster.js +36 -52
  77. package/lib/utils/cell-value-validator.js +5 -9
  78. package/lib/utils/column-utils.js +5 -13
  79. package/lib/utils/editor-utils.js +3 -13
  80. package/lib/utils/markdown2html.js +1 -7
  81. package/lib/utils/normalize-long-text-value.js +1 -6
  82. package/lib/utils/number-precision.js +13 -31
  83. package/lib/utils/utils.js +8 -33
  84. package/lib/utils/value-format-utils.js +58 -108
  85. package/package.json +5 -5
  86. package/es/AutoNumberFormatter/index.css +0 -1
  87. package/es/AutoNumberFormatter/index.js +0 -36
  88. package/es/ButtonFormatter/index.css +0 -13
  89. package/es/ButtonFormatter/index.js +0 -56
  90. package/es/CTimeFormatter/index.css +0 -1
  91. package/es/CTimeFormatter/index.js +0 -58
  92. package/es/CheckboxFormatter/index.css +0 -1
  93. package/es/CheckboxFormatter/index.js +0 -45
  94. package/es/CollaboratorFormatter/index.css +0 -1
  95. package/es/CollaboratorFormatter/index.js +0 -91
  96. package/es/CollaboratorItem/index.css +0 -49
  97. package/es/CollaboratorItem/index.js +0 -64
  98. package/es/CreatorFormatter/index.css +0 -1
  99. package/es/CreatorFormatter/index.js +0 -87
  100. package/es/DateFormatter/index.css +0 -1
  101. package/es/DateFormatter/index.js +0 -60
  102. package/es/DurationFormatter/index.css +0 -1
  103. package/es/DurationFormatter/index.js +0 -38
  104. package/es/EmailFormatter/index.css +0 -5
  105. package/es/EmailFormatter/index.js +0 -36
  106. package/es/FileFormatter/index.css +0 -29
  107. package/es/FileFormatter/index.js +0 -64
  108. package/es/FileItemFormatter/index.js +0 -50
  109. package/es/FileUploader/index.js +0 -53
  110. package/es/FormulaFormatter/index.css +0 -19
  111. package/es/FormulaFormatter/index.js +0 -164
  112. package/es/GeolocationFormatter/index.css +0 -1
  113. package/es/GeolocationFormatter/index.js +0 -53
  114. package/es/ImageFormatter/images-lazy-load.js +0 -150
  115. package/es/ImageFormatter/index.css +0 -34
  116. package/es/ImageFormatter/index.js +0 -154
  117. package/es/ImagePreviewerLightbox/index.css +0 -87
  118. package/es/ImagePreviewerLightbox/index.js +0 -119
  119. package/es/LastModifierFormatter/index.css +0 -1
  120. package/es/LastModifierFormatter/index.js +0 -87
  121. package/es/LinkFormatter/index.css +0 -27
  122. package/es/LinkFormatter/index.js +0 -144
  123. package/es/Loading/index.css +0 -54
  124. package/es/Loading/index.js +0 -7
  125. package/es/LongTextFormatter/html-long-text-formatter.js +0 -96
  126. package/es/LongTextFormatter/index.css +0 -63
  127. package/es/LongTextFormatter/index.js +0 -29
  128. package/es/LongTextFormatter/simple-long-text-formatter.js +0 -104
  129. package/es/MTimeFormatter/index.css +0 -1
  130. package/es/MTimeFormatter/index.js +0 -58
  131. package/es/ModalPortal/index.js +0 -44
  132. package/es/MultipleSelectFormatter/index.css +0 -1
  133. package/es/MultipleSelectFormatter/index.js +0 -70
  134. package/es/NumberFormatter/index.css +0 -1
  135. package/es/NumberFormatter/index.js +0 -47
  136. package/es/RateFormatter/index.css +0 -1
  137. package/es/RateFormatter/index.js +0 -80
  138. package/es/SelectItem/index.js +0 -58
  139. package/es/SingleSelectFormatter/index.css +0 -1
  140. package/es/SingleSelectFormatter/index.js +0 -70
  141. package/es/TextFormatter/index.css +0 -1
  142. package/es/TextFormatter/index.js +0 -56
  143. package/es/UrlFormatter/index.css +0 -5
  144. package/es/UrlFormatter/index.js +0 -36
  145. package/es/app.css +0 -20
  146. package/es/app.js +0 -91
  147. package/es/assets/images/avatar/default_avatar.png +0 -0
  148. package/es/assets/images/file/192/excel.png +0 -0
  149. package/es/assets/images/file/192/file.png +0 -0
  150. package/es/assets/images/file/192/music.png +0 -0
  151. package/es/assets/images/file/192/pdf.png +0 -0
  152. package/es/assets/images/file/192/pic.png +0 -0
  153. package/es/assets/images/file/192/ppt.png +0 -0
  154. package/es/assets/images/file/192/txt.png +0 -0
  155. package/es/assets/images/file/192/video.png +0 -0
  156. package/es/assets/images/file/192/word.png +0 -0
  157. package/es/assets/images/file/24/excel.png +0 -0
  158. package/es/assets/images/file/24/file.png +0 -0
  159. package/es/assets/images/file/24/music.png +0 -0
  160. package/es/assets/images/file/24/pdf.png +0 -0
  161. package/es/assets/images/file/24/pic.png +0 -0
  162. package/es/assets/images/file/24/ppt.png +0 -0
  163. package/es/assets/images/file/24/txt.png +0 -0
  164. package/es/assets/images/file/24/video.png +0 -0
  165. package/es/assets/images/file/24/word.png +0 -0
  166. package/es/assets/images/folder/folder-192.png +0 -0
  167. package/es/assets/images/folder/folder-24.png +0 -0
  168. package/es/cellFormatterFactory/index.js +0 -25
  169. package/es/components/cell-editor/checkbox-editor.js +0 -104
  170. package/es/components/cell-editor/collaborator-editor.js +0 -236
  171. package/es/components/cell-editor/date-editor.js +0 -151
  172. package/es/components/cell-editor/index.js +0 -9
  173. package/es/components/cell-editor/link-editor.js +0 -303
  174. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  175. package/es/components/cell-editor/number-editor.js +0 -154
  176. package/es/components/cell-editor/single-select-editor.js +0 -202
  177. package/es/components/cell-editor/text-editor.js +0 -122
  178. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  179. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  180. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  181. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  182. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  183. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  184. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  185. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  186. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  187. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  188. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  189. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  190. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  191. package/es/components/common/collaborator-item.js +0 -63
  192. package/es/components/common/edit-editor-button.js +0 -56
  193. package/es/components/common/link-editor-option.js +0 -113
  194. package/es/components/common/mobile/mb-editor-header.js +0 -48
  195. package/es/components/common/select-editor-option.js +0 -106
  196. package/es/constants/cell-types.js +0 -25
  197. package/es/constants/index.js +0 -49
  198. package/es/css/cell-editor.css +0 -614
  199. package/es/css/cell-formatter.css +0 -4
  200. package/es/css/custom-rc-calendar.css +0 -118
  201. package/es/formatterConfig/index.js +0 -31
  202. package/es/index.js +0 -31
  203. package/es/lang/index.js +0 -50
  204. package/es/locals/de.js +0 -2
  205. package/es/locals/en.js +0 -17
  206. package/es/locals/fr.js +0 -2
  207. package/es/locals/zh-CN.js +0 -17
  208. package/es/toaster/alert.js +0 -150
  209. package/es/toaster/index.js +0 -3
  210. package/es/toaster/toast.js +0 -179
  211. package/es/toaster/toastManager.js +0 -170
  212. package/es/toaster/toaster.js +0 -76
  213. package/es/utils/cell-value-validator.js +0 -31
  214. package/es/utils/column-utils.js +0 -7
  215. package/es/utils/editor-utils.js +0 -71
  216. package/es/utils/markdown2html.js +0 -62
  217. package/es/utils/normalize-long-text-value.js +0 -69
  218. package/es/utils/number-precision.js +0 -164
  219. package/es/utils/unified/index.js +0 -470
  220. package/es/utils/utils.js +0 -116
  221. package/es/utils/value-format-utils.js +0 -497
  222. package/es/utils/vfile/core.js +0 -172
  223. package/es/utils/vfile/index.js +0 -48
@@ -1,470 +0,0 @@
1
- 'use strict';
2
- /* Dependencies. */
3
-
4
- var extend = require('extend');
5
-
6
- var bail = require('bail');
7
-
8
- var vfile = require('../vfile');
9
-
10
- var trough = require('trough');
11
-
12
- var string = require('x-is-string');
13
-
14
- var plain = require('is-plain-obj');
15
- /* Expose a frozen processor. */
16
-
17
-
18
- module.exports = unified().freeze();
19
- var slice = [].slice;
20
- var own = {}.hasOwnProperty;
21
- /* Process pipeline. */
22
-
23
- var pipeline = trough().use(pipelineParse).use(pipelineRun).use(pipelineStringify);
24
-
25
- function pipelineParse(p, ctx) {
26
- ctx.tree = p.parse(ctx.file);
27
- }
28
-
29
- function pipelineRun(p, ctx, next) {
30
- p.run(ctx.tree, ctx.file, done);
31
-
32
- function done(err, tree, file) {
33
- if (err) {
34
- next(err);
35
- } else {
36
- ctx.tree = tree;
37
- ctx.file = file;
38
- next();
39
- }
40
- }
41
- }
42
-
43
- function pipelineStringify(p, ctx) {
44
- ctx.file.contents = p.stringify(ctx.tree, ctx.file);
45
- }
46
- /* Function to create the first processor. */
47
-
48
-
49
- function unified() {
50
- var attachers = [];
51
- var transformers = trough();
52
- var namespace = {};
53
- var frozen = false;
54
- var freezeIndex = -1;
55
- /* Data management. */
56
-
57
- processor.data = data;
58
- /* Lock. */
59
-
60
- processor.freeze = freeze;
61
- /* Plug-ins. */
62
-
63
- processor.attachers = attachers;
64
- processor.use = use;
65
- /* API. */
66
-
67
- processor.parse = parse;
68
- processor.stringify = stringify;
69
- processor.run = run;
70
- processor.runSync = runSync;
71
- processor.process = process;
72
- processor.processSync = processSync;
73
- /* Expose. */
74
-
75
- return processor;
76
- /* Create a new processor based on the processor
77
- * in the current scope. */
78
-
79
- function processor() {
80
- var destination = unified();
81
- var length = attachers.length;
82
- var index = -1;
83
-
84
- while (++index < length) {
85
- destination.use.apply(null, attachers[index]);
86
- }
87
-
88
- destination.data(extend(true, {}, namespace));
89
- return destination;
90
- }
91
- /* Freeze: used to signal a processor that has finished
92
- * configuration.
93
- *
94
- * For example, take unified itself. It’s frozen.
95
- * Plug-ins should not be added to it. Rather, it should
96
- * be extended, by invoking it, before modifying it.
97
- *
98
- * In essence, always invoke this when exporting a
99
- * processor. */
100
-
101
-
102
- function freeze() {
103
- var values;
104
- var plugin;
105
- var options;
106
- var transformer;
107
-
108
- if (frozen) {
109
- return processor;
110
- }
111
-
112
- while (++freezeIndex < attachers.length) {
113
- values = attachers[freezeIndex];
114
- plugin = values[0];
115
- options = values[1];
116
- transformer = null;
117
-
118
- if (options === false) {
119
- continue;
120
- }
121
-
122
- if (options === true) {
123
- values[1] = undefined;
124
- }
125
-
126
- transformer = plugin.apply(processor, values.slice(1));
127
-
128
- if (typeof transformer === 'function') {
129
- transformers.use(transformer);
130
- }
131
- }
132
-
133
- frozen = true;
134
- freezeIndex = Infinity;
135
- return processor;
136
- }
137
- /* Data management.
138
- * Getter / setter for processor-specific informtion. */
139
-
140
-
141
- function data(key, value) {
142
- if (string(key)) {
143
- /* Set `key`. */
144
- if (arguments.length === 2) {
145
- assertUnfrozen('data', frozen);
146
- namespace[key] = value;
147
- return processor;
148
- }
149
- /* Get `key`. */
150
-
151
-
152
- return own.call(namespace, key) && namespace[key] || null;
153
- }
154
- /* Set space. */
155
-
156
-
157
- if (key) {
158
- assertUnfrozen('data', frozen);
159
- namespace = key;
160
- return processor;
161
- }
162
- /* Get space. */
163
-
164
-
165
- return namespace;
166
- }
167
- /* Plug-in management.
168
- *
169
- * Pass it:
170
- * * an attacher and options,
171
- * * a preset,
172
- * * a list of presets, attachers, and arguments (list
173
- * of attachers and options). */
174
-
175
-
176
- function use(value) {
177
- var settings;
178
- assertUnfrozen('use', frozen);
179
-
180
- if (value === null || value === undefined) {
181
- /* Empty */
182
- } else if (typeof value === 'function') {
183
- addPlugin.apply(null, arguments);
184
- } else if (typeof value === 'object') {
185
- if ('length' in value) {
186
- addList(value);
187
- } else {
188
- addPreset(value);
189
- }
190
- } else {
191
- throw new Error('Expected usable value, not `' + value + '`');
192
- }
193
-
194
- if (settings) {
195
- namespace.settings = extend(namespace.settings || {}, settings);
196
- }
197
-
198
- return processor;
199
-
200
- function addPreset(result) {
201
- addList(result.plugins);
202
-
203
- if (result.settings) {
204
- settings = extend(settings || {}, result.settings);
205
- }
206
- }
207
-
208
- function add(value) {
209
- if (typeof value === 'function') {
210
- addPlugin(value);
211
- } else if (typeof value === 'object') {
212
- if ('length' in value) {
213
- addPlugin.apply(null, value);
214
- } else {
215
- addPreset(value);
216
- }
217
- } else {
218
- throw new Error('Expected usable value, not `' + value + '`');
219
- }
220
- }
221
-
222
- function addList(plugins) {
223
- var length;
224
- var index;
225
-
226
- if (plugins === null || plugins === undefined) {
227
- /* Empty */
228
- } else if (typeof plugins === 'object' && 'length' in plugins) {
229
- length = plugins.length;
230
- index = -1;
231
-
232
- while (++index < length) {
233
- add(plugins[index]);
234
- }
235
- } else {
236
- throw new Error('Expected a list of plugins, not `' + plugins + '`');
237
- }
238
- }
239
-
240
- function addPlugin(plugin, value) {
241
- var entry = find(plugin);
242
-
243
- if (entry) {
244
- if (plain(entry[1]) && plain(value)) {
245
- value = extend(entry[1], value);
246
- }
247
-
248
- entry[1] = value;
249
- } else {
250
- attachers.push(slice.call(arguments));
251
- }
252
- }
253
- }
254
-
255
- function find(plugin) {
256
- var length = attachers.length;
257
- var index = -1;
258
- var entry;
259
-
260
- while (++index < length) {
261
- entry = attachers[index];
262
-
263
- if (entry[0] === plugin) {
264
- return entry;
265
- }
266
- }
267
- }
268
- /* Parse a file (in string or VFile representation)
269
- * into a Unist node using the `Parser` on the
270
- * processor. */
271
-
272
-
273
- function parse(doc) {
274
- var file = vfile(doc);
275
- var Parser;
276
- freeze();
277
- Parser = processor.Parser;
278
- assertParser('parse', Parser);
279
-
280
- if (newable(Parser)) {
281
- return new Parser(String(file), file).parse();
282
- }
283
-
284
- return Parser(String(file), file); // eslint-disable-line new-cap
285
- }
286
- /* Run transforms on a Unist node representation of a file
287
- * (in string or VFile representation), async. */
288
-
289
-
290
- function run(node, file, cb) {
291
- assertNode(node);
292
- freeze();
293
-
294
- if (!cb && typeof file === 'function') {
295
- cb = file;
296
- file = null;
297
- }
298
-
299
- if (!cb) {
300
- return new Promise(executor);
301
- }
302
-
303
- executor(null, cb);
304
-
305
- function executor(resolve, reject) {
306
- transformers.run(node, vfile(file), done);
307
-
308
- function done(err, tree, file) {
309
- tree = tree || node;
310
-
311
- if (err) {
312
- reject(err);
313
- } else if (resolve) {
314
- resolve(tree);
315
- } else {
316
- cb(null, tree, file);
317
- }
318
- }
319
- }
320
- }
321
- /* Run transforms on a Unist node representation of a file
322
- * (in string or VFile representation), sync. */
323
-
324
-
325
- function runSync(node, file) {
326
- var complete = false;
327
- var result;
328
- run(node, file, done);
329
- assertDone('runSync', 'run', complete);
330
- return result;
331
-
332
- function done(err, tree) {
333
- complete = true;
334
- bail(err);
335
- result = tree;
336
- }
337
- }
338
- /* Stringify a Unist node representation of a file
339
- * (in string or VFile representation) into a string
340
- * using the `Compiler` on the processor. */
341
-
342
-
343
- function stringify(node, doc) {
344
- var file = vfile(doc);
345
- var Compiler;
346
- freeze();
347
- Compiler = processor.Compiler;
348
- assertCompiler('stringify', Compiler);
349
- assertNode(node);
350
-
351
- if (newable(Compiler)) {
352
- return new Compiler(node, file).compile();
353
- }
354
-
355
- return Compiler(node, file); // eslint-disable-line new-cap
356
- }
357
- /* Parse a file (in string or VFile representation)
358
- * into a Unist node using the `Parser` on the processor,
359
- * then run transforms on that node, and compile the
360
- * resulting node using the `Compiler` on the processor,
361
- * and store that result on the VFile. */
362
-
363
-
364
- function process(doc, cb) {
365
- freeze();
366
- assertParser('process', processor.Parser);
367
- assertCompiler('process', processor.Compiler);
368
-
369
- if (!cb) {
370
- return new Promise(executor);
371
- }
372
-
373
- executor(null, cb);
374
-
375
- function executor(resolve, reject) {
376
- var file = vfile(doc);
377
- pipeline.run(processor, {
378
- file: file
379
- }, done);
380
-
381
- function done(err) {
382
- if (err) {
383
- reject(err);
384
- } else if (resolve) {
385
- resolve(file);
386
- } else {
387
- cb(null, file);
388
- }
389
- }
390
- }
391
- }
392
- /* Process the given document (in string or VFile
393
- * representation), sync. */
394
-
395
-
396
- function processSync(doc) {
397
- var complete = false;
398
- var file;
399
- freeze();
400
- assertParser('processSync', processor.Parser);
401
- assertCompiler('processSync', processor.Compiler);
402
- file = vfile(doc);
403
- process(file, done);
404
- assertDone('processSync', 'process', complete);
405
- return file;
406
-
407
- function done(err) {
408
- complete = true;
409
- bail(err);
410
- }
411
- }
412
- }
413
- /* Check if `func` is a constructor. */
414
-
415
-
416
- function newable(value) {
417
- return typeof value === 'function' && keys(value.prototype);
418
- }
419
- /* Check if `value` is an object with keys. */
420
-
421
-
422
- function keys(value) {
423
- var key;
424
-
425
- for (key in value) {
426
- return true;
427
- }
428
-
429
- return false;
430
- }
431
- /* Assert a parser is available. */
432
-
433
-
434
- function assertParser(name, Parser) {
435
- if (typeof Parser !== 'function') {
436
- throw new Error('Cannot `' + name + '` without `Parser`');
437
- }
438
- }
439
- /* Assert a compiler is available. */
440
-
441
-
442
- function assertCompiler(name, Compiler) {
443
- if (typeof Compiler !== 'function') {
444
- throw new Error('Cannot `' + name + '` without `Compiler`');
445
- }
446
- }
447
- /* Assert the processor is not frozen. */
448
-
449
-
450
- function assertUnfrozen(name, frozen) {
451
- if (frozen) {
452
- throw new Error(['Cannot invoke `' + name + '` on a frozen processor.\nCreate a new ', 'processor first, by invoking it: use `processor()` instead of ', '`processor`.'].join(''));
453
- }
454
- }
455
- /* Assert `node` is a Unist node. */
456
-
457
-
458
- function assertNode(node) {
459
- if (!node || !string(node.type)) {
460
- throw new Error('Expected node, got `' + node + '`');
461
- }
462
- }
463
- /* Assert that `complete` is `true`. */
464
-
465
-
466
- function assertDone(name, asyncName, complete) {
467
- if (!complete) {
468
- throw new Error('`' + name + '` finished async. Use `' + asyncName + '` instead');
469
- }
470
- }
package/es/utils/utils.js DELETED
@@ -1,116 +0,0 @@
1
- var FILEEXT_ICON_MAP = {
2
- // text file
3
- md: "txt.png",
4
- txt: "txt.png",
5
- // pdf file
6
- pdf: "pdf.png",
7
- // document file
8
- doc: "word.png",
9
- docx: "word.png",
10
- odt: "word.png",
11
- fodt: "word.png",
12
- ppt: "ppt.png",
13
- pptx: "ppt.png",
14
- odp: "ppt.png",
15
- fodp: "ppt.png",
16
- xls: "excel.png",
17
- xlsx: "excel.png",
18
- ods: "excel.png",
19
- fods: "excel.png",
20
- // video
21
- mp4: "video.png",
22
- ogv: "video.png",
23
- webm: "video.png",
24
- mov: "video.png",
25
- flv: "video.png",
26
- wmv: "video.png",
27
- rmvb: "video.png",
28
- // music file
29
- mp3: "music.png",
30
- oga: "music.png",
31
- ogg: "music.png",
32
- flac: "music.png",
33
- aac: "music.png",
34
- ac3: "music.png",
35
- wma: "music.png",
36
- // image file
37
- jpg: "pic.png",
38
- jpeg: "pic.png",
39
- png: "pic.png",
40
- svg: "pic.png",
41
- gif: "pic.png",
42
- bmp: "pic.png",
43
- ico: "pic.png",
44
- // folder dir
45
- folder: "folder-192.png",
46
- // default
47
- default: "file.png"
48
- };
49
- export var getFileIconUrl = function getFileIconUrl(filename, direntType) {
50
- if (direntType === "dir") {
51
- var _iconUrl = "assets/images/folder/" + FILEEXT_ICON_MAP["folder"];
52
-
53
- return _iconUrl;
54
- }
55
-
56
- var iconUrl = "";
57
-
58
- if (filename.lastIndexOf(".") === -1) {
59
- iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
60
- return iconUrl;
61
- }
62
-
63
- var file_ext = filename.substr(filename.lastIndexOf(".") + 1).toLowerCase();
64
-
65
- if (FILEEXT_ICON_MAP[file_ext]) {
66
- iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP[file_ext];
67
- } else {
68
- iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
69
- }
70
-
71
- return iconUrl;
72
- };
73
- export var getImageThumbnailUrl = function getImageThumbnailUrl(url, server) {
74
- if (server && url.indexOf(server) > -1) {
75
- return url.replace("/workspace", "/thumbnail/workspace") + "?size=256";
76
- }
77
-
78
- return url;
79
- };
80
- export var debounce = function debounce(fn, wait) {
81
- var timeout = null;
82
- return function () {
83
- if (timeout !== null) clearTimeout(timeout);
84
- timeout = setTimeout(fn, wait);
85
- };
86
- };
87
- export var throttle = function throttle(func, delay) {
88
- var timer = null;
89
- var startTime = Date.now();
90
- return function () {
91
- var curTime = Date.now();
92
- var remaining = delay - (curTime - startTime);
93
- var context = this;
94
- var args = arguments;
95
- clearTimeout(timer);
96
-
97
- if (remaining <= 0) {
98
- func.apply(context, args);
99
- startTime = Date.now();
100
- } else {
101
- timer = setTimeout(func, remaining);
102
- }
103
- };
104
- };
105
- export var isFunction = function isFunction(functionToCheck) {
106
- var getType = {};
107
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
108
- };
109
- export var isInternalImg = function isInternalImg(url) {
110
- if (!url) return;
111
- return url.indexOf(window.dtable.server) > -1;
112
- };
113
- export var checkSVGImage = function checkSVGImage(url) {
114
- if (!url) return false;
115
- return url.substr(-4).toLowerCase() === '.svg';
116
- };