Giter Club home page Giter Club logo

ckeditor5-math-preview's Introduction

ckeditor5-math-preview

npm version Dependency Status devDependency Status

About

This is a plugin for ckeditor 5. When clicking on a latex math expression, a popup is shown that displays the expression rendered with MathJax or KaTeX.

Demo

Check this fiddle: https://jsfiddle.net/centaur54dev/ra7qcLzb/

Install

Install using NPM:

npm install ckeditor5-math-preview

To add the functionality of this plugin you should make a custom build of the editor. Follow the instructions here.

To load the plugin, configure ckeditor (e.g. edit file ckeditor.js) like this:

Import plugin

import MathpreviewPlugin from 'ckeditor5-math-preview/src/mathpreview';

Configure build

Assuming that the build is based on Classic Editor:

export default class ClassicEditor extends ClassicEditorBase {}

// Plugins to include in the build.
ClassicEditor.builtinPlugins = [
	...
	MathpreviewPlugin,
	...
],

ClassicEditor.defaultConfig = {
	toolbar: {
		items: [
			...
			'mathpreview',
			...
			]
	},

	MathPreview : {
		//configuration options for the math-preview plugin
		engine: 'mathjax' //or 'katex'
	},



	...OTHER OPTIONS
};

Note: the MathPreview configuration is optional. If not defined the rendering defaults to MathJax.

Use

A toolbar button is added, which functions as an on/off switch for the plugin functionality. Type some math formulas in latex in the editor using either the \[ \] or the \( \) markers, e.g. \[x^2+\frac{1}{x}=0\]. When clicking anywhere in the formula, a popup appears and the formula is rendered. The rendering updates itself on formula modification, on the fly.

The plugin expects MathJax or KaTeX to be loaded and configured.

ckeditor5-math-preview's People

Contributors

centaur54dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ckeditor5-math-preview's Issues

CKE5 v.12.0 support?

Seems like not working with CKE 12.0.0, nothing happens when the plugin is clicked.

Unable to get this to work

entering formula eg \(x+x^2=0\) shows no changes

but the console prints when i click on the formula

Error: view-createPositionAt-offset-required: View#createPositionAt() requires the offset when the first parameter is a view item. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-view-createPositionAt-offset-required

setData() seems not to work properly when setting a latex formula

Which is the correct way of calling editor.setData( ) with a latex formula as an argument?

I tried editor.setData( "\\[a+b\\]" ); and I am getting a+ba+b
If a call editor.setData( "\[a+b\]" ); and I am getting [a+b]

The expected result in the editor should be \[a+b\].

Any idea?

Doesn't work with no errors

It doesn't work with no errors.

Here are my commits https://github.com/wenisy/ckeditor5-build-classic/commit/775e1fc398381b6d4893d77789f7f43c8a94cac2

  1. I add this plugin into dependencies not devDependencies
  "dependencies": {
    "ckeditor5-math-preview": "^1.0.7"
  }
  1. I add MathpreviewPlugin into ckeditor.js

  2. Test it on python -m SimpleHTTPServer with local file No errors, no modal alert, no correct result.

image

There is no declaration for mathjax in README, so I assume it is unnecessary.

And event I added mathjax into dependencies, it still doesn't work.

Updating the dependencies

Hey, i would like to use this cool plugin to write better Latex.
Sadly, it doesn't work due to duplicate modules because of this plugin uses 20 but the ckEditor5 is already developed to version 27.

Also a Keyboard Shortcut would be pretty awesome or even better if the popup appears automatically :)

Bug with visual representation of fractions

Hi, we have implemented the plugin as described for our math community site.

Unfortunately the following issue occurs:

2019-05-17_21-24-49

Is this known and does this only occur with the latest version?

Best, Leon

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.