Browse Source

Enable refresh in setContent of the CodeMirrorEditor

pull/1800/head
Artur Arseniev 7 years ago
parent
commit
2803ace2fc
  1. 10
      dist/grapes.js
  2. 4
      dist/grapes.min.js
  3. 2
      dist/grapes.min.js.map
  4. 2
      package-lock.json
  5. 2
      package.json
  6. 21
      src/code_manager/model/CodeMirrorEditor.js

10
dist/grapes.js

@ -38527,7 +38527,7 @@ module.exports = function () {
plugins: plugins,
// Will be replaced on build
version: '0.14.53',
version: '0.14.54',
/**
* Initialize the editor with passed options
@ -38723,6 +38723,7 @@ module.exports = function () {
* @param {string} id Keymap id
* @param {string} keys Keymap keys, eg. `ctrl+a`, `⌘+z, ctrl+z`
* @param {Function|string} handler Keymap handler, might be a function
* @param {Object} [opts={}] Options
* @return {Object} Added keymap
* or just a command id as a string
* @example
@ -38739,6 +38740,8 @@ module.exports = function () {
* })
*/
add: function add(id, keys, handler) {
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var em = this.em;
var editor = em.getEditor();
var cmd = em.get('Commands');
@ -38749,9 +38752,10 @@ module.exports = function () {
keymaps[id] = keymap;
keymaster(keys, function (e, h) {
// It's safer putting handlers resolution inside the callback
var opt = { event: e, h: h };
handler = (0, _underscore.isString)(handler) ? cmd.get(handler) : handler;
!handler.avoidPrevent && canvas.getCanvasView().preventDefault(e);
(typeof handler === 'undefined' ? 'undefined' : _typeof(handler)) == 'object' ? handler.run(editor) : handler(editor);
opts.prevent && canvas.getCanvasView().preventDefault(e);
(typeof handler === 'undefined' ? 'undefined' : _typeof(handler)) == 'object' ? handler.run(editor, 0, opt) : handler(editor, 0, opt);
var args = [id, h.shortcut, e];
em.trigger.apply(em, ['keymap:emit'].concat(args));
em.trigger.apply(em, ['keymap:emit:' + id].concat(args));

4
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
dist/grapes.min.js.map

File diff suppressed because one or more lines are too long

2
package-lock.json

@ -1,6 +1,6 @@
{
"name": "grapesjs",
"version": "0.14.53",
"version": "0.14.54",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

2
package.json

@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.14.53",
"version": "0.14.54",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",

21
src/code_manager/model/CodeMirrorEditor.js

@ -75,16 +75,17 @@ module.exports = Backbone.Model.extend({
},
/** @inheritdoc */
setContent(v) {
if (!this.editor) return;
this.editor.setValue(v);
if (this.editor.autoFormatRange) {
CodeMirror.commands.selectAll(this.editor);
this.editor.autoFormatRange(
this.editor.getCursor(true),
this.editor.getCursor(false)
);
CodeMirror.commands.goDocStart(this.editor);
setContent(v, opts = {}) {
const { editor } = this;
if (!editor) return;
editor.setValue(v);
if (editor.autoFormatRange) {
CodeMirror.commands.selectAll(editor);
editor.autoFormatRange(editor.getCursor(true), editor.getCursor(false));
CodeMirror.commands.goDocStart(editor);
}
!opts.noRefresh && setTimeout(() => this.refresh());
}
});

Loading…
Cancel
Save