Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created June 12, 2013 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biovisualize/5768775 to your computer and use it in GitHub Desktop.
Save biovisualize/5768775 to your computer and use it in GitHub Desktop.
Contenteditable in foreignObject
{"description":"Contenteditable in foreignObject","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"hidepanel":true}
// Change the size here to see it wrap
var w = 494
var h = 300;
var div = d3.select("#display");
var svg = div.append("svg")
.attr({width: w, height: h});
svg.append("foreignObject")
.attr({width: w, height: h})
.append("xhtml:body")
.append("xhtml:span")
.attr({'class': 'cell', contenteditable: true})
.text('test')
.on("keyup", function(d, i){
console.log(d3.select(this).text());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment