Skip to content

Commit

Permalink
changes to the dist folder after build
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyaa-s committed Jun 6, 2020
1 parent d1cd2fa commit 1469be3
Showing 1 changed file with 119 additions and 12 deletions.
131 changes: 119 additions & 12 deletions dist/PublicLab.Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19065,6 +19065,7 @@ var strings = require('../strings');
function boldOrItalic (chunks, type) {
var rnewlines = /\n{2,}/g;
var starCount = type === 'bold' ? 2 : 1;

chunks.trim();
chunks.selection = chunks.selection.replace(rnewlines, '\n');

Expand All @@ -19087,7 +19088,6 @@ function boldOrItalic (chunks, type) {
markup = starCount === 1 ? '*' : '**';
chunks.before = chunks.before + markup;
chunks.after = markup + chunks.after;

}
}

Expand Down Expand Up @@ -21651,7 +21651,8 @@ module.exports = {
module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({

init: function(_editor, options) {


var dragImageI = document.getElementById("mainImage");
var _module = this;

_module.key = 'main_image_url';
Expand Down Expand Up @@ -21778,6 +21779,10 @@ module.exports = PublicLab.MainImageModule = PublicLab.Module.extend({
progressall: function (e, data) {

var progress = parseInt(data.loaded / data.total * 100, 10);

// For hiding the HTML "Drag an image here to upload." after uploading image.
dragImageI.innerHTML = "";

_module.el.find('.progress .progress-bar').css(
'width',
progress + '%'
Expand Down Expand Up @@ -21950,19 +21955,121 @@ module.exports = function initAutoCenter(_module, wysiwyg) {

$('.wk-commands .woofmark-command-autocenter').click(function() {
wysiwyg.runCommand(function(chunks,mode) {
if(mode == "wysiwyg") { //first convert then replace
chunks.selection = ("->"+chunks.selection+"<-")
var openingTag = /->/g;
var closingTag = /<-/g;
chunks.selection = chunks.selection.replace(openingTag,"<center>")
chunks.selection = chunks.selection.replace(closingTag,"</center>")
if(mode == "wysiwyg") {
var tag = "center";
var open = '<' + tag;
var close = '</' + tag.replace(/</g, '</');
var rleading = new RegExp(open + '( [^>]*)?>$', 'i');
var rtrailing = new RegExp('^' + close + '>', 'i');
var ropen = new RegExp(open + '( [^>]*)?>', 'ig');
var rclose = new RegExp(close + '( [^>]*)?>', 'ig');
chunks.trim();
// searches if selected text is center aligned and left aligns it
var trail = rtrailing.exec(chunks.before);
var lead = rleading.exec(chunks.after);
if (lead && trail) {
chunks.before = chunks.before.replace(rleading, '');
chunks.after = chunks.after.replace(rtrailing, '');
} else {
// searches if center tag is opened in selected text
var opened = ropen.test(chunks.selection);
if (opened) {
chunks.selection = chunks.selection.replace(ropen, '');
if (!surrounded(chunks, tag)) {
chunks.before += open + '>';
}
}
// searches if center tag is closed in selected text
var closed = rclose.test(chunks.selection);
if (closed) {
chunks.selection = chunks.selection.replace(rclose, '');
if (!surrounded(chunks, tag)) {
chunks.after = close + '>' + chunks.after;
}
}
if (surrounded(chunks, tag)) {
if (rleading.test(chunks.before)) {
chunks.before = chunks.before.replace(rleading, '');
} else {
chunks.before += close + '>';
}
if (rtrailing.test(chunks.after)) {
chunks.after = chunks.after.replace(rtrailing, '');
} else {
chunks.after = open + '>' + chunks.after;
}
} else if (!closebounded(chunks, tag)) {
chunks.after = close + '>' + chunks.after;
chunks.before += open + '>';
}
}

function closebounded (chunks, tag) {
var rcloseleft = new RegExp('</' + tag.replace(/</g, '</') + '>$', 'i');
var ropenright = new RegExp('^<' + tag + '(?: [^>]*)?>', 'i');
var bounded = rcloseleft.test(chunks.before) && ropenright.test(chunks.after);
if (bounded) {
chunks.before = chunks.before.replace(rcloseleft, '');
chunks.after = chunks.after.replace(ropenright, '');
}
return bounded;
}

function surrounded (chunks, tag) {
var ropen = new RegExp('<' + tag + '(?: [^>]*)?>', 'ig');
var rclose = new RegExp('<\/' + tag.replace(/</g, '</') + '>', 'ig');
var opensBefore = count(chunks.before, ropen);
var opensAfter = count(chunks.after, ropen);
var closesBefore = count(chunks.before, rclose);
var closesAfter = count(chunks.after, rclose);
var open = opensBefore - closesBefore > 0;
var close = closesAfter - opensAfter > 0;
return open && close;

function count (text, regex) {
var match = text.match(regex);
if (match) {
return match.length;
}
return 0;
}
}
else if (mode == "markdown") {
chunks.selection = _module.wysiwyg.parseHTML("<center>"+chunks.selection+"</center>")
} else if (mode == "markdown") {
var open = '->';
var close = '<-';
var rleading = new RegExp(open + '( [^>]*)?', 'i');
var rtrailing = new RegExp('^' + close, 'i');
var ropen = new RegExp(open + '( [^>]*)?', 'ig');
var rclose = new RegExp(close + '( [^>]*)?', 'ig');
chunks.trim();
var trail = rleading.exec(chunks.before);
var lead = rtrailing.exec(chunks.after);

if(trail && lead) {
chunks.before = chunks.before.replace(rleading, '');
chunks.after = chunks.after.replace(rtrailing, '');
} else {
var opened = ropen.test(chunks.selection);
var closed = rclose.test(chunks.selection);
if(opened || closed)
{
if (opened) {
chunks.selection = chunks.selection.replace(ropen, '');
chunks.before += open;
}
if (closed) {
chunks.selection = chunks.selection.replace(rclose, '');
chunks.after = close + chunks.after;
}
} else {
// adds center tag and parses into markdown
chunks.selection = _module.wysiwyg.parseHTML("<center>"+chunks.selection+"</center>")
}
}
}

_module.afterParse();
})
_module.afterParse();
})
})
}

Expand Down

0 comments on commit 1469be3

Please sign in to comment.