Skip to content

Commit c0596c4

Browse files
authored
feat: update Quill to v2.0 (#1168)
Closes: #1165 Closes: #1150
1 parent dbd486b commit c0596c4

File tree

8 files changed

+267
-180
lines changed

8 files changed

+267
-180
lines changed

bower.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@
7171
"web-animations-js": "2.2.2",
7272
"x2js": "1.2.0",
7373
"js-yaml": "^3.7.0",
74-
"canvg": "^1.3.0",
75-
"quill": "https://github.com/quilljs/quill/releases/download/v1.3.7/quill.tar.gz"
74+
"canvg": "^1.3.0"
7675
},
7776
"resolutions": {
7877
"jsgraph": "2.2.36",

gruntfile.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
module.exports = function (grunt) {
44
const walk = require('walk');
5-
const fs = require('fs');
5+
const fs = require('node:fs');
66
const mkpath = require('mkpath');
7-
const path = require('path');
7+
const path = require('node:path');
88
const extend = require('extend');
9-
const child_process = require('child_process');
9+
const child_process = require('node:child_process');
1010
const semver = require('semver');
1111
const changelog = require('conventional-changelog').default;
1212
const tempfile = require('tempfile');
@@ -27,23 +27,25 @@ module.exports = function (grunt) {
2727
ignore: false,
2828
});
2929

30-
if (!this.files.length) {
30+
if (this.files.length === 0) {
3131
grunt.log.writeln(`Moved ${'0'.cyan} files.`);
3232
return done();
3333
}
3434

35-
this.files.forEach(function (f) {
35+
for (const f of this.files) {
3636
let dest = f.dest;
3737
let dir = path.dirname(dest);
3838

3939
// Check if no source files were found
4040
if (f.src.length === 0) {
4141
// Continue if ignore is set
4242
if (options.ignore) {
43-
return done();
43+
done();
44+
continue;
4445
} else {
4546
grunt.fail.warn(`Could not move file to ${f.dest} it did not exist.`);
46-
return done();
47+
done();
48+
continue;
4749
}
4850
}
4951

@@ -90,15 +92,15 @@ module.exports = function (grunt) {
9092
read.pipe(write);
9193
});
9294
});
93-
});
95+
}
9496
});
9597

9698
function mapPath(path) {
9799
// Map a relative application path to a relative build path
98100
var mapped;
99-
if (path.indexOf('usr/') === 0) mapped = usrPath + path.substr(3);
101+
if (path.indexOf('usr/') === 0) mapped = usrPath + path.slice(3);
100102
else mapped = `./src/${path}`;
101-
if (mapped.indexOf('.js') === -1) mapped += '.js';
103+
if (!mapped.includes('.js')) mapped += '.js';
102104
return mapped;
103105
}
104106

