Skip to content

Commit

Permalink
PL.Editor #162 Filter empty bold tags and instruct (#198)
Browse files Browse the repository at this point in the history
* PL.Editor #162

* Improve on #198
  • Loading branch information
rexagod authored and jywarren committed Jan 3, 2019
1 parent 7da18f6 commit b04e151
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dist/PublicLab.Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15696,6 +15696,7 @@ module.exports = tokenizeLinks;
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
function (config) {
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));

}
);

Expand Down Expand Up @@ -16210,6 +16211,7 @@ module.exports = tokenizeLinks;
this._isUTC = true;
if (localAdjust != null) {
this.add(localAdjust, 'm');

}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
Expand Down Expand Up @@ -16294,6 +16296,7 @@ module.exports = tokenizeLinks;

var c = {};


copyConfig(c, this);
c = prepareConfig(c);

Expand Down Expand Up @@ -16336,6 +16339,7 @@ module.exports = tokenizeLinks;
ret,
diffRes;


if (isDuration(input)) {
duration = {
ms : input._milliseconds,
Expand Down Expand Up @@ -17499,6 +17503,7 @@ module.exports = tokenizeLinks;
var months;
var milliseconds = this._milliseconds;


units = normalizeUnits(units);

if (units === 'month' || units === 'year') {
Expand Down Expand Up @@ -17678,6 +17683,7 @@ module.exports = tokenizeLinks;
return this.localeData().invalidDate();
}


var seconds = abs$1(this._milliseconds) / 1000;
var days = abs$1(this._days);
var months = abs$1(this._months);
Expand Down Expand Up @@ -23747,6 +23753,21 @@ module.exports = PublicLab.RichTextModule = PublicLab.Module.extend({
}
});

crossvent.add(_module.wysiwyg.textarea, 'keyup', function (e) {
_editor.validate();
var regexp= /\*\*[\n]+\*\*/g;
var timestamp = Date.now()
if (_module.wysiwyg.mode == "markdown" && _module.value().match(regexp) && $('.invalid-bold-tags-warning').length === 0) {
var message = "Invalid input: Please remove all invalid bold tags like the ones below:<br><br>**<br>**";
_module.wysiwyg.textarea.innerHTML = (_module.wysiwyg.textarea.innerHTML).replace(regexp,'');
$(_module.wysiwyg.textarea).after("<div id='scrollpointBold_"+timestamp+"' class='invalid-bold-tags-warning alert alert-warning'>" + message + "</div>");
var refer = "#scrollpointBold_" + timestamp
$('html, body').animate({
scrollTop: $(refer).offset().top
}, 2000);
}
});

// once woofmark's done with the textarea, this is triggered
// using woofmark's special event system, crossvent
// -- move this into the Woofmark adapter initializer
Expand Down
15 changes: 15 additions & 0 deletions src/modules/PublicLab.RichTextModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ module.exports = PublicLab.RichTextModule = PublicLab.Module.extend({
}
});

crossvent.add(_module.wysiwyg.textarea, 'keyup', function (e) {
_editor.validate();
var regexp= /\*\*[\n]+\*\*/g;
var timestamp = Date.now()
if (_module.wysiwyg.mode == "markdown" && _module.value().match(regexp) && $('.invalid-bold-tags-warning').length === 0) {
var message = "Invalid input: Please remove all invalid bold tags like the ones below:<br><br>**<br>**";
_module.wysiwyg.textarea.innerHTML = (_module.wysiwyg.textarea.innerHTML).replace(regexp,'');
$(_module.wysiwyg.textarea).after("<div id='scrollpointBold_"+timestamp+"' class='invalid-bold-tags-warning alert alert-warning'>" + message + "</div>");
var refer = "#scrollpointBold_" + timestamp
$('html, body').animate({
scrollTop: $(refer).offset().top
}, 2000);
}
});

// once woofmark's done with the textarea, this is triggered
// using woofmark's special event system, crossvent
// -- move this into the Woofmark adapter initializer
Expand Down

0 comments on commit b04e151

Please sign in to comment.