├── LICENSE ├── README.md └── raphael.inline_text_editing.js /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Emmanuel Quentin, marmelab 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Raphaël.InlineTextEditing 2 | ==================== 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 |
archivedArchived Repository
9 | This code is no longer maintained. Feel free to fork it, but use it at your own risks. 10 |
13 | 14 | Inline text editing tool for [Raphaël 2.0](http://raphaeljs.com/) & compatible with [Raphaël Free transform](https://github.com/ElbertF/Raphael.FreeTransform). 15 | Supports SVG text elements with any type of transformation (scale, rotate, translate, matrix). 16 | 17 | [See demo](http://marmelab.github.io/Raphael.InlineTextEditing/) 18 | 19 | *Licensed under the [MIT license](LICENSE).* 20 | 21 | Example 22 | ------- 23 | 24 | ```javascript 25 | var paper = Raphael(document.getElementById('container'), 740, 540); 26 | 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]); 27 | 28 | // Initialize text editing for the text element 29 | paper.inlineTextEditing(text); 30 | 31 | // Start inline editing on click 32 | text.click(function(){ 33 | // Retrieve created field 34 | var input = this.inlineTextEditing.startEditing(); 35 | 36 | input.addEventListener("blur", function(e){ 37 | // Stop inline editing after blur on the text field 38 | text.inlineTextEditing.stopEditing(); 39 | }, true); 40 | }); 41 | ``` 42 | 43 | Functions 44 | --------- 45 | #### `startEditing()` 46 | Hide initialized text and add HTML input text at the same position. 47 | 48 | Returns this text field. 49 | 50 | #### `stopEditing()` 51 | Remove the text field added with startEditing() and apply text modifications. 52 | 53 | 54 | TODO 55 | ---- 56 | * Fix long text positionning when scaled 57 | * Allow webfonts 58 | -------------------------------------------------------------------------------- /raphael.inline_text_editing.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Inline text editing tool for Raphaël 2.0 & compatible with Raphaël Free transform. 3 | * Source: https://github.com/marmelab/Raphael.InlineTextEditing 4 | * Licensed under the MIT license 5 | */ 6 | (function (root, factory) { 7 | if (typeof define === "function" && define.amd) { 8 | // AMD. Register as an anonymous module. 9 | define(["raphael"], function(Raphael) { 10 | // Use global variables if the locals are undefined. 11 | return factory(Raphael || root.Raphael); 12 | }); 13 | } else { 14 | // RequireJS isn't being used. Assume Raphael is loaded in