GithubHelp home page GithubHelp logo

isaul32 / ckeditor5-math Goto Github PK

View Code? Open in Web Editor NEW
72.0 5.0 36.0 1005 KB

Math feature for CKEditor 5.

Home Page: https://www.npmjs.com/package/ckeditor5-math

License: ISC License

JavaScript 31.58% CSS 0.78% TypeScript 67.64%
ckeditor ckeditor5 ckeditor5-math katex mathjax tex latex hacktoberfest

ckeditor5-math's Introduction

CKEditor 5 mathematical feature · GitHub license npm version

ckeditor5-math is a TeX-based mathematical plugin for CKEditor 5. You can use it to insert, edit, and view mathematical equations and formulas. This plugin supports MathJax, KaTeX and custom typesetting engines.

Table of contents

Features

  • Written in TypeScript (as of v41.2.1)
  • DLL build support (as of v36.0.3)
  • TeX syntax
  • Inline and display equations
  • Preview view
  • Multiple typesetting engines
  • Have multiple input and output format
  • Paste support
    • from plain text
  • Autoformat support

Demos

Screenshots

Screenshot 1

Screenshot 2

Requirements

  • Use same major version as your CKEditor 5 build

If you get duplicated modules error, you have mismatching versions.

Examples

Link to examples repository

Installation

Use official classic or inline build as a base:

Install plugin with NPM or Yarn

npm install @isaul32/ckeditor5-math --save-dev

yarn add @isaul32/ckeditor5-math --dev

Add import into ckeditor.js file

import Math from '@isaul32/ckeditor5-math/src/math';
import AutoformatMath from '@isaul32/ckeditor5-math/src/autoformatmath';

Add it to built-in plugins

InlineEditor.builtinPlugins = [
	// ...
	Math,
	AutoformatMath
];

Add math button to toolbar

InlineEditor.defaultConfig = {
	toolbar: {
		items: [
			// ...
			'math'
		]
	}
};

Styles for Lark theme

Copy theme/ckeditor5-math folder from https://github.com/isaul32/ckeditor5/tree/master/packages/ckeditor5-theme-lark to your lark theme repository

Using DLL builds

Use the official DLL build and additionally load the math plugin:

<script src="path/to/node_modules/@isaul32/ckeditor5-math/build/math.js"></script>
<script>
CKEditor5.editorClassic.ClassicEditor
	.create(editorElement, {
		plugins: [
			CKEditor5.math.Math,
			...
		],
		...
	});
</script>

Configuration & Usage

Plugin options

InlineEditor.defaultConfig = {
	// ...
	math: {
		engine: 'mathjax', // or katex or function. E.g. (equation, element, display) => { ... }
		lazyLoad: undefined, // async () => { ... }, called once before rendering first equation if engine doesn't exist. After resolving promise, plugin renders equations.
		outputType: 'script', // or span
		className: 'math-tex', // class name to use with span output type, change e.g. MathJax processClass (v2) / processHtmlClass (v3) is set
		forceOutputType: false, // forces output to use outputType
		enablePreview: true, // Enable preview view
		previewClassName: [], // Class names to add to previews
		popupClassName: [], // Class names to add to math popup balloon
		katexRenderOptions: {}  // KaTeX only options for katex.render(ToString)
	}
}

Available typesetting engines

MathJax

  • Tested with latest 2.7
  • Has experimental (CHTML, SVG) support for 3.0.0 or newer version

KaTeX

KaTeX

  • Tested with version 0.12.0

KaTeX

  • katexRenderOptions - pass options.

    InlineEditor.defaultConfig = {
    	// ...
    	math: {
    		engine: 'katex'
    		katexRenderOptions: {
    			macros: {
    				"\\neq": "\\mathrel{\\char`≠}",
    			},
    		},
    	}
    }

Custom typesetting

Custom typesetting is possible to implement with engine config. For example, custom typesetting feature can be used when use back end rendering.

InlineEditor.defaultConfig = {
	// ...
	math: {
		engine: ( equation, element, display, preview ) => {
			// ...
		}
	}
}
  • equation is equation in TeX format without delimiters.
  • element is DOM element reserved for rendering.
  • display is boolean. Typesetting should be inline when false.
  • preview is boolean. Rendering in preview when true.

