Updated Sanitizer for HTML5

Sanitizer should recognize HTML elements
and attributes.

New Allowed Elements:

  article aside audio canvas command details
  dialog figcaption figure footer header
  hgroup mark meter nav progress rp rt ruby
  section source summary time video war 
       
(OK, audio and video were already there)

New Allowed Attributes:

  autocomplete contenteditable contextmenu
  draggable formaction icon low max min
  open optimum pattern placeholder preload
  pubdate required reversed  spellcheck step
  wrap

Attributes removed:

  abbr charset loopcount loopend loopstart
  noshade nowrap rev rules 


Maruku supports @start and @reversed on
ordered lists. It doesn't seem to support
IALs on li elements, so you still can't
attach @value to an li.
This commit is contained in:
Jacques Distler 2010-05-22 14:34:08 -05:00
parent d9d353a350
commit 2781890832
9 changed files with 175 additions and 137 deletions

View file

@ -961,7 +961,6 @@ function BatchCommand(text) {
'</svg>').documentElement, true);
$(svgroot).appendTo(container);
var opac_ani = document.createElementNS(svgns, 'animate');
$(opac_ani).attr({
attributeName: 'opacity',
@ -1777,7 +1776,9 @@ function BatchCommand(text) {
var i = selectedElements.length;
while(i--) {
var cmd = recalculateDimensions(selectedElements[i]);
var elem = selectedElements[i];
// if(canvas.getRotationAngle(elem) && !hasMatrixTransform(canvas.getTransformList(elem))) continue;
var cmd = recalculateDimensions(elem);
if (cmd) {
batchCmd.addSubCommand(cmd);
}
@ -2052,6 +2053,8 @@ function BatchCommand(text) {
}
}
}
// End here if all it has is a rotation
if(tlist.numberOfItems == 1 && canvas.getRotationAngle(selected)) return null;
}
// if this element had no transforms, we are done
@ -2132,6 +2135,7 @@ function BatchCommand(text) {
transformListToTransform(tlist).matrix),
m = svgroot.createSVGMatrix();
// temporarily strip off the rotate and save the old center
var gangle = canvas.getRotationAngle(selected);
if (gangle) {
@ -2157,7 +2161,11 @@ function BatchCommand(text) {
var tx = 0, ty = 0,
operation = 0,
N = tlist.numberOfItems;
if(N) {
var first_m = tlist.getItem(0).matrix;
}
// first, if it was a scale then the second-last transform will be it
if (N >= 3 && tlist.getItem(N-2).type == 3 &&
tlist.getItem(N-3).type == 2 && tlist.getItem(N-1).type == 2)
@ -2359,6 +2367,11 @@ function BatchCommand(text) {
// if it was a translate, put back the rotate at the new center
if (operation == 2) {
if (gangle) {
newcenter = {
x: oldcenter.x + first_m.e,
y: oldcenter.y + first_m.f
};
var newRot = svgroot.createSVGTransform();
newRot.setRotate(gangle,newcenter.x,newcenter.y);
tlist.insertItemBefore(newRot, 0);
@ -2550,8 +2563,12 @@ function BatchCommand(text) {
// if it was a translate, put back the rotate at the new center
if (operation == 2) {
if (angle) {
newcenter = {
x: oldcenter.x + m.e,
y: oldcenter.y + m.f
};
var newRot = svgroot.createSVGTransform();
newRot.setRotate(angle,newcenter.x,newcenter.y);
newRot.setRotate(angle, newcenter.x, newcenter.y);
tlist.insertItemBefore(newRot, 0);
}
}
@ -3447,50 +3464,15 @@ function BatchCommand(text) {
var y2 = y;
if(evt.shiftKey) {
var snap = Math.PI/4; // 45 degrees
var diff_x = x - start_x;
var diff_y = y - start_y;
var angle = ((Math.atan2(start_y-y,start_x-x) * (180/Math.PI))-90) % 360;
angle = angle<0?(360+angle):angle
// TODO: Write all this more efficiently
var angle = Math.atan2(diff_y,diff_x);
var dist = Math.sqrt(diff_x * diff_x + diff_y * diff_y);
var val = Math.sqrt((dist*dist)/2);
var diagonal = false;
if(angle >= 360-22.5 || angle < 22.5) {
x2 = start_x;
} else if(angle >= 22.5 && angle < 22.5 + 45) {
diagonal = true;
} else if(angle >= 22.5 + 45 && angle < 22.5 + 90) {
y2 = start_y;
} else if(angle >= 22.5 + 90 && angle < 22.5 + 135) {
diagonal = true;
} else if(angle >= 22.5 + 135 && angle < 22.5 + 180) {
x2 = start_x;
} else if(angle >= 22.5 + 180 && angle < 22.5 + 225) {
diagonal = true;
} else if(angle >= 22.5 + 225 && angle < 22.5 + 270) {
y2 = start_y;
} else if(angle >= 22.5 + 270 && angle < 22.5 + 315) {
diagonal = true;
}
if(diagonal) {
if(y2 < start_y) {
y2 = start_y - val;
} else {
y2 = start_y + val;
}
if(x2 < start_x) {
x2 = start_x - val;
} else {
x2 = start_x + val;
}
}
var snapangle= Math.round(angle/snap)*snap;
x2 = start_x + dist*Math.cos(snapangle);
y2 = start_y + dist*Math.sin(snapangle);
}
shape.setAttributeNS(null, "x2", x2);
shape.setAttributeNS(null, "y2", y2);
@ -4831,16 +4813,36 @@ function BatchCommand(text) {
this.addSeg = function(index) {
// Adds a new segment
var seg = p.segs[index];
if(!seg.prev) return;
var prev = seg.prev;
var new_x = (seg.item.x + prev.item.x) / 2;
var new_y = (seg.item.y + prev.item.y) / 2;
var list = elem.pathSegList;
var newseg = elem.createSVGPathSegLinetoAbs(new_x, new_y);
var newseg;
switch(seg.item.pathSegType) {
case 4:
var new_x = (seg.item.x + prev.item.x) / 2;
var new_y = (seg.item.y + prev.item.y) / 2;
newseg = elem.createSVGPathSegLinetoAbs(new_x, new_y);
break;
case 6: //make it a curved segment to preserve the shape (WRS)
// http://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm#Geometric_interpretation
var p0_x = (prev.item.x + seg.item.x1)/2;
var p1_x = (seg.item.x1 + seg.item.x2)/2;
var p2_x = (seg.item.x2 + seg.item.x)/2;
var p01_x = (p0_x + p1_x)/2;
var p12_x = (p1_x + p2_x)/2;
var new_x = (p01_x + p12_x)/2;
var p0_y = (prev.item.y + seg.item.y1)/2;
var p1_y = (seg.item.y1 + seg.item.y2)/2;
var p2_y = (seg.item.y2 + seg.item.y)/2;
var p01_y = (p0_y + p1_y)/2;
var p12_y = (p1_y + p2_y)/2;
var new_y = (p01_y + p12_y)/2;
newseg = elem.createSVGPathSegCurvetoCubicAbs(new_x,new_y, p0_x,p0_y, p01_x,p01_y);
var pts = [seg.item.x,seg.item.y,p12_x,p12_y,p2_x,p2_y];
replacePathSeg(seg.type,index,pts);
break;
}
insertItemBefore(elem, newseg, index);
}
@ -5030,10 +5032,17 @@ function BatchCommand(text) {
var diff_x = cur_x - prev_x;
var diff_y = cur_y - prev_y;
// get control points from straight line segment
/*
var ct1_x = (prev_x + (diff_y/2));
var ct1_y = (prev_y - (diff_x/2));
var ct2_x = (cur_x + (diff_y/2));
var ct2_y = (cur_y - (diff_x/2));
*/
//create control points on the line to preserve the shape (WRS)
var ct1_x = (prev_x + (diff_x/3));
var ct1_y = (prev_y + (diff_y/3));
var ct2_x = (cur_x - (diff_x/3));
var ct2_y = (cur_y - (diff_y/3));
points = [cur_x,cur_y, ct1_x,ct1_y, ct2_x,ct2_y];
}
break;
@ -9038,7 +9047,7 @@ function BatchCommand(text) {
// Function: getVersion
// Returns a string which describes the revision number of SvgCanvas.
this.getVersion = function() {
return "svgcanvas.js ($Rev: 1569 $)";
return "svgcanvas.js ($Rev: 1573 $)";
};
this.setUiStrings = function(strs) {