You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not an issue. Here's a very simple addition to add support to svg foreignbject:
SVG.ForiegnObject=function(){this.constructor.call(this,SVG.create('foreignObject'))/* store type */this.type='foreignObject'}SVG.ForiegnObject.prototype=newSVG.ShapeSVG.extend(SVG.ForiegnObject,{appendChild: function(child,attrs){varnewChild=typeof(child)=='string' ? document.createElement(child) : childif(typeof(attrs)=='object'){for(ainattrs)newChild[a]=attrs[a]}this.node.appendChild(newChild)returnthis},getChild: function(index){returnthis.node.childNodes[index]}})SVG.extend(SVG.Container,{foreignObject: function(width,height){returnthis.put(newSVG.ForiegnObject).size(width==null ? 100 : width,height==null ? 100 : height)}})
And a simple example of use (assuming you put the above code in a file called svg.foreignobject.js:
<html><head><scriptsrc='svg.js'></script><scriptsrc='svg.foreignobject.js'></script></head><bodyonload="doit()"><h1>Foreign Objects</h1><divid='canvas'></div><script>vartxt="some text that is quite long. and it goes on and on. and it's pointless really. and the grammar is terrible. blah. blah. blah"varcanvas=SVG('canvas').size(1024,550)canvas.rect(1024,550).attr({fill: '#eee'})varfobj=canvas.foreignObject(100,100).attr({id: 'fobj'})functiondoit(){fobj.appendChild("div",{id: 'mydiv',innerText: txt})varn=fobj.getChild(0)fobj.attr({width: 200,height: 100}).rotate(45).move(100,0)n.style.height='50px'n.style.overflow='hidden'n.style.border="solid black 1px"}</script></body></html>
This is an alternative way to do text flowing and/or integrating a WYSWIG editor into a primarily SVG web page.
The text was updated successfully, but these errors were encountered:
Excellent! I've been thinking about writing it myself. :)
Why don't you put this plugin (svg.foreignobject.js) in a repo? I'll add it in the plugin section...
Not an issue. Here's a very simple addition to add support to svg foreignbject:
And a simple example of use (assuming you put the above code in a file called svg.foreignobject.js:
This is an alternative way to do text flowing and/or integrating a WYSWIG editor into a primarily SVG web page.
The text was updated successfully, but these errors were encountered: