diff options
Diffstat (limited to '')
-rw-r--r-- | infrastructure/ace/www/ace2_inner.js | 45 | ||||
-rw-r--r-- | infrastructure/ace/www/contentcollector.js | 18 | ||||
-rw-r--r-- | infrastructure/ace/www/editor.css | 9 | ||||
-rw-r--r-- | infrastructure/ace/www/linestylefilter.js | 8 |
4 files changed, 74 insertions, 6 deletions
diff --git a/infrastructure/ace/www/ace2_inner.js b/infrastructure/ace/www/ace2_inner.js index e817c95..33c13e8 100644 --- a/infrastructure/ace/www/ace2_inner.js +++ b/infrastructure/ace/www/ace2_inner.js @@ -752,6 +752,12 @@ function OUTER(gscope) { italic: function() { toggleAttributeOnSelection('italic'); }, underline: function() { toggleAttributeOnSelection('underline'); }, strikethrough: function() { toggleAttributeOnSelection('strikethrough'); }, + h1: function() { toggleAttributeOnSelection('h1'); }, + h2: function() { toggleAttributeOnSelection('h2'); }, + h3: function() { toggleAttributeOnSelection('h3'); }, + h4: function() { toggleAttributeOnSelection('h4'); }, + h5: function() { toggleAttributeOnSelection('h5'); }, + h6: function() { toggleAttributeOnSelection('h6'); }, undo: function() { doUndoRedo('undo'); }, redo: function() { doUndoRedo('redo'); }, clearauthorship: function(prompt) { @@ -1523,7 +1529,9 @@ function OUTER(gscope) { } var STYLE_ATTRIBS = {bold: true, italic: true, underline: true, - strikethrough: true, list: true}; + strikethrough: true, h1: true, h2: true, + h3: true, h4: true, h5: true, h6: true, + list: true}; var OTHER_INCORPED_ATTRIBS = {insertorder: true, author: true}; function isStyleAttribute(aname) { @@ -2070,8 +2078,34 @@ function OUTER(gscope) { [[attributeName,'']]); } else { - performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, - [[attributeName,'true']]); + var settings = [[attributeName, 'true']]; + + if (attributeName == 'h1' || attributeName == 'h2' || attributeName == 'h3' || + attributeName == 'h4' || attributeName == 'h5' || attributeName == 'h6') { + + settings = [['h1',''], ['h2',''], ['h3',''], + ['h4',''], ['h5',''], ['h6','']]; + if (attributeName == 'h1') { + settings[0] = [attributeName, 'true']; + } + else if (attributeName == 'h2') { + settings[1] = [attributeName, 'true']; + } + else if (attributeName == 'h3') { + settings[2] = [attributeName, 'true']; + } + else if (attributeName == 'h4') { + settings[3] = [attributeName, 'true']; + } + else if (attributeName == 'h5') { + settings[4] = [attributeName, 'true']; + } + else if (attributeName == 'h6') { + settings[5] = [attributeName, 'true']; + } + } + + performDocumentApplyAttributesToRange(rep.selStart, rep.selEnd, settings); } } @@ -4762,6 +4796,11 @@ function OUTER(gscope) { a = a.nextSibling; b = b.nextSibling; } + + // fix if first line has margin (f.e. h1 in first line) + sideDivInner.firstChild.style.marginTop = + (doc.body.firstChild.offsetTop - sideDivInner.firstChild.offsetTop + + parseInt(sideDivInner.firstChild.style.marginTop + "0")) + "px"; } } diff --git a/infrastructure/ace/www/contentcollector.js b/infrastructure/ace/www/contentcollector.js index c5d8ddb..573672e 100644 --- a/infrastructure/ace/www/contentcollector.js +++ b/infrastructure/ace/www/contentcollector.js @@ -340,6 +340,24 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, tname == "del") { doAttrib("strikethrough"); } + if (tname == "h1") { + doAttrib("h1"); + } + if (tname == "h2") { + doAttrib("h2"); + } + if (tname == "h3") { + doAttrib("h3"); + } + if (tname == "h4") { + doAttrib("h4"); + } + if (tname == "h5") { + doAttrib("h5"); + } + if (tname == "h6") { + doAttrib("h6"); + } if (tname == "ul") { var type; var rr = cls && /(?:^| )list-(bullet[12345678])\b/.exec(cls); diff --git a/infrastructure/ace/www/editor.css b/infrastructure/ace/www/editor.css index 0a43478..9df127d 100644 --- a/infrastructure/ace/www/editor.css +++ b/infrastructure/ace/www/editor.css @@ -6,7 +6,12 @@ body { margin: 0; white-space: nowrap; -} +} + +h1,h2,h3,h4,h5,h6 { + display: inline; + line-height: 2em; +} #outerdocbody { background-color: #fff; @@ -106,4 +111,4 @@ p { font-family: monospace; /* overridden by lineMetricsDiv.style */ } -#overlaysdiv { position: absolute; left: -1000px; top: -1000px; }
\ No newline at end of file +#overlaysdiv { position: absolute; left: -1000px; top: -1000px; } diff --git a/infrastructure/ace/www/linestylefilter.js b/infrastructure/ace/www/linestylefilter.js index 196cb63..f772ce3 100644 --- a/infrastructure/ace/www/linestylefilter.js +++ b/infrastructure/ace/www/linestylefilter.js @@ -29,7 +29,13 @@ linestylefilter.ATTRIB_CLASSES = { 'bold':'tag:b', 'italic':'tag:i', 'underline':'tag:u', - 'strikethrough':'tag:s' + 'strikethrough':'tag:s', + 'h1':'tag:h1', + 'h2':'tag:h2', + 'h3':'tag:h3', + 'h4':'tag:h4', + 'h5':'tag:h5', + 'h6':'tag:h6' }; linestylefilter.getAuthorClassName = function(author) { |