Skip to content

Commit f508317

Browse files
Fix: eslint prettier (#1085)
* chore: Update ESLint ignore rules and enhance linting command * lint: Apply lint to master * fix: Linted and fixed readme
1 parent e655348 commit f508317

File tree

23 files changed

+115
-116
lines changed

23 files changed

+115
-116
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ packages/tinymce/editor_plugin.src.js
1313
packages/devkit/doc/templates/**
1414
packages/devkit/out/**
1515
packages/devkit/core.js
16+
packages/devkit/telemeter-wasm/**

.github/workflows/staging-cleanup.yml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
1514
- name: Checkout repository
1615
uses: actions/checkout@v4
1716

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Visit the [MathType integrations release notes](https://docs.wiris.com/mathtype/
6060
| [`@wiris/mathtype-generic`](packages/mathtype-generic) | <a href="https://www.npmjs.com/package/@wiris/mathtype-generic"><img src="https://img.shields.io/npm/v/@wiris/mathtype-generic"></a> | MathType Web for a generic HTML textarea. |
6161
| [`@wiris/mathtype-ckeditor4`](packages/mathtype-ckeditor4) | <a href="https://www.npmjs.com/package/@wiris/mathtype-ckeditor4"><img src="https://img.shields.io/npm/v/@wiris/mathtype-ckeditor4"></a> | MathType Web for CKEditor4 editor. |
6262
| [`@wiris/mathtype-ckeditor5`](packages/mathtype-ckeditor5) | <a href="https://www.npmjs.com/package/@wiris/mathtype-ckeditor5"><img src="https://img.shields.io/npm/v/@wiris/mathtype-ckeditor5"></a> | MathType Web for CKEditor5 editor. |
63-
| [`@wiris/mathtype-froala`](packages/mathtype-froala) | <a href="https://www.npmjs.com/package/@wiris/mathtype-froala"><img src="https://img.shields.io/npm/v/@wiris/mathtype-froala"></a> | MathType Web for Froala editor. | |
63+
| [`@wiris/mathtype-froala`](packages/mathtype-froala) | <a href="https://www.npmjs.com/package/@wiris/mathtype-froala"><img src="https://img.shields.io/npm/v/@wiris/mathtype-froala"></a> | MathType Web for Froala editor. |
6464
| [`@wiris/mathtype-tinymce5`](packages/mathtype-tinymce5) | <a href="https://www.npmjs.com/package/@wiris/mathtype-tinymce5"><img src="https://img.shields.io/npm/v/@wiris/mathtype-tinymce5"></a> | MathType Web for TinyMCE5 editor. |
6565
| [`@wiris/mathtype-tinymce6`](packages/mathtype-tinymce6) | <img src="https://img.shields.io/npm/v/@wiris/mathtype-tinymce5"> | MathType Web for TinyMCE6 editor. |
6666
| [`@wiris/mathtype-tinymce7`](packages/mathtype-tinymce7) | <img src="https://img.shields.io/npm/v/@wiris/mathtype-tinymce7"> | MathType Web for TinyMCE7 editor. |

demos/html/ckeditor4/src/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ CKEDITOR.replace("editor", {
4343
});
4444

4545
// Handle on editor ready event.
46-
CKEDITOR.on("instanceReady", function () {
46+
CKEDITOR.on("instanceReady", () => {
4747
//eslint-disable-line
4848
// Get and set the editor and wiris versions in this order.
4949
Generic.setEditorAndWirisVersion(CKEDITOR.version, WirisPlugin.currentInstance.version); //eslint-disable-line
5050
});
5151

52-
CKEDITOR.instances.editor.on("instanceReady", function (evt) {
52+
CKEDITOR.instances.editor.on("instanceReady", (evt) => {
5353
evt.editor.setData(Generic.editorContentImg);
5454
});
5555

demos/vue/ckeditor5/src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const content = Generic.editorContentMathML;
3232
const toolbar = ["bold", "italic", "link", "undo", "redo", "MathType", "ChemType", "sourceEditing"];
3333
const plugins = [Essentials, Bold, Italic, Link, Paragraph, MathType, SourceEditing];
3434
const editorConfig = {
35-
licenseKey: 'GPL',
35+
licenseKey: "GPL",
3636
iframe: true,
3737
charCounterCount: false,
3838
plugins,

docs/demos/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ The URL format for each demo is as follows: `https://integrations.wiris.kitchen/
4848

4949
The following table contains all our demos, together with links to the corresponding deployment for the branch `master`:
5050

51-
| FRAMEWORK | Editor and Version | EDITOR | Deployment URL for `master` |
52-
| --------- | ------------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
53-
| html | CKEditor V4 | [ckeditor4](../../demos/html/ckeditor4) | https://integrations.wiris.kitchen/master/html/ckeditor4/ |
54-
| html | CKEditor V5 | [ckeditor5](../../demos/html/ckeditor5) | https://integrations.wiris.kitchen/master/html/ckeditor5/ |
55-
| html | Froala | [froala](../../demos/html/froala) | https://integrations.wiris.kitchen/master/html/froala/ |
56-
| html | Generic integration | [generic](../../demos/html/generic) | https://integrations.wiris.kitchen/master/html/generic/ |
57-
| html | TinyMCE V5 | [tinymce5](../../demos/html/tinymce5) | https://integrations.wiris.kitchen/master/html/tinymce5/ |
58-
| html | TinyMCE V6 | [tinymce6](../../demos/html/tinymce6) | https://integrations.wiris.kitchen/master/html/tinymce6/ |
59-
| vue | CKEditor V5 | [ckeditor5](../../demos/vue/ckeditor5/README.md) | https://integrations.wiris.kitchen/master/vue/ckeditor5/ |
51+
| FRAMEWORK | Editor and Version | EDITOR | Deployment URL for `master` |
52+
| --------- | ------------------- | ------------------------------------------------ | --------------------------------------------------------- |
53+
| html | CKEditor V4 | [ckeditor4](../../demos/html/ckeditor4) | https://integrations.wiris.kitchen/master/html/ckeditor4/ |
54+
| html | CKEditor V5 | [ckeditor5](../../demos/html/ckeditor5) | https://integrations.wiris.kitchen/master/html/ckeditor5/ |
55+
| html | Froala | [froala](../../demos/html/froala) | https://integrations.wiris.kitchen/master/html/froala/ |
56+
| html | Generic integration | [generic](../../demos/html/generic) | https://integrations.wiris.kitchen/master/html/generic/ |
57+
| html | TinyMCE V5 | [tinymce5](../../demos/html/tinymce5) | https://integrations.wiris.kitchen/master/html/tinymce5/ |
58+
| html | TinyMCE V6 | [tinymce6](../../demos/html/tinymce6) | https://integrations.wiris.kitchen/master/html/tinymce6/ |
59+
| vue | CKEditor V5 | [ckeditor5](../../demos/vue/ckeditor5/README.md) | https://integrations.wiris.kitchen/master/vue/ckeditor5/ |
6060

6161
## Running a demo using the local source code
6262

docs/development/demos/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ $ nx start <FRAMEWORK>-<EDITOR>
3939

4040
> In case you haven't installed `nx`, you'll have to add `yarn` at the beginning of each one of the previous commands.
4141
42-
| FRAMEWORK | Editor and Version | EDITOR/PACKAGE |
43-
| --------- | ------------------- | ---------------------------------------------------- |
44-
| html | CKEditor V4 | [ckeditor4](../../demos/html/ckeditor4) |
45-
| html | CKEditor V5 | [ckeditor5](../../demos/html/ckeditor5) |
46-
| html | Froala | [froala](../../demos/html/froala) |
47-
| html | Generic integration | [generic](../../demos/html/generic) |
48-
| html | TinyMCE V5 | [tinymce5](../../demos/html/tinymce5) |
49-
| html | TinyMCE V6 | [tinymce6](../../demos/html/tinymce6) |
50-
| vue | CKEditor V5 | [ckeditor5](../../demos/vue/ckeditor5/README.md) |
42+
| FRAMEWORK | Editor and Version | EDITOR/PACKAGE |
43+
| --------- | ------------------- | ------------------------------------------------ |
44+
| html | CKEditor V4 | [ckeditor4](../../demos/html/ckeditor4) |
45+
| html | CKEditor V5 | [ckeditor5](../../demos/html/ckeditor5) |
46+
| html | Froala | [froala](../../demos/html/froala) |
47+
| html | Generic integration | [generic](../../demos/html/generic) |
48+
| html | TinyMCE V5 | [tinymce5](../../demos/html/tinymce5) |
49+
| html | TinyMCE V6 | [tinymce6](../../demos/html/tinymce6) |
50+
| vue | CKEditor V5 | [ckeditor5](../../demos/vue/ckeditor5/README.md) |
5151

5252
Each time you apply a change to a package and want to see the changes in your demo, you'll have to re-run the previous two commands.
5353

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "nx run-many --target=test --all --parallel",
1313
"test:ci": "docker run -v $PWD:/cypress --net=host -w /cypress -e CYPRESS_PROJECT_ID --entrypoint=cypress cypress/included:7.5.0 run --project .",
1414
"build": "cd demos/html/generic && npm install && npm start &",
15-
"lint": "prettier --write . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .eslintignore && nx run-many --target=lint --all --parallel"
15+
"lint": "prettier --write . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .eslintignore && nx run-many --target=lint --all --parallel --fix"
1616
},
1717
"devDependencies": {
1818
"@babel/eslint-parser": "^7.24.1",
@@ -32,7 +32,9 @@
3232
"eslint-plugin-jsdoc": "^48.2.3",
3333
"html-validate": "^8.18.1",
3434
"nx": "18.2.2",
35-
"prettier": "3.2.5",
35+
"eslint-config-prettier": "^10.0.1",
36+
"eslint-plugin-prettier": "^5.2.3",
37+
"prettier": "3.5.2",
3638
"typescript": "~5.4.4"
3739
},
3840
"license": "MIT",

packages/ckeditor4/plugin.src.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export class CKEditor4Integration extends IntegrationModel {
380380
});
381381

382382
// Parse the editor content after copy & paste / drag & drop
383-
editor.on("afterPaste", function (event) {
383+
editor.on("afterPaste", (event) => {
384384
editor.setData(Parser.initParse(editor.getData()));
385385
});
386386
},

packages/ckeditor5/src/integration.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -256,20 +256,19 @@ export default class CKEditor5Integration extends IntegrationModel {
256256
// When Latex is next to image/formula.
257257
if (latexRange.startContainer.nodeType === 3 && latexRange.startContainer.previousSibling?.nodeType === 1) {
258258
// Get the position of the latex to be replaced.
259-
let latexEdited =
260-
"$$" +
261-
Latex.getLatexFromMathML(MathML.safeXmlDecode(this.core.editionProperties.temporalImage.dataset.mathml)) +
262-
"$$";
259+
const latexEdited = `$$${Latex.getLatexFromMathML(
260+
MathML.safeXmlDecode(this.core.editionProperties.temporalImage.dataset.mathml),
261+
)}$$`;
263262
let data = latexRange.startContainer.data;
264263

265264
// Remove invisible characters.
266265
data = data.replaceAll(String.fromCharCode(8288), "");
267266

268267
// Get to the start of the latex we are editing.
269-
let offset = data.indexOf(latexEdited);
270-
let dataOffset = data.substring(offset);
271-
let second$ = dataOffset.substring(2).indexOf("$$") + 4;
272-
let substring = dataOffset.substr(0, second$);
268+
const offset = data.indexOf(latexEdited);
269+
const dataOffset = data.substring(offset);
270+
const second$ = dataOffset.substring(2).indexOf("$$") + 4;
271+
const substring = dataOffset.substr(0, second$);
273272
data = data.replace(substring, "");
274273

275274
if (!data) {
@@ -301,7 +300,7 @@ export default class CKEditor5Integration extends IntegrationModel {
301300
}
302301

303302
// Build the telemeter payload separated to delete null/undefined entries.
304-
let payload = {
303+
const payload = {
305304
mathml_origin: mathmlOrigin ? MathML.safeXmlDecode(mathmlOrigin) : mathmlOrigin,
306305
mathml: mathml ? MathML.safeXmlDecode(mathml) : mathml,
307306
elapsed_time: Date.now() - this.core.editionProperties.editionStartTime,

packages/ckeditor5/src/plugin.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export default class MathType extends Plugin {
315315
}
316316

317317
const mathAttributes = [...viewItem.getAttributes()].map(([key, value]) => ` ${key}="${value}"`).join("");
318-
let htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
318+
const htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
319319

320320
const modelNode = writer.createElement("mathml", { htmlContent });
321321

@@ -463,7 +463,7 @@ export default class MathType extends Plugin {
463463
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
464464

465465
// Load img element
466-
let mathString =
466+
const mathString =
467467
modelItem.getAttribute("htmlContent") || Parser.endParseSaveMode(modelItem.getAttribute("formula"));
468468

469469
const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
@@ -486,7 +486,7 @@ export default class MathType extends Plugin {
486486
editor.data.on(
487487
"get",
488488
(e) => {
489-
let output = e.return;
489+
const output = e.return;
490490
const parsedResult = Parser.endParse(output);
491491

492492
// Cleans all the semantics tag for safexml
@@ -518,14 +518,14 @@ export default class MathType extends Plugin {
518518
formulas.forEach((formula) => {
519519
if (formula.includes('encoding="LaTeX"')) {
520520
// LaTeX found.
521-
let latex = "$$$" + Latex.getLatexFromMathML(formula) + "$$$"; // We add $$$ instead of $$ because the replace function ignores one $.
521+
const latex = `$$$${Latex.getLatexFromMathML(formula)}$$$`; // We add $$$ instead of $$ because the replace function ignores one $.
522522
modifiedData = modifiedData.replace(formula, latex);
523523
} else if (formula.includes("<img")) {
524524
// If we found a formula image, we should find MathML data, and then substitute the entire image.
525525
const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
526526
const safexml = formula.match(regexp);
527527
if (safexml !== null) {
528-
let decodeXML = MathML.safeXmlDecode(safexml[0]);
528+
const decodeXML = MathML.safeXmlDecode(safexml[0]);
529529
modifiedData = modifiedData.replace(formula, decodeXML);
530530
}
531531
}

packages/devkit/src/contentmanager.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ export default class ContentManager {
468468
} else {
469469
this.setMathML(this.mathML);
470470
}
471-
let toolbar = this.updateToolbar();
471+
const toolbar = this.updateToolbar();
472472
this.onFocus();
473473

474474
if (this.deviceProperties.isIOS) {
@@ -480,13 +480,13 @@ export default class ContentManager {
480480
}
481481
}
482482

483-
let trigger = this.dbclick ? "formula" : "button";
483+
const trigger = this.dbclick ? "formula" : "button";
484484

485485
// Call Telemetry service to track the event.
486486
try {
487487
Telemeter.telemeter.track("OPENED_MTCT_EDITOR", {
488-
toolbar: toolbar,
489-
trigger: trigger,
488+
toolbar,
489+
trigger,
490490
});
491491
} catch (error) {
492492
console.error("Error tracking OPENED_MTCT_EDITOR", error);
@@ -722,14 +722,12 @@ export default class ContentManager {
722722
this.modalDialogInstance.closeDiv.focus();
723723
keyboardEvent.stopPropagation();
724724
keyboardEvent.preventDefault();
725-
} else {
726-
if (document.activeElement === this.modalDialogInstance.minimizeDiv) {
727-
// Focus on cancel button.
728-
if (!(this.modalDialogInstance.properties.state === "minimized")) {
729-
this.modalDialogInstance.cancelButton.focus();
730-
keyboardEvent.stopPropagation();
731-
keyboardEvent.preventDefault();
732-
}
725+
} else if (document.activeElement === this.modalDialogInstance.minimizeDiv) {
726+
// Focus on cancel button.
727+
if (!(this.modalDialogInstance.properties.state === "minimized")) {
728+
this.modalDialogInstance.cancelButton.focus();
729+
keyboardEvent.stopPropagation();
730+
keyboardEvent.preventDefault();
733731
}
734732
}
735733
} else if (keyboardEvent.key === "Tab") {

packages/devkit/src/core.src.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export default class Core {
550550

551551
// Build the telemeter payload separated to delete null/undefined entries.
552552
const mathml = element?.dataset?.mathml;
553-
let payload = {
553+
const payload = {
554554
mathml_origin: mathmlOrigin ? MathML.safeXmlDecode(mathmlOrigin) : mathmlOrigin,
555555
mathml: mathml ? MathML.safeXmlDecode(mathml) : mathml,
556556
elapsed_time: Date.now() - this.editionProperties.editionStartTime,

packages/devkit/src/image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export default class Image {
194194
processImg(img);
195195
// if it does contain a blob, then read that, replace the src with the decoded content, and process it
196196
} else {
197-
let reader = new FileReader();
197+
const reader = new FileReader();
198198
reader.onload = function () {
199199
img.setAttribute("src", reader.result);
200200
processImg(img);

0 commit comments

Comments
 (0)