Git Product home page Git Product logo

svelte-mathquill's Introduction

npm

A wrapper around MathQuill, a very intuitive math typing editor

npm i -D svelte-mathquill

Usage

Add this to your +layout.svelte or any wrapper file where you use MathQuill:

<script>
	import { MathQuillSetup } from 'svelte-mathquill';
</script>

<MathQuillSetup />

This injects jQuery and MathQuill (+ styles) into the head of the document, to begin using MathQuill in your components.

Simple example:

<script lang="ts">
	import { MathQuill } from 'svelte-mathquill';

	let latex = '';
</script>

<MathQuill bind:latex="{latex}" />
<br />
<input bind:value="{latex}" />

Documentation

Properties

autofocus: boolean - if the element should focus on mount

latex: string (bindable & updates) - the content of the element

noBorderOutline: boolean - if styling should be applied to remove borders / outlines. Only use if you have a wrapper that's styled (outlines help accessibility!)

class: string - classes to apply to the math element

config: MathQuillConfig (updateable) - Apply a config to the element.

Events

Triggers when the text is edited: on:edit={latex => ...}

Triggers when the enter key is pressed: on:enter={() => ...}

Direction Events (L(eft) | R(ight) | U(p) | D(own))

Triggers when the up arrow is pressed: on:upOutOf={() => ...}

Triggers when the down arrow is pressed: on:downOutOf={() => ...}

Triggers when the right / left arrows are pressed: on:moveOutOf={("L" | "R") => ...}

Triggers when the content is selected out of: on:selectOutOf={("L" | "R") => ...}

Triggers when the content is deleted: on:deleteOutOf={("L" | "R") => ...}

Triggers when any out of is triggered: on:outOf={("L" | "R" | "U" | "D") => ...}

Triggers when any out of is triggered WITHOUT deleteOutOf: on:outOfOnly={("L" | "R" | "U" | "D") => ...}

Functions

Focus the element: mathQuillElement.focus()

Unfocus the element: mathQuillElement.blur()

Refresh the element: mathQuillElement.reflow()

Select the current element: mathQuillElement.select()

Clear any active selection: mathQuillElement.clearSelection()

Mimic a keystroke (ex Shift-Left): mathQuillElement.keystroke(string)

Type Text: mathQuillElement.typedText(string)

svelte-mathquill's People

Contributors

leodog896 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

svelte-mathquill's Issues

focus mode

Of course, sorry, I have a suggestion for you after clicking the button when the mathematical expression is entered, it is not good to stay in the focus mode?

I have added a localy and if you like it, please add it too

function input(str) { mathField.cmd(str) mathField.focus() }

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.