Supported input and output formats

Supported input and output formats are:

<!-- MathJax style http://docs.mathjax.org/en/v2.7-latest/advanced/model.html#how-mathematics-is-stored-in-the-page -->
<script type="math/tex">\sqrt{\frac{a}{b}}</script>
<script type="math/tex; mode=display">\sqrt{\frac{a}{b}}</script>

<!-- CKEditor 4 style https://ckeditor.com/docs/ckeditor4/latest/features/mathjax.html -->
<span class="math-tex">\( \sqrt{\frac{a}{b}} \)</span>
<span class="math-tex">\[ \sqrt{\frac{a}{b}} \]</span>

Paste support

From plain text

Paste TeX equations with delimiters. For example:

\[ x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} \]

or

\( x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} \)

Autoformat support

Inline mode

Ctrl+M can be used to add easily math formulas in inline mode.

Display mode

Autoformat for math can be used to add formula in display mode on a new line by adding \[ or $$. This feature requires additional autoformat plugin to be added.

Add following lines into your build

// ...
import AutoformatMath from '@isaul32/ckeditor5-math/src/autoformatmath';

InlineEditor.builtinPlugins = [
	// ...
	AutoformatMath
];

or use it with DLL build

<script src="path/to/node_modules/@isaul32/ckeditor5-math/build/math.js"></script>
<script>
CKEditor5.editorInline.InlineEditorEditor
	.create(editorElement, {
		plugins: [
			CKEditor5.math.AutoformatMath,
			...
		],
		...
	});
</script>

Preview workaround

.ck-reset_all * css rules from ckeditor5-ui and ckeditor5-theme-lark break rendering in preview mode.

My solution for this is use rendering element outside of CKEditor DOM and place it to right place by using absolute position. Alternative solution could be using iframe, but then typesetting engine's scripts and styles have to copy to child document.

Development

Contributions, improvements and bug fixes are welcome. To aid in this, try out our developer environment w/ live reload support and CKEditor 5 inspector.

Development environment

To enter a development loop with hot reload support:

  • git clone https://github.com/isaul32/ckeditor5-math.git
  • cd ckeditor5-math
  • yarn
  • yarn start
  • http://localhost:8080

ckeditor5-math's People

Contributors

danielkulbe avatar isaul32 avatar jules-bertholet avatar marcellofuschi avatar tony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ckeditor5-math's Issues

Make a Build

In many cases we need dll builds to add plugins. As mentioned in official website. Also having a dll build, we can use it in different packages.

Would you please provide a dll build of this plugin? Or guide me how I can build one?

Add a default `className`

In a custom build, if no math is declared in configuration:

fileupload.html:80 There was a problem initializing the editor. TypeError: Cannot read properties of undefined (reading 'className')
    at mx._defineConverters (mathediting.js:99:28)
    at mx.init (mathediting.js:20:8)

Moving the editor.config.define from init() to constructor( fixes it

Accessibility of edit button in balloon editor

Hello, I use "balloon" editor in my app instead of the classic toolbar.

There's a problem that if I choose alternative display style (block style instead of inline), then I can't re-edit the math formula.

You can see the problem on this clip:

Also it seems a little bit unintuitive that I need to click on the f(x) button to be able to edit the formula. Wouldn't simple click (or perhaps double click) on the rendered formula be better way to show the edit dialog?

Compare with how this works in ckeditor for normal links (click triggers dialog):

Copying formulas copies text, rather than object / element

Example (+ drag and drop issue with #34)

00:00 - 00:14:

2021-05-04.09-08-33.-.ckeditor5-math.PR.34.35.-.with.PR.mp4

Possibly relevant / fixable with #34

We speak about autoformat and pasting in the README, but we strip \ from equations on pasting, so those aren't copyable.

Reproducible on the demos: https://jsfiddle.net/isaul32/qktj9h7x/, https://jsfiddle.net/isaul32/3wjrkLdv/, https://jsfiddle.net/isaul32/q01mu8kp/

Recreation steps

  • git clone https://github.com/isaul32/ckeditor5-math.git
  • cd ckeditor5-math
  • yarn
  • yarn start
  • http://localhost:8080
  • Copy a formula
  • Paste formula: It pastes as text

creating extra content to the model

good morning, i do have a problem in adding multiple elements to mathjax pop-up as it doesn't have enough space and i can't really understand the work flow and i cannot debug as well as me not being good in java script I cloned the package and add it locally to my ckeditor file and imported it i also changed few things in mainformview.js and here's my mainformview.js right now
`import View from '@ckeditor/ckeditor5-ui/src/view';
import ViewCollection from '@ckeditor/ckeditor5-ui/src/viewcollection';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
import SwitchButtonView from '@ckeditor/ckeditor5-ui/src/button/switchbuttonview';
import LabeledInputView from '@ckeditor/ckeditor5-ui/src/labeledinput/labeledinputview';
import InputTextView from '@ckeditor/ckeditor5-ui/src/inputtext/inputtextview';
import LabelView from '@ckeditor/ckeditor5-ui/src/label/labelview';
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
import FocusCycler from '@ckeditor/ckeditor5-ui/src/focuscycler';
import checkIcon from '@ckeditor/ckeditor5-core/theme/icons/check.svg';
import cancelIcon from '@ckeditor/ckeditor5-core/theme/icons/cancel.svg';
import multiply from './math-svg/multiply.svg';
import root from './math-svg/root.svg';
import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler';

import { extractDelimiters, hasDelimiters } from '../utils';
import MathView from './mathview';
import '../../theme/mathform.css';

export default class MainFormView extends View {
constructor( locale, engine, lazyLoad, previewEnabled, previewUid, previewClassName, popupClassName ) {
super( locale );

	const t = locale.t;

	// Create key event & focus trackers
	this._createKeyAndFocusTrackers();

	// Submit button
	this.saveButtonView = this._createButton( t( 'Save' ), checkIcon, 'ck-button-save', null );
	this.saveButtonView.type = 'submit';
	this.rootButtonView = this._createButton( t( 'root' ), root, 'mathjaxbuttons', null );
	this.rootButtonView.type = 'root';
	//this.multiplyButtonView = this._createButton( t( 'multiply' ), multiply, 'mathjaxbuttons', null );
	//this.mutliplyButtonView.type = 'multiply';
	// Math buttons
	this.bigmathButtonView = this._createFlatButton( t( 'Maths' ), 'mathjaxbuttons button button 1', null );
	this.bigmathButtonView.type = 'maths';
	this.gkButtonView = this._createFlatButton( t( 'GK&Fun' ), 'mathjaxbuttons button button 1', null );
	this.gkButtonView.type = 'Gk@Fun';
	this.logicButtonView = this._createFlatButton( t( 'Logic' ), 'mathjaxbuttons button button 1', null );
	this.logicButtonView.type = 'logic';
	this.arrowButtonView = this._createFlatButton( t( 'Arrow' ), 'mathjaxbuttons button button 1', null );
	this.arrowButtonView.type = 'arrow';
	this.symbolButtonView = this._createFlatButton( t( 'Symbol' ), 'mathjaxbuttons button button 1', null );
	this.symbolButtonView.type = 'sybmol';
	this.formatButtonView = this._createFlatButton( t( 'Format' ), 'mathjaxbuttons button button 1', null );
	this.formatButtonView.type = 'format';
	// Equation input
	this.mathInputView = this._createMathInput();

	// Display button
	this.displayButtonView = this._createDisplayButton();

	// Cancel button
	this.cancelButtonView = this._createButton( t( 'Cancel' ), cancelIcon, 'ck-button-cancel', 'cancel' );
	this.previewEnabled = previewEnabled;

	let children = [];
	if ( this.previewEnabled ) {
		// Preview label
		this.previewLabel = new LabelView( locale );
		this.previewLabel.text = t( 'Equation preview' );

		// Math element
		this.mathView = new MathView( engine, lazyLoad, locale, previewUid, previewClassName );
		children = [
			this.mathInputView,
			this.bigmathButtonView,
			this.gkButtonView,
			this.logicButtonView,
			this.arrowButtonView,
			this.symbolButtonView,
			this.formatButtonView,
			this.rootButtonView,
		//	this.multiplyButtonView,
		//	this.displayButtonView,
			this.previewLabel,
			this.mathView
		];
	} else {
		children = [
			this.mathInputView,
			this.bigmathButtonView,
			this.gkButtonView,
			this.logicButtonView,
			this.arrowButtonView,
			this.symbolButtonView,
			this.formatButtonView,
			this.rootButtonView,
		//	this.multiplyButtonView
		//	this.displayButtonView
		];
	}

	// Add UI elements to template
	this.setTemplate( {
		tag: 'form',
		attributes: {
			class: [
				'ck',
				'ck-math-form',
				...popupClassName
			],
			tabindex: '-1',
			spellcheck: 'false'
		},
		children: [
			{
				tag: 'div',
				attributes: {
					class: [
						'ck-math-view'
					]
				},
				children
			},
			this.saveButtonView,
			this.cancelButtonView
		]
	} );
}

render() {
	super.render();

	// Prevent default form submit event & trigger custom 'submit'
	submitHandler( {
		view: this
	} );

	// Register form elements to focusable elements
	const childViews = [
		this.mathInputView,
		this.saveButtonView,
		this.cancelButtonView
	];

	childViews.forEach( v => {
		this._focusables.add( v );
		this.focusTracker.add( v.element );
	} );

	// Listen to keypresses inside form element
	this.keystrokes.listenTo( this.element );
}

focus() {
	this._focusCycler.focusFirst();
}

get equation() {
	return this.mathInputView.inputView.element.value;
}

set equation( equation ) {
	this.mathInputView.inputView.element.value = equation;
	if ( this.previewEnabled ) {
		this.mathView.value = equation;
	}
}

_createKeyAndFocusTrackers() {
	this.focusTracker = new FocusTracker();
	this.keystrokes = new KeystrokeHandler();
	this._focusables = new ViewCollection();

	this._focusCycler = new FocusCycler( {
		focusables: this._focusables,
		focusTracker: this.focusTracker,
		keystrokeHandler: this.keystrokes,
		actions: {
			focusPrevious: 'shift + tab',
			focusNext: 'tab'
		}
	} );
}

_createMathInput() {
	const t = this.locale.t;

	// Create equation input
	const mathInput = new LabeledInputView( this.locale, InputTextView );
	const inputView = mathInput.inputView;
	mathInput.infoText = t( 'Insert equation in TeX format.' );

	const onInput = () => {
		if ( inputView.element != null ) {
			let equationInput = inputView.element.value.trim();

			// If input has delimiters
			if ( hasDelimiters( equationInput ) ) {
				// Get equation without delimiters
				const params = extractDelimiters( equationInput );

				// Remove delimiters from input field
				inputView.element.value = params.equation;

				equationInput = params.equation;

				// update display button and preview
				this.displayButtonView.isOn = params.display;
			}
			if ( this.previewEnabled ) {
				// Update preview view
				this.mathView.value = equationInput;
			}

			this.saveButtonView.isEnabled = !!equationInput;
		}
	};

	inputView.on( 'render', onInput );
	inputView.on( 'input', onInput );

	return mathInput;
}

_createButton( label, icon, className, eventName ) {
	const button = new ButtonView( this.locale );

	button.set( {
		label,
		icon,
		tooltip: true
	} );

	button.extendTemplate( {
		attributes: {
			class: className
		}
	} );

	if ( eventName ) {
		button.delegate( 'execute' ).to( this, eventName );
	}

	return button;
}
_createformulaButton( label, icon, className, eventName ) {
	const button = new ButtonView(this.locale );

	button.set( {
		label,
		icon,
		tooltip: true
	} );

	button.extendTemplate( {
		attributes: {
			class: className
		}
	} );

	if ( eventName ) {
		button.delegate( 'execute' ).to( this, eventName );
	}
	if ( eventName ) {
		button.delegate( 'execute' ).to( this, eventName );
	}
	button.on( 'execute', () => {
	
		//this.mathInputView.equationInput='\\sqrt{ab}';
	} );

	return button;
}
_createFlatButton( label, className, eventName) {
	const button = new ButtonView( this.locale );

	button.set( {
		label,
		withText: true,
		tooltip: true,
		
	} );

	button.extendTemplate( {
		attributes: {
			class: className
		}
	} );

	if ( eventName ) {
		button.delegate( 'execute' ).to( this, eventName );
	}
	button.on( 'execute', () => {
	
		console.log('button pressed!');
	} );
	return button;
}


_createDisplayButton() {
	const t = this.locale.t;

	const switchButton = new SwitchButtonView( this.locale );

	switchButton.set( {
		label: t( 'Display mode' ),
		withText: true
	} );

	switchButton.extendTemplate( {
		attributes: {
			class: 'ck-button-display-toggle'
		}
	} );

	switchButton.on( 'execute', () => {
		// Toggle state
		switchButton.isOn = !switchButton.isOn;

		if ( this.previewEnabled ) {
			// Update preview view
			this.mathView.display = switchButton.isOn;
		}
	} );

	return switchButton;
}

}
`
and here's the existing UI
1
and here's the UI that I want to achieve
1-Recovered
can someone help me to do so here's my questions
how can i exactly put the category buttons (maths, gk&fun, logic, arrows, symbols, format) in a standalone div to work as one pressing anyone should display those icon buttons in which each category button should display different icon buttons group ?
and on pressing any of the icon buttons it should concatenate the added string into the textfield ?
i'm really confused it might be a trevial issue but i'd appreciate anyone's help
thank you so much.

Allow passing render options for KaTeX

Workaround for #2109 issue:

New option: katexRenderOptions, optional

	math: {
		engine: "katex",
		katexRenderOptions: {
			macros: {
				"\\neq": "\\mathrel{\\char`≠}",
			},
		},
	},

Case: pass render options

re: workaround using macros:

katex.render(
  text,
  element,
  {
    macros: {
      '\\neq': '\\mathrel{\\char`≠}',
    },
  },
)

Math vs. placeholder in block mode

Hi, when there's no other content other than math block then this happens:

I suspect the problem is that CKEditor considers math block as empty content and therefore displays also placeholder ...

CKEDITOR5 V25.0.0 support?

I was update to ckeditor5 v25.0.0.
and then math editor not working.
is it support ckeditor5 V25.0.0?
and any plan support?

Publish latest versions in npm

Hi.

Looking at ckeditor5-math releases here in github it seems that the latest is 39.0.1. However that can't be installed via npm. The latest version available there is 36.0.2. Would it be possible to publish the missing versions to npm? I'd need a version compatible with ckeditor5 39.x. and I understood that ckeditor5-math's version should match that of ckeditor5.

Autoformat for math

Hi, CKEditor 5 has markdown-like auto formatting - e.g. when you start typing ### on a new line, it will turn the line into a H3.

It might be pretty cool to have something like also for math. With this you could avoid opening 

I know this wouldn't be a quick/easy feature, but it would be interesting to at least hear what you think ...

Indent not working, missing alignment and insert image url

Hi,
Firstly I really appreciate your effort for making this editor. It helps me a lot in my works.
But I recognize that some functions which is missing or don't work well such as indent, alignment or insert image from url.
Could you spend your time to taking a look at these issues?
Thank a lot.

duplicated modules

Hi,
I've tried to build the plugin today according to http://npm.taobao.org/package/ckeditor5-math#screenshots

However, the editor does not run at all, the error is
CKEditorError: ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated.

If I comment out the ckeditor5-math entries, the editor runs normally.

Could you please help me with that?
My environment: npm 6.13.4, yarn 1.22.0, on Ubuntu 18.04

How to test?

At the moment, the instructions at ec03d72 don't work

$ node node_modules/@ckeditor/ckeditor5-dev-tests/bin/test.js
⚠ You're running tests in dev mode - some error protections are loose. Use the `--production` flag to use strictest verification methods.
02 05 2021 11:26:38.277:WARN [config]: Pattern "/" does not match any file.
Error: Not found files to tests. Specified patterns are invalid.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

option for localization and custom popup

Hi, i want to say thank you for your project, it help me a lot when working with latex in Ckeditor5. Also i want to know if there are any option for localization or customize popup, i want to change language from English to Vietnamese. Thank you.
image

How to use this in the Vue application?

I like this math plugin for ckeditor5,but I don't know how to use it in the Vue application.
Installed this plugin according to the ckeditor5 document,show this error "ckeditor.js:5 math-tex-typesetting-missing: Missing the mathematical typesetting engine (katex) for tex".

Thanks!

renderEquation is receiving wrongs params from package itself

renderEquation is defined as

export async function renderEquation(
equation, element, engine = 'katex', lazyLoad, display = false, preview = false, previewUid, previewClassName = [],
katexRenderOptions = {}
so the 7th parameter should be a string that matches an id in the document and the 8th is an array of string for the class.

Problem is in mathediting where renderEquation is using the array of class as the 7th parameter.

renderEquation( equation, domElement, mathConfig.engine, mathConfig.lazyLoad, display, false, mathConfig.previewClassName,

Is this expected or is it a bug? I'm currently doing the migration to Typescript

Input panel overflows from editor

image

The input panel will overflow from the editor on the bottom, which can cause issues if the editor is near to the bottom of the screen or is surrounded by higher z-index elements.

image

Duplicated modules

Hello, looks fantastic your plugin, but I'm getting the following error when addin it to my build:

version.js:152 Uncaught CKEditorError: ckeditor-duplicated-modules
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-ckeditor-duplicated-modules
    at version.js:152:11
    at ckeditor.js:6:2002156
    at universalModuleDefinition:11:1
    at universalModuleDefinition:9:37
    at universalModuleDefinition:1:1

All I did was to add your plugin. Thanks!

Pressing spacebar before a formula deletes the rest of the lile

Hi,
I observe a problem with the math module. If I place cursor just in front of a formula and press the space bar, the formula and everything after it is deleted till the end of the line

How to test:
Start any of the jffiddle.net demos
Place the cursor after the "Lorem.." text (either directly after the last dot or directly in front of the formula)
Hit the space bar. The formula and the text after the cursor vanish (both in inline and display modes)

Edit window too small

LaTeX formulas can get really large and often require multiple lines. However, the editing field in the popup widget is very small. Would it be possible to make it multiline and to add it a possibility to change the popup size?
Thanks!

Lazy loading of the rendering engine

Hi, first of all, thank you for this project. I'm pretty sure a lot of people have been waiting for this!

I do have a question / feature request.

This module can be configured with engine like katex, but its loading is left up to the app developer - ckeditor5-math just expects it to be there. This is not difficult to handle - app can just load katex on its own.

However, think of a use case where an app uses CKEditor and the math is used only in some specific content, so the user edits math and needs this module only from time to time. But with current approach the katex (pretty large library) must be loaded even if there's no need for it currently.

So what I propose is some sort of lazy loading mechanism where this module would detect the math usage on the page (or when user clicks on the toolbar) in the currently edited content so the module would call some (promise returning) callback which would then lazy load Katex.

What do you think?

Move to `ckeditor5-package-tools`

@ckeditor/ckeditor5-package-tools

This gives us:

  • test – prepares an entry file and passes it to the karma test runner,
  • start – prepares the development server with the live-reloading mechanism,
  • dll:build – prepares a file compatible with CKEditor 5 DLL that exposes plugins from the package,
  • translations:collect – collects translations context and prepares them to be sent to Transifex,
  • translations:upload – uploads collected contexts to Transifex,
  • translations:download – downloads translated contexts from Transifex.

Formula disappears when it is the only element in the CKEditor and is saved.

The formula disappears when it is the only element in the CKEditor and is saved. Checking the value in the database, if it remains saved with the tag 'Script', but when it does not render it.

When you insert text first, or a line break, and then the formula, it is already possible to insert formulas without them disappearing.

I am using CKEditor 5 for React (V28.0.0).

I'm not sure if inserting a line break before rendering the formula or a 'p' 'span' or something like that when executing the writer.createContainerElement can solve the problem.

Error on installing the package after customizing/building it

Hi,

I've tried to add a manual link to the popup and build the package again. I didn't have any problem with building it but since I use CkEditor Custom Build, after adding it to the project I'm getting below error on npm install. Does anyone know what could be the problem?

npm ERR! code 1
npm ERR! path /var/www/html/packages/ckeditor5-math
npm ERR! command failed
npm ERR! command sh -c yarn run dll:build
npm ERR! yarn run v1.22.19
npm ERR! $ ckeditor5-package-tools dll:build
npm ERR! info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! node:internal/modules/cjs/loader:1080
npm ERR!   throw err;
npm ERR!   ^
npm ERR! 
npm ERR! Error: Cannot find module '/var/www/html/packages/ckeditor5-math/node_modules/ckeditor5/build/ckeditor5-dll.manifest.json'
npm ERR! Require stack:
npm ERR! - /var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/utils/get-webpack-config-dll.js
npm ERR! - /var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/tasks/dll-build.js
npm ERR! - /var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/index.js
npm ERR! - /var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/bin/index.js
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:922:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1143:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:110:18)
npm ERR!     at module.exports (/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/utils/get-webpack-config-dll.js:38:14)
npm ERR!     at module.exports (/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/tasks/dll-build.js:12:24)
npm ERR!     at dll:build (/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/index.js:18:45)
npm ERR!     at Object.<anonymous> (/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/bin/index.js:18:32)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1256:14)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/utils/get-webpack-config-dll.js',
npm ERR!     '/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/tasks/dll-build.js',
npm ERR!     '/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/lib/index.js',
npm ERR!     '/var/www/html/node_modules/@ckeditor/ckeditor5-package-tools/bin/index.js'
npm ERR!   ]
npm ERR! }
npm ERR! 
npm ERR! Node.js v18.17.0
npm ERR! error Command failed with exit code 1.

BWT, I the ckeditor5-dll.manifest.json file exists in the path.

Support for Markdown Output

Hi, So we are currently using ckedito5 version 31.0.0 and our output is Markdown. Unfortunately ckeditor5-math does not have any support for markdown. I was wondering if that could be added.

Math edit position problem.

Math edit position is wrong.
(X position is minus)
That problem was occurred current edge, chrome, safari web browser.
Please check attached screen shot.
Screen Shot 2021-01-23 at 9 02 47 PM

Not working in vue.js

My package.json :

"@ckeditor/ckeditor5-build-classic": "^24.0.0",
"ckeditor5-math": "^24.0.0"

My vue.js file :


import CKEditor from '@ckeditor/ckeditor5-vue2';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import Mathematics from 'ckeditor5-math/src/math';

  data() {
        return {
            editor: ClassicEditor,
            editorData: '<p>Content of the editor.</p>',
            editorConfig: {
                // The configuration of the editor.
                     toolbar: [items: [
                          'math'
		     ] ],
                    plugins: [ Mathematics]
            }
        };
    }

the Error :

Uncaught (in promise) CKEditorError: ckeditor-duplicated-modules

I have modified both versions , with no luck

Huge portions of text being deleted when typing something after a math expression.

Hey, I've been having this problem for a few months but still have not found out what is causing it. It happens constantly though.
image
This line for example, after typing any character at the end turns into
image
I've been working around this by inserting a dot at the end of the line and typing my texts before the dot. But even then sometimes I get unexpected behavior that is similar to this, such as the inability to delete characters using backspace.
I can reproduce this problem every time using this string

The frontier of a set 

(X \subseteq \R^2)

 is the set 

(Y)

 of all points 

(y \in \R^2)

 such that every neighborhood of 

(y)

 meets both 

(X)

 and 

(\R^2 \setminus X)

. Note that if 

(X)

The formatting is off, but I just copied directly from the editor.

Custom Build duplicated modules error

Hello,

I've followed the steps to install ckeditor5-math, using v24 of CKEDitor 5 and v24 of ckeditor5-math.

The build worked fine and I got it in my forked repository.
However, when installing that branch and then trying to use this custom build in my react application, I get the duplicated modules error.

Any ideas?

Installing MathJax Engine

I had this warning in my console log math-tex-typesetting-missing: Missing the mathematical typesetting engine (mathjax) for tex., so it's obvious that it tells me to install MathJax, so I tried to install MathJax and KaTeX, but none of them worked.

The method, that I follow to install ckeditor5-math and MathJax, was:-

  1. In ckEditor5 folder, I run npm install ckeditor5-math --save-dev, then npm install mathjax.
  2. Add import into ckeditor.js file import Mathematics from 'ckeditor5-math/src/math';
  3. Add it to built-in plugins
InlineEditor.builtinPlugins = [
	// ...
	Mathematics
];
  1. In ckEditor5 folder, I run npm run-script build.

It worked fine with ckeditor5-math but display mode didn't work, in other words, MathJax didn't work and give me the above-mentioned log, so what is the right way to install MathJax or KaTaX, and how can I solve this problem?

error

P.S: The ckeditor5 was integrated with Angular12 App.

Math widget is selected after entering expression

Hi, there's sort of usability issue that when you enter an expression, it is immediatelly selected - if you then continue with typing, widget will be removed because it was in selection:

(here the expression disappears on spacebar)

Now you need to be extra careful to remove the selection first (e.g. with pressing right arrow) before you can continue with typing.

Make span element className configurable

I have a large installation which currently uses the CKEditor 4 MathJax plugin. The plugin provides a configuration for the MathJax element className, which is currently set to the tex2jax.processClass value of the MathJax configuration. I'd like to suggest to have such option here too.

Question: Use with Custom-Build CKEditor5

Hi,
I am sorry to bother... I want to use a custom build of CKEditor5 with this brilliant plugin in a Next-JS environment:

  return (
    <div>
      {isLayoutReady ? (
        <>
          <Script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" id="MathJax-script" async/>
          <CKEditor editor={ClassicEditor} data={getValues(fieldName)} />
        </>
      ) : null}
    </div>
  );

This works very well... The only problem is: I want MathJax to be loaded locally from "node_modules/mathjax/es5/tex-svg.js"... I really don't get, what to do... Can someone give me a hint?

Best Regards,
Tobias

Display mode toggle

Hi, thanks for the autoformatting and recent fixes! I really appreciate them.

I have a small issue/question...

For me the name "display mode" is quite confusing - although I know now what does it do, I still don't know why it is named "display mode". In CKEditor terminology this would be called "block mode" (as opposed to "inline mode") which IMHO reflects the usage quite well.

Also I would propose a radio button toggle which would make it clear what are the 2 options:

TypeScript compilation errors with CKEditor 37.1.0

Hi, I'm trying to upgrade to 37.1.0, but getting these errors:

src/ckeditor.ts:63:18 - error TS7016: Could not find a declaration file for module '@isaul32/ckeditor5-math/src/math'. '/home/[...]/[...]/node_modules/@isaul32/ckeditor5-math/src/math.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/isaul32__ckeditor5-math` if it exists or add a new declaration (.d.ts) file containing `d
eclare module '@isaul32/ckeditor5-math/src/math';`

63 import Math from '@isaul32/ckeditor5-math/src/math';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/ckeditor.ts:64:28 - error TS7016: Could not find a declaration file for module '@isaul32/ckeditor5-math/src/autoformatmath'. '/home/[...]/[...]/node_modules/@isaul32/ckeditor5-math/src/autoformatmath.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/isaul32__ckeditor5-math` if it exists or add a new declaration (.d.ts) file containing `d
eclare module '@isaul32/ckeditor5-math/src/autoformatmath';`

64 import AutoformatMath from '@isaul32/ckeditor5-math/src/autoformatmath';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unfortunately I don't have an experience in TypeScript to solve it myself.

27.0.0: Dragging/dropping of formulas not supported

Example (+ copy text issue with #35)

00:15 - 00:25:

2021-05-04.09-08-33.-.ckeditor5-math.PR.34.35.-.with.PR.mp4

Drag and drop of inline content:

Recreation steps

  • git clone https://github.com/isaul32/ckeditor5-math.git
  • cd ckeditor5-math
  • yarn
  • yarn start
  • http://localhost:8080
  • Drag and drop a formula

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.