Git Product home page Git Product logo

iinkts's Introduction

iinkTS

npm version Examples Documentation

The fastest way to integrate rich handwriting features in your webapp.

iinkTS is a JavaScript library that can be used in every web application to bring handwriting recognition.

It integrates all you need:

  • Signal capture for all devices,
  • Digital ink rendering,
  • Link to MyScript Cloud to bring handwriting recognition.

Table of contents

Features

  • Text and Math support,
  • Easy to integrate,
  • Digital ink capture and rendering,
  • Rich editing gestures,
  • Import and export content,
  • Styling,
  • Typeset support,
  • More than 200 mathematical symbols supported,
  • 72 supported languages.

You can discover all the features on our Developer website for Text and Math.

Requirements

  1. Have npm, yarn.
  2. Have a MyScript developer account. You can create one here.
  3. Get your keys and the free monthly quota to access MyScript Cloud at developer.myscript.com

Installation

iinkTS can be installed with the well known package managers npm, yarn.

If you want to use npm or yarn you first have to init a project (or use an existing one).

npm init
OR
yarn init

You can then install iinkTS and use it as showed in the Usage section.

npm install iink-ts
OR
yarn add iink-ts

Usage

  1. Create an index.html file in the same directory.

  2. Add the following lines in the head section of your file to use iinkTS and the css :

<script src="node_modules/iink-ts/dist/iink.min.js"></script>
  1. Still in the head section, add a style and specify the height and the width of your editor:
<style>
    #editor {
        width: 100%;
        height: 100%;
    }
</style>
  1. In the body tag, create a div tag that will contain the editing area:
    <div id="editor"></div>
  1. In JavaScript and within a <script> tag placed before the closing tag </body>, create the editor using the Editor constructor function, your editor html element and a simple configuration, then initialize it:
  const editorElement = document.getElementById('editor');

  const editor = new iink.Editor(editorElement, {
      configuration: {
          server: {
              applicationKey: '#YOUR MYSCRIPT DEVELOPER APPLICATION KEY#',
              hmacKey: '#YOUR MYSCRIPT DEVELOPER HMAC KEY#'
          }
      }
  });
  editor.initialize();
  1. Your index.html file should look like this:
<html>
    <head>
        <script src="node_modules/iink-ts/dist/iink.min.js"></script>
        <style>
            #editor {
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <div id="editor" touch-action="none"></div>
        <script>
            const editorElement = document.getElementById('editor');

            const editor = new iink.Editor(editorElement, {
                configuration: {
                    server: {
                        applicationKey: '#YOUR MYSCRIPT DEVELOPER APPLICATION KEY#',
                        hmacKey: '#YOUR MYSCRIPT DEVELOPER HMAC KEY#'
                    }
                }
            });
            editor.initialize();
        </script>
    </body>
</html>
  1. Open index.html in your browser or serve your folder content using any web server.

You can find this guide, and a more complete example on the MyScript Developer website.

Documentation

You can find a complete documentation with the following sections on our Developer website:

As well as a global Configuration page.

We also provide a complete API Reference.

Development

Instructions to help you build the project and develop are available in the SETUP.md file.

Getting support

You can get support and ask your questions on the dedicated section of MyScript Developer website.

Sharing your feedback ?

Made a cool app with iinkTS? We would love to hear about you! We’re planning to showcase apps using it so let us know by sending a quick mail to [email protected].

Contributing

We welcome your contributions: if you would like to extend iinkTS for your needs, feel free to fork it!

Please take a look at our contributing guidelines before submitting your pull request.

Troubleshooting

If you encounter the error: Unrecognized property: convert.force, this means your server version is lower than 2.3.0. To correct the problem, you have 2 options:

  • either update your server
  • either add in the iink-ts configuration configuration.server.version = 2.2.0

License

This library is licensed under the Apache 2.0.

iinkts's People

Contributors

blatinville avatar lejsboureau avatar mathieuruellanmyscript avatar srobert-myscript avatar torebo 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

Watchers

 avatar  avatar

iinkts's Issues

Editor styles unavailable in shadow dom elements

The editor styles are added to the top level of the page instead of inside the passed editor element due to the change to directly import the css file at the top of the editor class. This means elements inside shadow doms no longer receive the styles and also increases the chance of style conflicts.

In iink-js the style element was directly added to the editor element so this was not an issue.

We use this library inside a chrome extension where we must keep our styles separate from the page we're loading on. Is there any way to replicate the old behaviour? I'm aware we can just copy and inject the iink.css ourselves, but that isn't ideal and would still result in the page having the styles added to the top level.

Server state randomly corrupts and collapses the iink editor content

I set up a editor to automatically convert strokes to text after a couple seconds of inactivity. Before long, the server seems to tell the client to collapse everything into a jumbled mess. "Undo" does not fix the situation - running the undo command will temporarily revert to the clean state on the client side, but the next time "convert" is run the content will get messed up again.

Minimal example to recreate the issue:

export class HandwritingEditor {
    private iinkEditor: IInkEditor
    private editorContainer: HTMLElement
    private editorElement: HTMLElement
    private resizeObserver: ResizeObserver
    private lastChangeID: string = ""

    constructor(applicationKey: string, hmacKey: string) {
        this.editorContainer = document.createElement('div')
        this.editorContainer.id = 'handwriting-editor-container'
        this.editorElement = document.createElement('div')
        this.editorElement.id = 'handwriting-editor'
        this.editorContainer.appendChild(this.editorElement)
        this.iinkEditor = new IInkEditor(this.editorElement,
            {
                configuration: {
                    server: {
                        scheme: "https",
                        host: "cloud.myscript.com",
                        applicationKey: applicationKey,
                        hmacKey: hmacKey,
                    },
                },
            }
        )
        setTimeout(() => {
            this.iinkEditor.initialize().then(() => {
                this.iinkEditor.events.addEventListener("changed", (evt: any) => {
                    const changeID = crypto.randomUUID()
                    this.lastChangeID = changeID
                    setTimeout(() => {
                        if (changeID == this.lastChangeID) {
                            this.iinkEditor.convert()
                        }
                    }, 2000)
                })
            })
        })
        this.resizeObserver = new ResizeObserver(this.refreshSize.bind(this));
        this.resizeObserver.observe(this.editorElement);
        this.refreshSize()
    }

    getEditorContainer() {
        return this.editorContainer
    }

    refreshSize() {
        this.iinkEditor.resize()
    }
}

let editor = HandwritingEditor("app key", "hmac key")
document.body.appendChild(editor.getEditorContainer())

Before collapse:
pre-jumble

After collapse:
after-jumble

Reliance on discontinued `crypto-js` requires node/browser pollyfill

This is more of an inquiry/suggestion on the use of the crypto-js library.

crypto-js is discontinued and versions 4+ of crypto-js rely on using the native node / browser library crypto for some functionality .
https://github.com/brix/crypto-js/blob/develop/README.md#400

This means people using this library need to decide on either polyfilling with the node api module or relying on browser support. This is difficult to check as I'm not entirely sure what functions of crypto are required for crypto-js usage so it's hard to gauge browser support.

Could you provide insight on what you recommend for iink-ts usage of crypto-js and If possible would removing the crypto-js dependency be viable in future?

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.