A Polymer 2 element for converting any SVG element into an editable multi-line textarea.
Add <svg-textarea> element as a sibling to the svg container. Pass the ID of the SVG <text> element to svg-textarea to make it editable.
<svg width="100%" style="border: 1px solid red">
<text id="svgtext"></text>
</svg>
<svg-textarea svg-text-id="svgtext"></svg-textarea>
svg-text-id: The id of the svg<text>element.content: returns the text contentadjustments: The component is adjusted toOpen SansGoogle font and works pretty well for font sizes between 10-50px. However depending on yourfont-familyandfont-size, you might notice some shift in text when edit mode is enabled. Use theadjustmentsproperty to pass thetopandleftposition for each browser (Chrome,Firefox,MSIE,Safari). You can pass+veor-vevalues. These values are relative to the current position of textarea.
{
'Firefox': {
left: 0.4
},
'Safari': {
top: 0.3
}
}
Checkout the demo for examples.
Latest versions of Chrome, Safari, Firefox and IE11+
First, make sure you have the Polymer CLI installed. Then run polymer serve to serve your element locally.
$ polymer serve
$ polymer test
Your application is already set up to be tested via web-component-tester. Run polymer test to run your application's test suite locally.