diff --git a/sources/raje/app/css/rash-inline.css b/sources/raje/app/css/rash-inline.css index c3c32e5..0d27967 100644 --- a/sources/raje/app/css/rash-inline.css +++ b/sources/raje/app/css/rash-inline.css @@ -97,7 +97,7 @@ img.avatar{ span.affiliation.placeholder{ color:#999 } - +/* pre{ position: relative } @@ -109,4 +109,8 @@ pre::after{ padding: 10px 20px; background-color: rgba('0,0,0,.5'); content: "enter = new line" -} \ No newline at end of file +} + +figure > pref::after{ + display: none +}*/ \ No newline at end of file diff --git a/sources/raje/app/js/editor/1_init.js b/sources/raje/app/js/editor/1_init.js index ba03ce4..d7a0652 100644 --- a/sources/raje/app/js/editor/1_init.js +++ b/sources/raje/app/js/editor/1_init.js @@ -63,6 +63,11 @@ jQuery.fn.extend({ setEditState() }) + $(this).bind('dragover drop', function (event) { + event.preventDefault(); + return false; + }); + /** * Get when call event to disable or activate toolbar elements */ @@ -180,6 +185,12 @@ window.handleFormulaBox = function () { window[id].showModal(); }; +window.handleListingBox = function () { + var id = 'table_' + ($(this).findNumber(listingbox_selector) + 1); + window[id] = new rashEditor.Listing(id); + window[id].add(); +}; + $(document).ready(function () { /* START .rash_inline */ diff --git a/sources/raje/app/js/editor/2_caret.js b/sources/raje/app/js/editor/2_caret.js index 014e3a1..db10617 100644 --- a/sources/raje/app/js/editor/2_caret.js +++ b/sources/raje/app/js/editor/2_caret.js @@ -26,7 +26,7 @@ caret = { }, checkIfInHeading: function () { - return $(window.getSelection().anchorNode).parents('h1,h2,h3').length; + return $(window.getSelection().anchorNode).parents('h1,h2,h3,h4,h5,h6').length; }, checkIfBorder: function () { diff --git a/sources/raje/app/js/editor/3_const.js b/sources/raje/app/js/editor/3_const.js index c80fd0b..0d6de61 100644 --- a/sources/raje/app/js/editor/3_const.js +++ b/sources/raje/app/js/editor/3_const.js @@ -14,3 +14,14 @@ const ZERO_SPACE = '​'; const ONE_SPACE = ' '; const messageDealer = 'div#messageDealer'; + +Array.prototype.indexOfContent = function (searchTerm) { + let index = -1; + for (var i = 0, len = this.length; i < len; i++) { + if (this[i].content == searchTerm) { + index = i; + break; + } + } + return index +} diff --git a/sources/raje/app/js/editor/4_raje.js b/sources/raje/app/js/editor/4_raje.js index be620f5..37b23c4 100644 --- a/sources/raje/app/js/editor/4_raje.js +++ b/sources/raje/app/js/editor/4_raje.js @@ -173,8 +173,11 @@ rashEditor = { let title = $(sel.anchorNode).parents('h1') - if (!$('h1.title small').length) - document.execCommand("insertHTML", false, `
${ZERO_SPACE}`) + if (!title.find('small').length) { + title.append(`
${ZERO_SPACE}`) + caret.moveStart(title.find('small')) + caret.move('character', 1) + } } }, @@ -331,6 +334,18 @@ rashEditor = { referenceables.append(formulas) } + if ($(`${rash_inline_selector} ${listingbox_selector}`).length) { + + let formulas = $(this.createCollapsable('Listings')) + + $(`${rash_inline_selector} figure:has(pre)`).each(function () { + let text = $(this).find('figcaption').text() + formulas.find('#listListings').append(`${text}`) + }) + + referenceables.append(formulas) + } + let references = $(this.createCollapsable('References')) references.find('#listReferences').append(`+ add new bibliographic reference`) @@ -384,11 +399,14 @@ rashEditor = { if (sel.isCollapsed) { document.execCommand("insertHTML", false, string); caret.moveStart($(`${element}[data-pointer]`)) - $(`${element}[data-pointer]`).removeAttr('data-pointer') + + caret.move('character', 1) if (isFormula) { caret.move('character', 2) } + + $(`${element}[data-pointer]`).removeAttr('data-pointer') } else { var range = sel.getRangeAt(0); @@ -659,8 +677,13 @@ rashEditor = { } else { - if (!node) - node = $('section[role="doc-endnotes"]>section:last-child') + if (!node) { + if ($('section[role="doc-endnotes"]>section').length) + node = $('section[role="doc-endnotes"]>section:last-child') + else + node = $('section[role="doc-endnotes"]>h1') + } + let getNextEndnote = function () { let max = -1 @@ -899,8 +922,19 @@ rashEditor = { if (undefined !== this.selection) { rangy.restoreSelection(this.selection); + let paragraph = $(rangy.getSelection().anchorNode).parents('p').first() + + let string + + if (paragraph.text().length != 0) { + string = `

\`\`${asciiFormula}\`\`

` + rashEditor.insertParagraph(paragraph[0]) + } + else + string = `

\`\`${asciiFormula}\`\`

` + // render formula - document.execCommand("insertHTML", false, "

\`\`" + asciiFormula + "\`\`

"); + document.execCommand("insertHTML", false, string); MathJax.Hub.Queue(["Typeset", MathJax.Hub]); //get mathml @@ -910,9 +944,25 @@ rashEditor = { captions() formulas() refreshReferences() + + caret.moveAfterNode($(`figure#${this.id} > p > span.cgen`)[0]) } }; - } + }, + + Listing: function (id) { + this.selection; + this.id = id; + + this.add = function () { + let sel = rangy.getSelection() + let string = '
' + if (sel && !sel.isCollapsed) + string = sel.toString() + document.execCommand("insertHTML", false, `
${ZERO_SPACE}${string}
Caption of the listing.
`); + captions() + } + }, /* END boxes */ }; diff --git a/sources/raje/app/js/editor/5_shortcuts.js b/sources/raje/app/js/editor/5_shortcuts.js index e12343e..f7f87e7 100644 --- a/sources/raje/app/js/editor/5_shortcuts.js +++ b/sources/raje/app/js/editor/5_shortcuts.js @@ -7,7 +7,7 @@ rashEditor. init = function () { // paste only text, without style - $(rash_inline_selector)[0].addEventListener("paste", function (e) { + $(document)[0].addEventListener("paste", function (e) { e.preventDefault(); @@ -34,6 +34,7 @@ rashEditor. return false }); + Mousetrap.bind('space', function (event) { var sel = rangy.getSelection() @@ -42,17 +43,12 @@ rashEditor. var parent = { reference: $(node).parents('a[href]:has(span.cgen),a[href]:has(sup.cgen)').last(), - endnote: $(node).parents('section[role="doc-endnote"]').last() } - if (!parent.endnote.length) { - if (parent.reference.length) { - rashEditor.exitInline(parent.reference) - return false - } + if (parent.reference.length) { + rashEditor.exitInline(parent.reference) + return false } - else - return true } }) @@ -103,6 +99,9 @@ rashEditor. //cross reference reference: $(node).parents('a[href]:has(span.cgen),a[href]:has(sup.cgen)').last(), + //headings + headings: $(node).parents('h1, h2, h3, h4, h5, h6').first(), + //inlines crossRef: $(node).parents('a.cgen').last(), code_inline: $(node).parents('code').last(), @@ -129,17 +128,22 @@ rashEditor. // header if (parent.subtitle.length) { - caret.getNextElement(parent.title) + if (parent.subtitle.text().length == 1) { + caret.getNextElement(parent.title) + parent.subtitle.prev('br').remove() + parent.subtitle.remove() + } + else + caret.getNextElement(parent.title) return false } else if (parent.title.length) { - caret.getNextElement(parent.title) - //rashEditor.header.insertSubTitle() + //caret.getNextElement(parent.title) + rashEditor.header.insertSubTitle() return false } else if (parent.author.name.length) { caret.getNextElement(parent.author.name) - //sel.move('character', 1) return false } else if (parent.author.email.length) { @@ -184,6 +188,13 @@ rashEditor. rashEditor.exitInline(parent.reference) } + //headings + else if (parent.headings.length) { + console.log(caret.checkIfBorder()) + if (caret.checkIfBorder() != 1) + return false + } + // inlines else if (parent.formula_inline.length) { if (parent.formula_inline.find('span[data-mathml]').length) @@ -232,7 +243,8 @@ rashEditor. /** endnotes */ else if (parent.endnote.length) { - rashEditor.insertEndnote($(node).parents('section[role="doc-endnote"]').last()) + rashEditor.insertParagraph(parent.paragraph[0]); + //rashEditor.insertEndnote($(node).parents('section[role="doc-endnote"]').last()) return false } @@ -298,6 +310,7 @@ rashEditor. if (parent.placeholderAffiliation.length) { parent.placeholderAffiliation.removeClass('placeholder') + parent.placeholderAffiliation.text('') } } }) @@ -309,7 +322,8 @@ rashEditor. var parent = { title: $(node).parents('h1.title').last(), pre: $(node).parents('pre').last(), - blockquote: $(node).parents('blockquote').last() + blockquote: $(node).parents('blockquote').last(), + headings: $(node).parents('h1, h2, h3, h4, h5, h6') } if (parent.title.length) { @@ -326,6 +340,10 @@ rashEditor. rashEditor.insertParagraph(parent.blockquote[0]) return false } + + else if (parent.headings.length) { + return false + } } }) diff --git a/sources/raje/app/js/editor/6_toolbar.js b/sources/raje/app/js/editor/6_toolbar.js index d9e6a13..60e95a3 100644 --- a/sources/raje/app/js/editor/6_toolbar.js +++ b/sources/raje/app/js/editor/6_toolbar.js @@ -111,6 +111,11 @@ function showNavbar() { + +
@@ -123,12 +128,12 @@ function showNavbar() {
  • Acknowledgement
  • -
  • Section 1.
  • -
  • Section 1.1.
  • -
  • Section 1.1.1.
  • -
  • Section 1.1.1.1.
  • -
  • Section 1.1.1.1.1.
  • -
  • Section 1.1.1.1.1.1.
  • +
  • Section 1.
  • +
  • Section 1.1.
  • +
  • Section 1.1.1.
  • +
  • Section 1.1.1.1.
  • +
  • Section 1.1.1.1.1.
  • +
  • Section 1.1.1.1.1.1.
  • @@ -239,6 +244,19 @@ function addTableModal() { $(this).find("input#rows").val(window[id].getRows()); $(this).find("input#cols").val(window[id].getCols()); + $(this).find("input#cols, input#rows").on('keypress', function (e) { + if (e.key == 'e') + e.preventDefault() + else if (e.key == ',') + e.preventDefault() + else if (e.key == '.') + e.preventDefault() + else if (e.key == '-') + e.preventDefault() + else if (e.key == '+') + e.preventDefault() + }) + $("button").removeClass("active"); if (window[id].hasTopHeading()) $(this).find("button#top").addClass("active"); @@ -253,8 +271,19 @@ function addTableModal() { $("#customizeTable").on("click", function (event) { event.preventDefault(); - window[id].addDelRows($("input#rows").val() - window[id].getRows()); - window[id].addDelCols($("input#cols").val() - window[id].getCols()); + + let inputRows, inputColumns + try { + inputRows = Number($("input#rows").val()) + inputColumns = Number($("input#cols").val()) + + window[id].addDelRows($("input#rows").val() - window[id].getRows()); + window[id].addDelCols($("input#cols").val() - window[id].getCols()); + } + catch (err) { + alert('Error, please type only numbers') + } + }); $("#top").on("click", function (event) { @@ -369,7 +398,7 @@ function addFormulaEditorModal(id) {
    - +
    @@ -860,14 +889,8 @@ function refreshToolbar() { //enable/disable clickable add section buttons in dropdown updateDropdown() - if (caret.checkIfInHeader()) { - $('nav#editNavbar .navbar-left button[title]').attr('disabled', true) - $('#sectionDropdown > button').addClass('disabled') - } - else { - $('nav#editNavbar .navbar-left button[title]').removeAttr('disabled') - $('#sectionDropdown > button').removeClass('disabled') - } + $('#editNavbar button').removeAttr('disabled') + $('#sectionDropdown > button').removeClass('disabled') // activate/deactivate strong button strong = $(sel.anchorNode).parents('strong, b').length > 0 @@ -891,14 +914,26 @@ function refreshToolbar() { ul = $(sel.anchorNode).parents('ul').length setButtonWithVar('#btnUnorderedList', ul) - //Disable behaviours + let figure = $(sel.anchorNode).parents('figure').length + disableButtonWithVar('#btnBoxTable, #btnBoxFormula, #btnBoxFigure', figure) + if (caret.checkIfInHeading()) { $('nav#editNavbar div[aria-label="Inline elements"] button, nav#editNavbar div[aria-label="Block elements"] button').attr('disabled', true) + $('#btnStrong, #btnEm, #btnInlineCode').removeAttr('disabled') + } - $('button#btnStrong').removeAttr('disabled') - $('button#btnEm').removeAttr('disabled') - $('button#btnInlineCode').removeAttr('disabled') + if ($(sel.anchorNode).parents('section[role="doc-bibliography"]').length) { + $('nav#editNavbar button').attr('disabled', true) + $('#btnLink').removeAttr('disabled') + } + + if (caret.checkIfInHeader()) { + $('#editNavbar button').attr('disabled', true) + $('#sectionDropdown > button').addClass('disabled') } + + //disableButtonWithVar('#btnStrong, #btnEm, #btnInlineCode', caret.checkIfInHeading()) + } } @@ -909,6 +944,13 @@ function setButtonWithVar(id, variable) { $(id).removeClass('active') } +function disableButtonWithVar(id, variable) { + if (variable) + $(id).attr('disabled', true) + else + $(id).removeAttr('disabled') +} + function showAuthorSettings() { $('address.lead.authors').each(function () { diff --git a/sources/raje/app/js/editor/7_derash.js b/sources/raje/app/js/editor/7_derash.js index 190265b..286c069 100644 --- a/sources/raje/app/js/editor/7_derash.js +++ b/sources/raje/app/js/editor/7_derash.js @@ -57,6 +57,8 @@ function derashHeader() { /* authors */ + let affiliations = [] + $('header address.lead.authors').each(function () { let email = $(this).find('code.email').text() @@ -66,13 +68,20 @@ function derashHeader() { $(this).find('span.affiliation').each(function (index) { - let affiliations = [], link = $() + console.log($(this).text()) + console.log(affiliations.indexOfContent($(this).text())) + + if (affiliations.indexOfContent($(this).text()) > -1) { + let pos = affiliations.indexOfContent($(this).text()) + index = parseInt(affiliations[pos].index.replace('affiliation', '')) + + } else { + index = affiliations.length + 1 + } //create new affiliation let affiliation = { - 'index': typeof $('meta[content="' + $(this).text() + '"]').attr('about') === 'undefined' ? - 'affiliation' + index : - $('meta[content="' + $(this).text() + '"]').attr('about'), + 'index': `affiliation${index}`, 'content': $(this).text() } @@ -87,13 +96,13 @@ function derashHeader() { if (affiliations[i].index == affiliation.index) affiliations.pop() } - - //check if affiliation already exists - for (var i = 0; i < affiliations.length; i++) { - head.append(``) - } }) }) + + for (var i = 0; i < affiliations.length; i++) { + head.append(``) + } + /* /End authors */ /** keywords */ @@ -142,11 +151,18 @@ function derashBody() { body.append(section) }) + // Formula block body.find('span[data-mathml]').each(function () { let mathml = $(this).data('mathml') $(this).parents('figure').html(`

    ${mathml}

    `) }) + // Formula inline + body.find('span[data-formula]:has(span[data-mathml])').each(function () { + let mathml = $(this).find('span[data-mathml]').data('mathml') + $(this).html(`${mathml}`) + }) + body.find('tbody').each(function () { }) /** End sections */ diff --git a/sources/raje/app/js/raje.js b/sources/raje/app/js/raje.js index fae8852..81f090d 100644 --- a/sources/raje/app/js/raje.js +++ b/sources/raje/app/js/raje.js @@ -63,6 +63,11 @@ jQuery.fn.extend({ setEditState() }) + $(this).bind('dragover drop', function (event) { + event.preventDefault(); + return false; + }); + /** * Get when call event to disable or activate toolbar elements */ @@ -180,6 +185,12 @@ window.handleFormulaBox = function () { window[id].showModal(); }; +window.handleListingBox = function () { + var id = 'table_' + ($(this).findNumber(listingbox_selector) + 1); + window[id] = new rashEditor.Listing(id); + window[id].add(); +}; + $(document).ready(function () { /* START .rash_inline */ @@ -331,7 +342,7 @@ caret = { }, checkIfInHeading: function () { - return $(window.getSelection().anchorNode).parents('h1,h2,h3').length; + return $(window.getSelection().anchorNode).parents('h1,h2,h3,h4,h5,h6').length; }, checkIfBorder: function () { @@ -526,6 +537,17 @@ const ONE_SPACE = ' '; const messageDealer = 'div#messageDealer'; +Array.prototype.indexOfContent = function (searchTerm) { + let index = -1; + for (var i = 0, len = this.length; i < len; i++) { + if (this[i].content == searchTerm) { + index = i; + break; + } + } + return index +} + rashEditor = { /* und/redo */ @@ -701,8 +723,11 @@ rashEditor = { let title = $(sel.anchorNode).parents('h1') - if (!$('h1.title small').length) - document.execCommand("insertHTML", false, `
    ${ZERO_SPACE}`) + if (!title.find('small').length) { + title.append(`
    ${ZERO_SPACE}`) + caret.moveStart(title.find('small')) + caret.move('character', 1) + } } }, @@ -859,6 +884,18 @@ rashEditor = { referenceables.append(formulas) } + if ($(`${rash_inline_selector} ${listingbox_selector}`).length) { + + let formulas = $(this.createCollapsable('Listings')) + + $(`${rash_inline_selector} figure:has(pre)`).each(function () { + let text = $(this).find('figcaption').text() + formulas.find('#listListings').append(`${text}`) + }) + + referenceables.append(formulas) + } + let references = $(this.createCollapsable('References')) references.find('#listReferences').append(`+ add new bibliographic reference`) @@ -912,11 +949,14 @@ rashEditor = { if (sel.isCollapsed) { document.execCommand("insertHTML", false, string); caret.moveStart($(`${element}[data-pointer]`)) - $(`${element}[data-pointer]`).removeAttr('data-pointer') + + caret.move('character', 1) if (isFormula) { caret.move('character', 2) } + + $(`${element}[data-pointer]`).removeAttr('data-pointer') } else { var range = sel.getRangeAt(0); @@ -1187,8 +1227,13 @@ rashEditor = { } else { - if (!node) - node = $('section[role="doc-endnotes"]>section:last-child') + if (!node) { + if ($('section[role="doc-endnotes"]>section').length) + node = $('section[role="doc-endnotes"]>section:last-child') + else + node = $('section[role="doc-endnotes"]>h1') + } + let getNextEndnote = function () { let max = -1 @@ -1427,8 +1472,19 @@ rashEditor = { if (undefined !== this.selection) { rangy.restoreSelection(this.selection); + let paragraph = $(rangy.getSelection().anchorNode).parents('p').first() + + let string + + if (paragraph.text().length != 0) { + string = `

    \`\`${asciiFormula}\`\`

    ` + rashEditor.insertParagraph(paragraph[0]) + } + else + string = `

    \`\`${asciiFormula}\`\`

    ` + // render formula - document.execCommand("insertHTML", false, "

    \`\`" + asciiFormula + "\`\`

    "); + document.execCommand("insertHTML", false, string); MathJax.Hub.Queue(["Typeset", MathJax.Hub]); //get mathml @@ -1438,9 +1494,25 @@ rashEditor = { captions() formulas() refreshReferences() + + caret.moveAfterNode($(`figure#${this.id} > p > span.cgen`)[0]) } }; - } + }, + + Listing: function (id) { + this.selection; + this.id = id; + + this.add = function () { + let sel = rangy.getSelection() + let string = '
    ' + if (sel && !sel.isCollapsed) + string = sel.toString() + document.execCommand("insertHTML", false, `
    ${ZERO_SPACE}${string}
    Caption of the listing.
    `); + captions() + } + }, /* END boxes */ }; @@ -1454,7 +1526,7 @@ rashEditor. init = function () { // paste only text, without style - $(rash_inline_selector)[0].addEventListener("paste", function (e) { + $(document)[0].addEventListener("paste", function (e) { e.preventDefault(); @@ -1481,6 +1553,7 @@ rashEditor. return false }); + Mousetrap.bind('space', function (event) { var sel = rangy.getSelection() @@ -1489,17 +1562,12 @@ rashEditor. var parent = { reference: $(node).parents('a[href]:has(span.cgen),a[href]:has(sup.cgen)').last(), - endnote: $(node).parents('section[role="doc-endnote"]').last() } - if (!parent.endnote.length) { - if (parent.reference.length) { - rashEditor.exitInline(parent.reference) - return false - } + if (parent.reference.length) { + rashEditor.exitInline(parent.reference) + return false } - else - return true } }) @@ -1550,6 +1618,9 @@ rashEditor. //cross reference reference: $(node).parents('a[href]:has(span.cgen),a[href]:has(sup.cgen)').last(), + //headings + headings: $(node).parents('h1, h2, h3, h4, h5, h6').first(), + //inlines crossRef: $(node).parents('a.cgen').last(), code_inline: $(node).parents('code').last(), @@ -1576,17 +1647,22 @@ rashEditor. // header if (parent.subtitle.length) { - caret.getNextElement(parent.title) + if (parent.subtitle.text().length == 1) { + caret.getNextElement(parent.title) + parent.subtitle.prev('br').remove() + parent.subtitle.remove() + } + else + caret.getNextElement(parent.title) return false } else if (parent.title.length) { - caret.getNextElement(parent.title) - //rashEditor.header.insertSubTitle() + //caret.getNextElement(parent.title) + rashEditor.header.insertSubTitle() return false } else if (parent.author.name.length) { caret.getNextElement(parent.author.name) - //sel.move('character', 1) return false } else if (parent.author.email.length) { @@ -1631,6 +1707,13 @@ rashEditor. rashEditor.exitInline(parent.reference) } + //headings + else if (parent.headings.length) { + console.log(caret.checkIfBorder()) + if (caret.checkIfBorder() != 1) + return false + } + // inlines else if (parent.formula_inline.length) { if (parent.formula_inline.find('span[data-mathml]').length) @@ -1679,7 +1762,8 @@ rashEditor. /** endnotes */ else if (parent.endnote.length) { - rashEditor.insertEndnote($(node).parents('section[role="doc-endnote"]').last()) + rashEditor.insertParagraph(parent.paragraph[0]); + //rashEditor.insertEndnote($(node).parents('section[role="doc-endnote"]').last()) return false } @@ -1745,6 +1829,7 @@ rashEditor. if (parent.placeholderAffiliation.length) { parent.placeholderAffiliation.removeClass('placeholder') + parent.placeholderAffiliation.text('') } } }) @@ -1756,7 +1841,8 @@ rashEditor. var parent = { title: $(node).parents('h1.title').last(), pre: $(node).parents('pre').last(), - blockquote: $(node).parents('blockquote').last() + blockquote: $(node).parents('blockquote').last(), + headings: $(node).parents('h1, h2, h3, h4, h5, h6') } if (parent.title.length) { @@ -1773,6 +1859,10 @@ rashEditor. rashEditor.insertParagraph(parent.blockquote[0]) return false } + + else if (parent.headings.length) { + return false + } } }) @@ -1952,6 +2042,11 @@ function showNavbar() { + +
    @@ -1964,12 +2059,12 @@ function showNavbar() {
  • Acknowledgement
  • -
  • Section 1.
  • -
  • Section 1.1.
  • -
  • Section 1.1.1.
  • -
  • Section 1.1.1.1.
  • -
  • Section 1.1.1.1.1.
  • -
  • Section 1.1.1.1.1.1.
  • +
  • Section 1.
  • +
  • Section 1.1.
  • +
  • Section 1.1.1.
  • +
  • Section 1.1.1.1.
  • +
  • Section 1.1.1.1.1.
  • +
  • Section 1.1.1.1.1.1.
  • @@ -2080,6 +2175,19 @@ function addTableModal() { $(this).find("input#rows").val(window[id].getRows()); $(this).find("input#cols").val(window[id].getCols()); + $(this).find("input#cols, input#rows").on('keypress', function (e) { + if (e.key == 'e') + e.preventDefault() + else if (e.key == ',') + e.preventDefault() + else if (e.key == '.') + e.preventDefault() + else if (e.key == '-') + e.preventDefault() + else if (e.key == '+') + e.preventDefault() + }) + $("button").removeClass("active"); if (window[id].hasTopHeading()) $(this).find("button#top").addClass("active"); @@ -2094,8 +2202,19 @@ function addTableModal() { $("#customizeTable").on("click", function (event) { event.preventDefault(); - window[id].addDelRows($("input#rows").val() - window[id].getRows()); - window[id].addDelCols($("input#cols").val() - window[id].getCols()); + + let inputRows, inputColumns + try { + inputRows = Number($("input#rows").val()) + inputColumns = Number($("input#cols").val()) + + window[id].addDelRows($("input#rows").val() - window[id].getRows()); + window[id].addDelCols($("input#cols").val() - window[id].getCols()); + } + catch (err) { + alert('Error, please type only numbers') + } + }); $("#top").on("click", function (event) { @@ -2210,7 +2329,7 @@ function addFormulaEditorModal(id) {
    - +
    @@ -2701,14 +2820,8 @@ function refreshToolbar() { //enable/disable clickable add section buttons in dropdown updateDropdown() - if (caret.checkIfInHeader()) { - $('nav#editNavbar .navbar-left button[title]').attr('disabled', true) - $('#sectionDropdown > button').addClass('disabled') - } - else { - $('nav#editNavbar .navbar-left button[title]').removeAttr('disabled') - $('#sectionDropdown > button').removeClass('disabled') - } + $('#editNavbar button').removeAttr('disabled') + $('#sectionDropdown > button').removeClass('disabled') // activate/deactivate strong button strong = $(sel.anchorNode).parents('strong, b').length > 0 @@ -2732,14 +2845,26 @@ function refreshToolbar() { ul = $(sel.anchorNode).parents('ul').length setButtonWithVar('#btnUnorderedList', ul) - //Disable behaviours + let figure = $(sel.anchorNode).parents('figure').length + disableButtonWithVar('#btnBoxTable, #btnBoxFormula, #btnBoxFigure', figure) + if (caret.checkIfInHeading()) { $('nav#editNavbar div[aria-label="Inline elements"] button, nav#editNavbar div[aria-label="Block elements"] button').attr('disabled', true) + $('#btnStrong, #btnEm, #btnInlineCode').removeAttr('disabled') + } - $('button#btnStrong').removeAttr('disabled') - $('button#btnEm').removeAttr('disabled') - $('button#btnInlineCode').removeAttr('disabled') + if ($(sel.anchorNode).parents('section[role="doc-bibliography"]').length) { + $('nav#editNavbar button').attr('disabled', true) + $('#btnLink').removeAttr('disabled') + } + + if (caret.checkIfInHeader()) { + $('#editNavbar button').attr('disabled', true) + $('#sectionDropdown > button').addClass('disabled') } + + //disableButtonWithVar('#btnStrong, #btnEm, #btnInlineCode', caret.checkIfInHeading()) + } } @@ -2750,6 +2875,13 @@ function setButtonWithVar(id, variable) { $(id).removeClass('active') } +function disableButtonWithVar(id, variable) { + if (variable) + $(id).attr('disabled', true) + else + $(id).removeAttr('disabled') +} + function showAuthorSettings() { $('address.lead.authors').each(function () { @@ -2839,6 +2971,8 @@ function derashHeader() { /* authors */ + let affiliations = [] + $('header address.lead.authors').each(function () { let email = $(this).find('code.email').text() @@ -2848,13 +2982,20 @@ function derashHeader() { $(this).find('span.affiliation').each(function (index) { - let affiliations = [], link = $() + console.log($(this).text()) + console.log(affiliations.indexOfContent($(this).text())) + + if (affiliations.indexOfContent($(this).text()) > -1) { + let pos = affiliations.indexOfContent($(this).text()) + index = parseInt(affiliations[pos].index.replace('affiliation', '')) + + } else { + index = affiliations.length + 1 + } //create new affiliation let affiliation = { - 'index': typeof $('meta[content="' + $(this).text() + '"]').attr('about') === 'undefined' ? - 'affiliation' + index : - $('meta[content="' + $(this).text() + '"]').attr('about'), + 'index': `affiliation${index}`, 'content': $(this).text() } @@ -2869,13 +3010,13 @@ function derashHeader() { if (affiliations[i].index == affiliation.index) affiliations.pop() } - - //check if affiliation already exists - for (var i = 0; i < affiliations.length; i++) { - head.append(``) - } }) }) + + for (var i = 0; i < affiliations.length; i++) { + head.append(``) + } + /* /End authors */ /** keywords */ @@ -2924,11 +3065,18 @@ function derashBody() { body.append(section) }) + // Formula block body.find('span[data-mathml]').each(function () { let mathml = $(this).data('mathml') $(this).parents('figure').html(`

    ${mathml}

    `) }) + // Formula inline + body.find('span[data-formula]:has(span[data-mathml])').each(function () { + let mathml = $(this).find('span[data-mathml]').data('mathml') + $(this).html(`${mathml}`) + }) + body.find('tbody').each(function () { }) /** End sections */ diff --git a/sources/raje/app/main.js b/sources/raje/app/main.js index 0006c82..d39e74f 100644 --- a/sources/raje/app/main.js +++ b/sources/raje/app/main.js @@ -54,9 +54,9 @@ function createWindow() { setSplashMenu() - fs.createReadStream('js/raje.js').pipe(fs.createWriteStream(`/Users/spino93/Desktop/prova/js/raje.js`)) + //fs.createReadStream('js/raje.js').pipe(fs.createWriteStream(`/Users/spino93/Desktop/test/js/raje.js`)) //fs.createReadStream('js/rash.js').pipe(fs.createWriteStream(`/Users/spino93/Desktop/dummylol/js/rash.js`)) - //fs.createReadStream('css/rash-inline.css').pipe(fs.createWriteStream(`/Users/spino93/Desktop/prova/css/rash-inline.css`)) + //fs.createReadStream('css/rash-inline.css').pipe(fs.createWriteStream(`/Users/spino93/Desktop/test/css/rash-inline.css`)) //fs.createReadStream('css/rash.css').pipe(fs.createWriteStream(`/Users/spino93/Desktop/spinaci-rajedoc2016/css/rash.css`)) mainWindow.on('close', (event) => { @@ -551,8 +551,11 @@ function setEditorMenu() { if (err) throw err let template = [menuUtils.File, menuUtils.Edit, menuUtils.RASH, menu, menuUtils.Help] - if (process.platform === 'darwin') + if (process.platform === 'darwin') { + systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true) + systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', true) template.unshift(menuUtils.MacOSX) + } updateMenu(template) }) @@ -583,9 +586,6 @@ function chooseGithub(callback) { }) } -systemPreferences.setUserDefault('NSDisabledDictationMenuItem', 'boolean', true) -systemPreferences.setUserDefault('NSDisabledCharacterPaletteMenuItem', 'boolean', true) - const menuUtils = { File: { label: 'File', @@ -638,26 +638,6 @@ const menuUtils = { }, { type: 'separator' - }, - { - label: 'Insert Title', - click() { } - }, - { - label: 'Insert Author', - click() { mainWindow.webContents.send('addNewAuthor') } - }, - { - label: 'Insert ACM Subject Category', - click() { - mainWindow.webContents.send('insertSubject') - } - }, - { - label: 'Insert Keyword', - click() { - mainWindow.webContents.send('insertKeyword') - } } ] }, @@ -682,8 +662,35 @@ const menuUtils = { type: 'separator' }, { - label: 'Show Rawgit', - enabled: false + label: 'Insert Title', + click() { } + }, + { + label: 'Insert Author', + click() { mainWindow.webContents.send('addNewAuthor') } + }, + { + label: 'Insert ACM Subject Category', + click() { + mainWindow.webContents.send('insertSubject') + } + }, + { + label: 'Insert Keyword', + click() { + mainWindow.webContents.send('insertKeyword') + } + }, + { + label: 'Toggle Change Authors Position', + click() { + if (reorganizingAuthors) + mainWindow.webContents.send('unsetReorganizeAuthors') + else + mainWindow.webContents.send('setReorganizeAuthors') + + reorganizingAuthors = !reorganizingAuthors + } }, { type: 'separator' diff --git a/sources/raje/app/main/splash.js b/sources/raje/app/main/splash.js index 9be59db..dbd7171 100644 --- a/sources/raje/app/main/splash.js +++ b/sources/raje/app/main/splash.js @@ -13,6 +13,9 @@ module.exports = { * */ initFolder: function (mainWindow, settings) { + settings.title = settings.title.replace(/\s\s+/g, ' ') + settings.title = settings.title.replace(' ', '_') + let folderPath = `${settings.path}/${settings.title}` let articlePath = `${folderPath}/${settings.title}.html` let toSaveSettings = { @@ -74,6 +77,7 @@ module.exports = { openEditorWindow: function (mainWindow, articlePath, title) { mainWindow.loadURL(`file://${articlePath}`) mainWindow.maximize() + //mainWindow.webContents.toggleDevTools() if (title) mainWindow.webContents.send('updateTitle', title) }, diff --git a/sources/raje/app/splash.html b/sources/raje/app/splash.html index 31ddad2..2aa1031 100644 --- a/sources/raje/app/splash.html +++ b/sources/raje/app/splash.html @@ -41,7 +41,7 @@
    diff --git a/tools/RAJE/RAJE-darwin-x64.zip b/tools/RAJE/RAJE-darwin-x64.zip new file mode 100644 index 0000000..e451269 Binary files /dev/null and b/tools/RAJE/RAJE-darwin-x64.zip differ diff --git a/tools/RAJE/RAJE-linux-x64.zip b/tools/RAJE/RAJE-linux-x64.zip new file mode 100644 index 0000000..d0bbe90 Binary files /dev/null and b/tools/RAJE/RAJE-linux-x64.zip differ diff --git a/tools/RAJE/RAJE-win32-x64.zip b/tools/RAJE/RAJE-win32-x64.zip new file mode 100644 index 0000000..2b1a6e5 Binary files /dev/null and b/tools/RAJE/RAJE-win32-x64.zip differ