@@ -280,7 +282,6 @@ module.exports = function (grunt) {
280282
'./js-yaml/dist/**',
281283
'./canvg/dist/**',
282284
'./eventEmitter/*.js',
283-
['./quill/*.min.js*', './quill/*.css'],
284285
],
285286
dest: './build/components/',
286287
},
@@ -290,11 +291,15 @@ module.exports = function (grunt) {
290291
src: [
291292
'./katex/dist/**',
292293
'./angularplasmid/dist/**',
293-
'./quill-image-drop-module/image-drop.min.js',
294-
'./quill-image-resize-module/image-resize.min.js',
295294
'./mathjs/dist/math.min.js',
296295
'./mathjs/dist/math.min.map',
297296
'./openchemlib/dist/**',
297+
[
298+
'./quill/dist/*.js*',
299+
'./quill/dist/*.css',
300+
'./quill-resize-module/dist/resize.*',
301+
'./quill-table-better/dist/quill-table-better.*',
302+
],
298303
'./d3-hierarchy/dist/d3-hierarchy.min.js',
299304
'./@fortawesome/fontawesome-free/css/all.min.css',
300305
'./@fortawesome/fontawesome-free/webfonts/*',
@@ -368,9 +373,9 @@ module.exports = function (grunt) {
368373
dest: './build/usr/',
369374
filter(filepath) {
370375
var modulesStack = grunt.option('modulesStack');
371-
filepath = filepath.replace(/\\/g, '/');
376+
filepath = filepath.replaceAll('\\', '/');
372377
for (const i in modulesStack) {
373-
if (filepath.indexOf(i.substr(4)) > -1) {
378+
if (filepath.includes(i.slice(4))) {
374379
return true;
375380
}
376381
}
@@ -384,9 +389,9 @@ module.exports = function (grunt) {
384389
dest: './build/',
385390
filter(filepath) {
386391
var modulesStack = grunt.option('modulesStack');
387-
filepath = filepath.replace(/\\/g, '/');
392+
filepath = filepath.replaceAll('\\', '/');
388393
for (const i in modulesStack) {
389-
if (filepath.indexOf(i) > -1) {
394+
if (filepath.includes(i)) {
390395
return true;
391396
}
392397
}
@@ -503,8 +508,8 @@ module.exports = function (grunt) {
503508
let p;
504509
if (root === '.') {
505510
p = fileStats.name;
506-
} else if (root.substr(0, 2) === './') {
507-
p = `${root.substr(2)}/${fileStats.name}`;
511+
} else if (root.slice(0, 2) === './') {
512+
p = `${root.slice(2)}/${fileStats.name}`;
508513
} else {
509514
p = `${root}/${fileStats.name}`;
510515
}
@@ -585,8 +590,8 @@ module.exports = function (grunt) {
585590
// Not a very neat fix but whatever
586591
const pos = arguments[0].search('usr');
587592
if (pos > -1) {
588-
console.log('new : ', arguments[0].substring(pos + 1));
589-
arguments[0] = arguments[0].substring(pos + 1);
593+
console.log('new :', arguments[0].slice(pos + 1));
594+
arguments[0] = arguments[0].slice(pos + 1);
590595
}
591596
return oldLoadFile(arguments[0], `${usrPath}/`);
592597
}
@@ -632,7 +637,7 @@ module.exports = function (grunt) {
632637

633638
function getRealPath(path) {
634639
if (path.indexOf('usr') === 0) {
635-
path = usrDir + path.substr(3);
640+
path = usrDir + path.slice(3);
636641
}
637642
return `./src/${path}`;
638643
}
@@ -650,7 +655,7 @@ module.exports = function (grunt) {
650655
}
651656

652657
jsonStructure.name = file.name;
653-
if (file.folders && file.folders instanceof Array) {
658+
if (file.folders && Array.isArray(file.folders)) {
654659
for (let i = 0; i < file.folders.length; i++) {
655660
const res = loadFile(`${fileName}/${file.folders[i]}`);
656661
jsonStructure.folders[res.name] = res;
@@ -668,7 +673,7 @@ module.exports = function (grunt) {
668673
}
669674

670675
if (cfg.modules) {
671-
if (cfg.modules instanceof Array) {
676+
if (Array.isArray(cfg.modules)) {
672677
// Backwards compatibility
673678
for (let i = 0; i < cfg.modules.length; i++) {
674679
if (typeof cfg.modules[i] == 'object') {
@@ -677,7 +682,7 @@ module.exports = function (grunt) {
677682
extend(true, modulesFinal, oldLoadFile(cfg.modules[i]));
678683
}
679684
}
680-
} else if (cfg.modules.folders instanceof Array) {
685+
} else if (Array.isArray(cfg.modules.folders)) {
681686
const list = cfg.modules;
682687
if (list.modules) {
683688
modulesFinal.modules = [];
@@ -856,7 +861,7 @@ module.exports = function (grunt) {
856861
versionJS = setVersionValue(
857862
versionJS,
858863
'PRERELEASE',
859-
semVersion.prerelease.length ? semVersion.prerelease[0] : 'false',
864+
semVersion.prerelease.length > 0 ? semVersion.prerelease[0] : 'false',
860865
);
861866

862867
if (grunt.option('release')) {
@@ -924,7 +929,7 @@ module.exports = function (grunt) {
924929
versionJS = setVersionValue(
925930
versionJS,
926931
'PRERELEASE',
927-
semVersion.prerelease.length ? semVersion.prerelease[0] : 'false',
932+
semVersion.prerelease.length > 0 ? semVersion.prerelease[0] : 'false',
928933
);
929934

930935
fs.writeFileSync('./src/version.js', versionJS);

0 commit comments

Comments
 (0)