Git Product home page Git Product logo

raphael.inlinetextediting's Introduction

Raphaël.InlineTextEditing

archived Archived Repository
This code is no longer maintained. Feel free to fork it, but use it at your own risks.

Inline text editing tool for Raphaël 2.0 & compatible with Raphaël Free transform. Supports SVG text elements with any type of transformation (scale, rotate, translate, matrix).

See demo

Licensed under the MIT license.

Example

var paper = Raphael(document.getElementById('container'), 740, 540);
var text = paper.text(250, 250, 'Hello').attr({'text-anchor': 'start', 'font-size': '25px'}).transform(['T', 242, -174, 'R', 36.9973, 'S', 2.0631, 1]);

// Initialize text editing for the text element
paper.inlineTextEditing(text);

// Start inline editing on click
text.click(function(){
	// Retrieve created <input type=text> field
	var input = this.inlineTextEditing.startEditing();

	input.addEventListener("blur", function(e){
		// Stop inline editing after blur on the text field
		text.inlineTextEditing.stopEditing();
	}, true);
});

Functions

startEditing()

Hide initialized text and add HTML input text at the same position.

Returns this text field.

stopEditing()

Remove the text field added with startEditing() and apply text modifications.

TODO

  • Fix long text positionning when scaled
  • Allow webfonts

raphael.inlinetextediting's People

Contributors

alexisjanvier avatar fzaninotto avatar jpetitcolas avatar manuquentin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raphael.inlinetextediting's Issues

Wrong position of input text

Text inputs are wrongly placed: they are positioned relatively to the window, and not to the SVG container.

For instance, change container style to the following in the demonstration:

#canvas_container {
  width: 740px;
  height: 540px;
  border: 1px solid #aaa;
  margin-top: 400px;
  margin-left: 300px;
}

And try to edit a text. The input exits the container.

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.