Skip to content

Commit

Permalink
Merge branch 'master' into rexagod_atwho
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Jan 18, 2019
2 parents 6d5288c + 1584378 commit 0628de2
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,6 +1,6 @@
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

* [ ] tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with `rake test`
* [ ] tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with `grunt jasmine`
* [ ] code is in uniquely-named feature branch and has no merge conflicts
* [ ] PR is descriptively titled
* [ ] PR body includes `fixes #0000`-style reference to original issue #
Expand All @@ -14,4 +14,4 @@ Please be sure you've reviewed our contribution guidelines at https://publiclab.

We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays.

Thanks!
Thanks!
15 changes: 15 additions & 0 deletions Gruntfile.js
Expand Up @@ -27,6 +27,17 @@ module.exports = function(grunt) {
'src/PublicLab.Editor.js'
],
dest: 'dist/PublicLab.Editor.js'
},
debug: {
options : {
browserifyOptions: {
debug: true
}
},
src: [
'src/PublicLab.Editor.js'
],
dest: 'dist/PublicLab.Editor.js'
}
},

Expand Down Expand Up @@ -63,6 +74,10 @@ module.exports = function(grunt) {
'browserify:dist'
]);

grunt.registerTask('debug', [
'browserify:debug'
]);

grunt.loadNpmTasks('grunt-contrib-jasmine');

};
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -100,6 +100,8 @@ PublicLab.Editor uses grunt - the javascript task runner for compilation of the

Make changes to the files in the `/src/` directory, then run `grunt build` to compile into `/dist/PublicLab.Editor.js`. This will use `grunt-browserify` to concatenate and include any node modules named in `require()` statements. You'll then be able to try it out in `/examples/index.html`. Run `grunt` and leave it running to build as you go.

You can also run `grunt debug` to have *grunt-browserify* to include Source Maps for easy debugging. This way you can locate the module from where the error is generating. This is for use in development only.


## Setup

Expand Down Expand Up @@ -146,6 +148,17 @@ These used to be compiled into `PublicLab.Editor` but are now external so that `

PublicLab.Editor expects a response from the server upon sending a request to `destination` that is a URL which it will follow.

### Creating a mock server

* Testing image upload and other features that depend on an interactive server is difficult with just a basic one-line webserver. Instead, you can set up the `plots2` project as explained here to see the Editor working interactively while you test out those features.

* Clone [`plots2`](https://github.com/publiclab/plots2#standard-installation) and follow the [Standard Installation](https://github.com/publiclab/plots2#standard-installation) instructions to run it on your local server.
* Now in `plots2/package.json#` at `line 62`, replace this line with `"publiclab-editor": "file:..<path>"` where `<path>` is path of your cloned `PublicLab.Editor` repo folder
* Now with `passenger start` you can access the Editor at `localhost:3000/post`. Make changes in Editor's source code and run `grunt build` or `grunt debug` to bundle all files. Then run `yarn install --force` in plots2 repo to view changes on server.
* For reflecting HTML changes use `plots2/app/views/editor/rich.html.erb` instead of example.html. They both have same sturcture.
* For reflecting the changes on the local server need to run `yarn install --force` and refresh your page.



****

Expand Down
1 change: 1 addition & 0 deletions dist/PublicLab.Editor.css
Expand Up @@ -155,6 +155,7 @@ textarea.ple-textarea {
.wk-prompt {
border-radius: 10px;
padding: 20px;
z-index: 2;
}

/* Following may be removed if this is resolved:
Expand Down
8 changes: 8 additions & 0 deletions dist/PublicLab.Editor.js
Expand Up @@ -22154,6 +22154,14 @@ module.exports = PublicLab.RichTextModule = PublicLab.Module.extend({
}
});

crossvent.add(_module.wysiwyg.textarea, 'keyup', function (e) {
_editor.validate();
var regexp= /[\*]{2}[\s]{0,1}[\n]+[\#]{3}[^\P{P}*]+[\*]{2}/;
if (_module.wysiwyg.mode == "markdown" && _module.value().match(regexp)) {
_module.value(_module.value().match(regexp)[0].substr(3, _module.value().match(regexp)[0].length-5))
}
});

// 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
21 changes: 21 additions & 0 deletions spec/javascripts/rich_text_module_spec.js
Expand Up @@ -114,4 +114,25 @@ describe("RichTextModule", function() {
});


it("displays alert for empty bold tags",function() {

var enter = jQuery.Event("keydown", {keyCode:13})

var temp_el = module.textarea

module.setMode('markdown');

module.textarea.innerHTML = '**';

$(temp_el).trigger(enter)

module.textarea.innerHTML = '**';

$(temp_el).trigger(enter)

expect($('.invalid-bold-tags-warning').length).not.toBeNull();

});


});
12 changes: 12 additions & 0 deletions src/modules/PublicLab.RichTextModule.js
Expand Up @@ -252,6 +252,18 @@ module.exports = PublicLab.RichTextModule = PublicLab.Module.extend({
}
});

crossvent.add(_module.wysiwyg.textarea, 'keyup', function (e) {
_editor.validate();
var regexp= /[\*]{2}[\s]{0,1}[\n]+[\#]+[^\P{P}*]+[\*]{2}/;
//checks for the following pattern
//<double asterisks><zero or one space>
//<atleast one new lines>
//<atleast one hash><include atleast one characters that is NOT an asterisk><double asterisks>
if (_module.wysiwyg.mode == "markdown" && _module.value().match(regexp)) {
_module.value(_module.value().match(regexp)[0].substr(3, _module.value().match(regexp)[0].length-5))
}
});

// 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 0628de2

Please sign in to comment.