Skip to content

Commit

Permalink
fix: MT breaking CK5 editor source plugin
Browse files Browse the repository at this point in the history
Taskid 42401
  • Loading branch information
carla-at-wiris committed Jan 17, 2024
1 parent 3e1639c commit 126e833
Show file tree
Hide file tree
Showing 7 changed files with 2,615 additions and 2,300 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Last release of this project is was 20th of December 2023.

### Unreleased

- fix: MathType breaking editour source plugin. #KB-42401

### 8.8.0 2023-12-20

- fix: Froala + Generic not setting GUI parameters.
Expand Down
15 changes: 8 additions & 7 deletions demos/html/ckeditor5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"author": "WIRIS Team (http://www.wiris.com)",
"license": "MIT",
"dependencies": {
"@ckeditor/ckeditor5-alignment": ">=31.1.0",
"@ckeditor/ckeditor5-basic-styles": ">=31.1.0",
"@ckeditor/ckeditor5-dev-utils": ">=31.1.0",
"@ckeditor/ckeditor5-editor-classic": ">=31.1.0",
"@ckeditor/ckeditor5-essentials": ">=31.1.0",
"@ckeditor/ckeditor5-paragraph": ">=31.1.0",
"@ckeditor/ckeditor5-theme-lark": ">=31.1.0",
"@ckeditor/ckeditor5-alignment": "^38.0.0",
"@ckeditor/ckeditor5-basic-styles": "^38.0.0",
"@ckeditor/ckeditor5-dev-utils": "^38.0.0",
"@ckeditor/ckeditor5-editor-classic": "^38.0.0",
"@ckeditor/ckeditor5-essentials": "^38.0.0",
"@ckeditor/ckeditor5-paragraph": "^38.0.0",
"@ckeditor/ckeditor5-source-editing": "^38.0.0",
"@ckeditor/ckeditor5-theme-lark": "^38.0.0",
"@wiris/mathtype-ckeditor5": "*",
"@wiris/mathtype-html-integration-devkit": "*"
},
Expand Down
5 changes: 3 additions & 2 deletions demos/html/ckeditor5/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';
import { SourceEditing } from '@ckeditor/ckeditor5-source-editing';
import MathType from '@wiris/mathtype-ckeditor5/src/plugin';

// Load styles.
Expand All @@ -31,8 +32,8 @@ window.editor = null;
// Create the CKEditor 5.
ClassicEditor
.create(document.querySelector('#editor'), {
plugins: [Essentials, Paragraph, Bold, Italic, MathType, Alignment],
toolbar: ['bold', 'italic', 'MathType', 'ChemType', 'alignment:left', 'alignment:center', 'alignment:right'],
plugins: [Essentials, Paragraph, Bold, Italic, MathType, Alignment, SourceEditing],
toolbar: ['bold', 'italic', 'MathType', 'ChemType', 'alignment:left', 'alignment:center', 'alignment:right', 'sourceEditing'],
// language: 'de',
// mathTypeParameters: {
// editorParameters: { language: 'es' }, // MathType config, including language
Expand Down
22 changes: 11 additions & 11 deletions demos/react/ckeditor5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
"private": true,
"homepage": "./",
"dependencies": {
"@ckeditor/ckeditor5-alignment": ">=27.1.0",
"@ckeditor/ckeditor5-autoformat": ">=27.1.0",
"@ckeditor/ckeditor5-basic-styles": ">=27.1.0",
"@ckeditor/ckeditor5-build-classic": ">=27.1.0",
"@ckeditor/ckeditor5-editor-classic": ">=27.1.0",
"@ckeditor/ckeditor5-essentials": ">=27.1.0",
"@ckeditor/ckeditor5-heading": ">=27.1.0",
"@ckeditor/ckeditor5-link": ">=27.1.0",
"@ckeditor/ckeditor5-list": ">=27.1.0",
"@ckeditor/ckeditor5-paragraph": ">=27.1.0",
"@ckeditor/ckeditor5-alignment": "^38.0.0",
"@ckeditor/ckeditor5-autoformat": "^38.0.0",
"@ckeditor/ckeditor5-basic-styles": "^38.0.0",
"@ckeditor/ckeditor5-build-classic": "^38.0.0",
"@ckeditor/ckeditor5-editor-classic": "^38.0.0",
"@ckeditor/ckeditor5-essentials": "^38.0.0",
"@ckeditor/ckeditor5-heading": "^38.0.0",
"@ckeditor/ckeditor5-link": "^38.0.0",
"@ckeditor/ckeditor5-list": "^38.0.0",
"@ckeditor/ckeditor5-paragraph": "^38.0.0",
"@ckeditor/ckeditor5-react": "^2.0.0",
"@wiris/mathtype-ckeditor5": "*",
"ckeditor5": ">=27.1.0"
"ckeditor5": "^38.0.0"
},
"devDependencies": {
"cross-env": "^7.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"build": "exit 0"
},
"dependencies": {
"@ckeditor/ckeditor5-core": ">=23.0.0",
"@ckeditor/ckeditor5-engine": ">=23.0.0",
"@ckeditor/ckeditor5-ui": ">=23.0.0",
"@ckeditor/ckeditor5-widget": ">=23.0.0",
"@ckeditor/ckeditor5-core": "^38.0.0",
"@ckeditor/ckeditor5-engine": "^38.0.0",
"@ckeditor/ckeditor5-ui": "^38.0.0",
"@ckeditor/ckeditor5-widget": "^38.0.0",
"@wiris/mathtype-html-integration-devkit": "1.15.0"
}
}
6 changes: 5 additions & 1 deletion packages/ckeditor5/src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ export default class MathType extends Plugin {
const regexp = /<math(.*?)<\/math>/gm;

// Get all MathML formulas and store them in an array.
let formulas = [...data.matchAll(regexp)];
// Using the conditional operator on data.main because the data patameter has different types depeding on:
// editor.data.set can be used directly or by the source editing plugin.
// With the source editor plugin, data is an object with the key `main` wich contains the source code string.
// When using the editor.data.set method, the data is a string with the content to be set to the editor.
let formulas = Object.values(data)[0] ? [...Object.values(data)[0].matchAll(regexp)] : [...data.matchAll(regexp)];

// Loop to find LaTeX formulas and replace the MathML for the LaTeX notation.
formulas.forEach((formula) => {
Expand Down
Loading

0 comments on commit 126e833

Please sign in to comment.