Getting started
This section presents what myscript-text-web
is and gives you information to start using it.
What is myscript-text-web?
The myscript-text-web
element offers the possibility to input handwritten text in any web page.
It is a rich editing zone where you can import raw text, edit it with rich gestures and handwriting, convert to type script, manipulate style and export the
produced content in raw text or HTML.
myscript-text-web
. Being familiar with Polymer is not necessary.
As recognition and conversion are processed on the server, it brings some constraints to ensure an optimal user experience. You need a high speed internet connection (latency is the key, as exchanged messages are relatively small except during jiix exports). For content styling, you have to use parameters and JavaScript objects instead of CSS, as the server needs to know the exact user positions.
Supported features
The following features of interactive ink are supported :
- Easy to integrate,
- Digital ink capture and rendering,
- Styling,
- 59 supported languages
Browser support
MyScriptJS supports the latest version of all major browsers: Safari 9+ and the evergreen Chrome, Firefox and Edge.
Requirements
This guide assumes that you are already familiar with key web-concepts like JavaScript dependencies management and polyfills.
Bower and all depending tools (nodejs, npm) have to be installed on your working environment.
This guide and relative libraries have been tested on Windows, macOS and Linux.
Installation
Open a console and type the following in your developing folder:
bower install myscript-text-web
Mandatory attributes
As myscript-text-web
is relying on either MyScript Cloud or MyScript Server, you have to provide an url and credentials to the server.
The default url for MyScript Cloud is cloud.myscript.com
.
Mandatory attributes
Attribute name | Description |
---|---|
apiversion |
use V4 for iink API |
applicationkey |
The application key provided during registration |
hmackey |
The hmac key provided during registration |
myscript-text-web
will take care of computing and answering the challenge sent by the server.
myscript-languages-element
Integration to HTML markup
Create then edit an index.html
file in the same folder and add the following lines:
<!doctype html>
<html>
<head>
<!-- Those three meta make the capture of handwriting inputs easier on mobile devices -->
<meta name="viewport" content="width=device-width, minimum-scale=1.1, initial-scale=1.1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>myscript-text-web demo</title>
<!-- As web components are not fully supported -->
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<!-- myscript-text-web is imported to be used later -->
<link rel="import" href="bower_components/myscript-text-web/myscript-text-web.html">
<style>
body {
margin: 0;
height: 95vh;
}
myscript-text-web {
height: 100%;
}
</style>
</head>
<body>
<!-- Please change applicationkey and hmackey below with those sent by mail during your registration. You can re-access them by connecting to your dashboard at developer.myscript.com with your myscript account -->
<myscript-text-web
applicationkey="YOUR APPLICATION KEY"
hmackey="YOUR HMAC KEY KEY"
language="en_US"
>
</myscript-text-web>
</body>
</html>
Launch a webserver serving the directory containing bower dependencies and the index.html file with for example python -m SimpleHTTPServer
.
Open the page in your browser (http://127.0.0.1:8000).
Configuring myscript-text-web with JavaScript
For every attribute modification of myscript-text-web
(except for styling, such as strokestyle
, strokewidth
, etc.),
the underlying editor is reinitialized, network connections are closed and reopened to provide the updated context of the recognition to the server.
If you want to set multiple attributes of a custom element with JavaScript, this behavior could really slow down your web application.
That is where the unloaded
attribute comes to the rescue.
This article about custom element interoperability lists the good practices met by
myscript-text-web
to help you build a fast and interoperable web application.
If you want to set attributes in JavaScript, create your instance of myscript-text-web
with only an unloaded
attribute set.
When loaded into the DOM, the component is attached but remains empty. This gives you the possibility to access it with JavaScript
(document.querySelector('myscript-text-web')
), so that you are able to set all the needed attributes.
The configuration
attribute allows you to fine-tune all the possible options available with myscript-text-web
.
Read the configuration reference documentation for a full list of supported options.
The programmatic init example code illustrates how to achieve it.
Reference documentation
Other optional attributes, methods and events are listed and documented in the reference documentation. The next sections will drive you through the most important points.