Added sanitizer extension
This commit is contained in:
parent
3ccc267028
commit
580fd66b15
@ -20,6 +20,7 @@ define([
|
|||||||
var modifiedSections = [];
|
var modifiedSections = [];
|
||||||
var insertBeforeSection;
|
var insertBeforeSection;
|
||||||
var fileChanged = false;
|
var fileChanged = false;
|
||||||
|
|
||||||
function updateSectionList() {
|
function updateSectionList() {
|
||||||
var newSectionList = [];
|
var newSectionList = [];
|
||||||
var newLinkDefinition = '\n';
|
var newLinkDefinition = '\n';
|
||||||
@ -111,6 +112,7 @@ define([
|
|||||||
|
|
||||||
var footnoteContainerElt;
|
var footnoteContainerElt;
|
||||||
var previewContentsElt;
|
var previewContentsElt;
|
||||||
|
|
||||||
function refreshSections() {
|
function refreshSections() {
|
||||||
|
|
||||||
// Remove outdated sections
|
// Remove outdated sections
|
||||||
@ -121,13 +123,14 @@ define([
|
|||||||
|
|
||||||
var wmdPreviewElt = document.getElementById("wmd-preview");
|
var wmdPreviewElt = document.getElementById("wmd-preview");
|
||||||
var childNode = wmdPreviewElt.firstChild;
|
var childNode = wmdPreviewElt.firstChild;
|
||||||
|
|
||||||
function createSectionElt(section) {
|
function createSectionElt(section) {
|
||||||
var sectionElt = crel('div', {
|
var sectionElt = crel('div', {
|
||||||
id: 'wmd-preview-section-' + section.id,
|
id: 'wmd-preview-section-' + section.id,
|
||||||
class: 'wmd-preview-section preview-content'
|
class: 'wmd-preview-section preview-content'
|
||||||
});
|
});
|
||||||
var isNextDelimiter = false;
|
var isNextDelimiter = false;
|
||||||
while (childNode) {
|
while(childNode) {
|
||||||
var nextNode = childNode.nextSibling;
|
var nextNode = childNode.nextSibling;
|
||||||
var isDelimiter = childNode.className == 'se-preview-section-delimiter';
|
var isDelimiter = childNode.className == 'se-preview-section-delimiter';
|
||||||
if(isNextDelimiter === true && childNode.tagName == 'DIV' && isDelimiter) {
|
if(isNextDelimiter === true && childNode.tagName == 'DIV' && isDelimiter) {
|
||||||
@ -166,7 +169,8 @@ define([
|
|||||||
elt.textContent = index + 1;
|
elt.textContent = index + 1;
|
||||||
var id = elt.id.substring(6);
|
var id = elt.id.substring(6);
|
||||||
usedFootnoteIds.push(id);
|
usedFootnoteIds.push(id);
|
||||||
footnoteElts.appendChild(footnoteMap[id].cloneNode(true));
|
var footnoteElt = footnoteMap[id];
|
||||||
|
footnoteElt && footnoteElts.appendChild(footnoteElt.cloneNode(true));
|
||||||
});
|
});
|
||||||
if(usedFootnoteIds.length > 0) {
|
if(usedFootnoteIds.length > 0) {
|
||||||
// Append the whole footnotes at the end of the document
|
// Append the whole footnotes at the end of the document
|
||||||
|
@ -10,6 +10,47 @@ define([
|
|||||||
|
|
||||||
var utils = {};
|
var utils = {};
|
||||||
|
|
||||||
|
utils.msie = (function() {
|
||||||
|
/**
|
||||||
|
* IE 11 changed the format of the UserAgent string.
|
||||||
|
* See http://msdn.microsoft.com/en-us/library/ms537503.aspx
|
||||||
|
*/
|
||||||
|
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
|
||||||
|
if (isNaN(msie)) {
|
||||||
|
msie = parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
|
||||||
|
}
|
||||||
|
return msie;
|
||||||
|
})();
|
||||||
|
|
||||||
|
utils.urlResolve = (function() {
|
||||||
|
var urlParsingNode = document.createElement("a");
|
||||||
|
return function urlResolve(url) {
|
||||||
|
var href = url;
|
||||||
|
|
||||||
|
if (utils.msie) {
|
||||||
|
// Normalize before parse. Refer Implementation Notes on why this is
|
||||||
|
// done in two steps on IE.
|
||||||
|
urlParsingNode.setAttribute("href", href);
|
||||||
|
href = urlParsingNode.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
|
||||||
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||||
|
return {
|
||||||
|
href: urlParsingNode.href,
|
||||||
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||||
|
host: urlParsingNode.host,
|
||||||
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||||
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||||
|
hostname: urlParsingNode.hostname,
|
||||||
|
port: urlParsingNode.port,
|
||||||
|
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
||||||
|
urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
// Faster than setTimeout (see http://dbaron.org/log/20100309-faster-timeouts)
|
// Faster than setTimeout (see http://dbaron.org/log/20100309-faster-timeouts)
|
||||||
utils.defer = (function() {
|
utils.defer = (function() {
|
||||||
var timeouts = [];
|
var timeouts = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user