Giter Site home page Giter Site logo

kineticjs-editable-text's Introduction

kinetic-editable-text

A KineticJS library which enables text creation and editing directly on the canvas

Summary

Re-inventing the wheel in text editing!

This tool was created in order to avoid the HTML textarea popup when wanting to enter text on the canvas. Most operations are supported, such as cursor movement, backspace, delete, and entering new lines.

Selecting text is not yet supported.

Initialization

Without a module loader

The global Kinetic object will be extended with Kinetic.EditableText

With CommonJS or AMD

kinetic-editable-text will return an object containing an init method. Kinetic is passed as the first argument to the init method, and will be extended with Kinetic.EditableText. An AMD example:

define([ 'Kinetic', 'kineticEditableText' ], function( Kinetic, kineticEditableText ){
    console.log( typeof Kinetic.EditableText ); // undefined

    kineticEditableText.init( Kinetic );

    console.log( typeof Kinetic.EditableText ); // function
});

API

Kinetic.EditableText.focus()

Focus the Kinetic.EditableText field so that it will start receiving text input.

Kinetic.EditableText.unfocus()

Unfocus the Kinetic.EditableText field so that it will stop receiving text input.

Kinetic.EditableText.addChar( character )

Add the specified character (string) to the Kinetic.EditableText field at the current cursor position.

Kinetic.EditableText.text( string )

This method mimics Kinetic.Text.text. If string is provided, the text in the Kinetic.EditableText field will be set to string; otherwise, the text currently in the field will be returned.

Kinetic.EditableText.backspaceChar()

Remove the character to the left of the current cursor position.

Kinetic.EditableText.deleteChar()

Remove the character to the right of the current cursor position.

Kinetic.EditableText.clear()

Remove all of the characters from the Kinetic.EditableText field.

Example

See index.html

About

Known Issues

  • Selecting text is not supported.
  • Copy paste (from outside text) is not fully functional yet.

Limitations

Tested with Kinetic v5.1.0 and v5.1.1

Contributions

Feel free to make a pull request and contribute to making this tool better.

kineticjs-editable-text's People

Contributors

hoffmannkrzysztof avatar mjhasbach avatar nktsitas avatar

Watchers

 avatar  avatar

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.