Skip to content

Instantly share code, notes, and snippets.

@hungrysquirrel
Created February 14, 2011 04:51
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 hungrysquirrel/825498 to your computer and use it in GitHub Desktop.
Save hungrysquirrel/825498 to your computer and use it in GitHub Desktop.
Corrects the odd formatting of height and width when pasted into text editor
/*
------------------------------------
Copy CSS Dimensions v1.0
------------------------------------
Created by Matt Stow 2010
http://www.mattstow.com
------------------------------------
*/
(function()
{
if (fw.documents.length == 0) {
return;
}
if (fw.selection != null && fw.selection.length == 1) {
var originalSelection = [].concat(fw.selection);
var dom = fw.getDocumentDOM();
var css = "height: " + fw.selection[0].height + "px;" + "\r\n" + "width: " + fw.selection[0].width + "px;"
dom.addNewText({left:-100, top:-100, right:-100, bottom:-100}, true);
var tr = fw.selection[0].textRuns;
tr.textRuns = [{changedAttrs: {}, characters:css}];
fw.selection[0].textRuns = tr;
dom.clipCopyFormats("(ADOBE AI3)");
dom.deleteSelection(false);
fw.selection = originalSelection;
}
else {
alert("Please select an object before running this command");
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment