Load TinyMCE directly from lib/, disable ajax functions
This commit is contained in:
1
assets/js/lib/mailpoet_custom_fields
Symbolic link
1
assets/js/lib/mailpoet_custom_fields
Symbolic link
@@ -0,0 +1 @@
|
||||
../src/newsletter_editor/tinymce/mailpoet_custom_fields
|
1
assets/js/lib/tinymce
Symbolic link
1
assets/js/lib/tinymce
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../node_modules/tinymce
|
1
assets/js/lib/wplink
Symbolic link
1
assets/js/lib/wplink
Symbolic link
@@ -0,0 +1 @@
|
||||
../src/newsletter_editor/tinymce/wplink
|
@@ -66,12 +66,14 @@ define('newsletter_editor/blocks/automatedLatestContent', [
|
||||
},
|
||||
fetchPosts: function() {
|
||||
var that = this;
|
||||
mailpoet_post_wpi('automated_latest_content.php', this.toJSON(), function(response) {
|
||||
console.log('ALC fetched', arguments);
|
||||
that.get('_container').get('blocks').reset(response, {parse: true});
|
||||
}, function() {
|
||||
console.log('ALC fetchPosts error', arguments);
|
||||
});
|
||||
console.log('automatedLatestContent.fetchPosts disabled');
|
||||
// TODO: Migrate to new AJAX queries
|
||||
//mailpoet_post_wpi('automated_latest_content.php', this.toJSON(), function(response) {
|
||||
//console.log('ALC fetched', arguments);
|
||||
//that.get('_container').get('blocks').reset(response, {parse: true});
|
||||
//}, function() {
|
||||
//console.log('ALC fetchPosts error', arguments);
|
||||
//});
|
||||
},
|
||||
/**
|
||||
* Batch more changes during a specific time, instead of fetching
|
||||
|
@@ -53,37 +53,37 @@ define('newsletter_editor/blocks/footer', [
|
||||
},
|
||||
attachTextEditor: function() {
|
||||
var that = this;
|
||||
//this.$('.mailpoet_content').tinymce({
|
||||
//inline: true,
|
||||
this.$('.mailpoet_content').tinymce({
|
||||
inline: true,
|
||||
|
||||
//menubar: false,
|
||||
//toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
|
||||
menubar: false,
|
||||
toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
|
||||
|
||||
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
|
||||
//invalid_elements: "script",
|
||||
//style_formats: [
|
||||
//{title: 'Paragraph', block: 'p'},
|
||||
//],
|
||||
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
|
||||
invalid_elements: "script",
|
||||
style_formats: [
|
||||
{title: 'Paragraph', block: 'p'},
|
||||
],
|
||||
|
||||
//plugins: "wplink textcolor mailpoet_custom_fields",
|
||||
plugins: "wplink textcolor mailpoet_custom_fields",
|
||||
|
||||
//setup: function(editor) {
|
||||
//editor.on('change', function(e) {
|
||||
//that.model.set('text', editor.getContent());
|
||||
//});
|
||||
setup: function(editor) {
|
||||
editor.on('change', function(e) {
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
//editor.on('focus', function(e) {
|
||||
//that.disableShowingTools();
|
||||
//});
|
||||
editor.on('focus', function(e) {
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
//editor.on('blur', function(e) {
|
||||
//that.enableShowingTools();
|
||||
//});
|
||||
//},
|
||||
editor.on('blur', function(e) {
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
|
||||
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
//});
|
||||
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -53,37 +53,37 @@ define('newsletter_editor/blocks/header', [
|
||||
},
|
||||
attachTextEditor: function() {
|
||||
var that = this;
|
||||
//this.$('.mailpoet_content').tinymce({
|
||||
//inline: true,
|
||||
this.$('.mailpoet_content').tinymce({
|
||||
inline: true,
|
||||
|
||||
//menubar: false,
|
||||
//toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
|
||||
menubar: false,
|
||||
toolbar: "bold italic link unlink forecolor mailpoet_custom_fields",
|
||||
|
||||
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
|
||||
//invalid_elements: "script",
|
||||
//style_formats: [
|
||||
//{title: 'Paragraph', block: 'p'},
|
||||
//],
|
||||
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],strong[class|style],em[class|style],strike,br",
|
||||
invalid_elements: "script",
|
||||
style_formats: [
|
||||
{title: 'Paragraph', block: 'p'},
|
||||
],
|
||||
|
||||
//plugins: "wplink textcolor mailpoet_custom_fields",
|
||||
plugins: "wplink textcolor mailpoet_custom_fields",
|
||||
|
||||
//setup: function(editor) {
|
||||
//editor.on('change', function(e) {
|
||||
//that.model.set('text', editor.getContent());
|
||||
//});
|
||||
setup: function(editor) {
|
||||
editor.on('change', function(e) {
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
//editor.on('focus', function(e) {
|
||||
//that.disableShowingTools();
|
||||
//});
|
||||
editor.on('focus', function(e) {
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
//editor.on('blur', function(e) {
|
||||
//that.enableShowingTools();
|
||||
//});
|
||||
//},
|
||||
editor.on('blur', function(e) {
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
|
||||
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
//});
|
||||
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -76,14 +76,16 @@ define('newsletter_editor/blocks/posts', [
|
||||
},
|
||||
fetchAvailablePosts: function() {
|
||||
var that = this;
|
||||
mailpoet_post_wpi('posts.php', this.toJSON(), function(response) {
|
||||
console.log('Posts fetched', arguments);
|
||||
that.get('_availablePosts').reset(response);
|
||||
that.get('_selectedPosts').reset(); // Empty out the collection
|
||||
that.trigger('change:_availablePosts');
|
||||
}, function() {
|
||||
console.log('Posts fetchPosts error', arguments);
|
||||
});
|
||||
console.log('posts.fetchAvailablePosts disabled');
|
||||
// TODO: Move this logic to new AJAX query format
|
||||
//mailpoet_post_wpi('posts.php', this.toJSON(), function(response) {
|
||||
//console.log('Posts fetched', arguments);
|
||||
//that.get('_availablePosts').reset(response);
|
||||
//that.get('_selectedPosts').reset(); // Empty out the collection
|
||||
//that.trigger('change:_availablePosts');
|
||||
//}, function() {
|
||||
//console.log('Posts fetchPosts error', arguments);
|
||||
//});
|
||||
},
|
||||
/**
|
||||
* Batch more changes during a specific time, instead of fetching
|
||||
@@ -110,12 +112,14 @@ define('newsletter_editor/blocks/posts', [
|
||||
|
||||
if (data.posts.length === 0) return;
|
||||
|
||||
mailpoet_post_wpi('automated_latest_content.php', data, function(response) {
|
||||
console.log('Available posts fetched', arguments);
|
||||
collection.add(response, { at: index });
|
||||
}, function() {
|
||||
console.log('Posts fetchPosts error', arguments);
|
||||
});
|
||||
console.log('posts._insertSelectedPosts disabled');
|
||||
// TODO: Move query logic to new AJAX format
|
||||
//mailpoet_post_wpi('automated_latest_content.php', data, function(response) {
|
||||
//console.log('Available posts fetched', arguments);
|
||||
//collection.add(response, { at: index });
|
||||
//}, function() {
|
||||
//console.log('Posts fetchPosts error', arguments);
|
||||
//});
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -7,9 +7,7 @@ define('newsletter_editor/blocks/text', [
|
||||
'backbone.marionette',
|
||||
'mailpoet',
|
||||
'jquery',
|
||||
//'tinymce',
|
||||
//'jquery.tinymce',
|
||||
], function(EditorApplication, Backbone, Marionette, MailPoet, jQuery, TinyMCE) {
|
||||
], function(EditorApplication, Backbone, Marionette, MailPoet, jQuery) {
|
||||
|
||||
EditorApplication.module("blocks.text", function(Module, App, Backbone, Marionette, $, _) {
|
||||
"use strict";
|
||||
@@ -50,43 +48,43 @@ define('newsletter_editor/blocks/text', [
|
||||
attachTextEditor: function() {
|
||||
var that = this;
|
||||
if (!this.renderOptions.disableTextEditor) {
|
||||
//this.$('.mailpoet_content').tinymce({
|
||||
//inline: true,
|
||||
this.$('.mailpoet_content').tinymce({
|
||||
inline: true,
|
||||
|
||||
//menubar: false,
|
||||
//toolbar1: "styleselect bold italic forecolor | link unlink",
|
||||
//toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_custom_fields",
|
||||
menubar: false,
|
||||
toolbar1: "styleselect bold italic forecolor | link unlink",
|
||||
toolbar2: "alignleft aligncenter alignright alignjustify | bullist numlist blockquote | code mailpoet_custom_fields",
|
||||
|
||||
////forced_root_block: 'p',
|
||||
//valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
|
||||
//invalid_elements: "script",
|
||||
//style_formats: [
|
||||
//{title: 'Heading 1', block: 'h1'},
|
||||
//{title: 'Heading 2', block: 'h2'},
|
||||
//{title: 'Heading 3', block: 'h3'},
|
||||
//forced_root_block: 'p',
|
||||
valid_elements: "p[class|style],span[class|style],a[href|class|title|target|style],h1[class|style],h2[class|style],h3[class|style],ol[class|style],ul[class|style],li[class|style],strong[class|style],em[class|style],strike,br,blockquote[class|style],table[class|style],tr[class|style],th[class|style],td[class|style]",
|
||||
invalid_elements: "script",
|
||||
style_formats: [
|
||||
{title: 'Heading 1', block: 'h1'},
|
||||
{title: 'Heading 2', block: 'h2'},
|
||||
{title: 'Heading 3', block: 'h3'},
|
||||
|
||||
//{title: 'Paragraph', block: 'p'},
|
||||
//],
|
||||
{title: 'Paragraph', block: 'p'},
|
||||
],
|
||||
|
||||
//plugins: "wplink code textcolor mailpoet_custom_fields",
|
||||
plugins: "wplink code textcolor mailpoet_custom_fields",
|
||||
|
||||
//setup: function(editor) {
|
||||
//editor.on('change', function(e) {
|
||||
//that.model.set('text', editor.getContent());
|
||||
//});
|
||||
setup: function(editor) {
|
||||
editor.on('change', function(e) {
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
//editor.on('focus', function(e) {
|
||||
//that.disableShowingTools();
|
||||
//});
|
||||
editor.on('focus', function(e) {
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
//editor.on('blur', function(e) {
|
||||
//that.enableShowingTools();
|
||||
//});
|
||||
//},
|
||||
editor.on('blur', function(e) {
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
|
||||
//mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
//mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
//});
|
||||
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
|
||||
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@@ -16,24 +16,26 @@ define('newsletter_editor/components/save', [
|
||||
|
||||
|
||||
// save newsletter
|
||||
mailpoet_post_wpi('newsletter_save.php', json, function(response) {
|
||||
if(response.success !== undefined && response.success === true) {
|
||||
//MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
|
||||
} else if(response.error !== undefined) {
|
||||
if(response.error.length === 0) {
|
||||
// TODO: Handle translations
|
||||
MailPoet.Notice.error("<?php _e('An unknown error occurred, please check your settings.'); ?>");
|
||||
} else {
|
||||
$(response.error).each(function(i, error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
App.getChannel().trigger('afterEditorSave', json, response);
|
||||
}, function(error) {
|
||||
// TODO: Handle saving errors
|
||||
App.getChannel().trigger('afterEditorSave', {}, error);
|
||||
});
|
||||
console.log('save disabled');
|
||||
// TODO: Migrate logic to new AJAX format
|
||||
//mailpoet_post_wpi('newsletter_save.php', json, function(response) {
|
||||
//if(response.success !== undefined && response.success === true) {
|
||||
////MailPoet.Notice.success("<?php _e('Newsletter has been saved.'); ?>");
|
||||
//} else if(response.error !== undefined) {
|
||||
//if(response.error.length === 0) {
|
||||
//// TODO: Handle translations
|
||||
//MailPoet.Notice.error("<?php _e('An unknown error occurred, please check your settings.'); ?>");
|
||||
//} else {
|
||||
//$(response.error).each(function(i, error) {
|
||||
//MailPoet.Notice.error(error);
|
||||
//});
|
||||
//}
|
||||
//}
|
||||
//App.getChannel().trigger('afterEditorSave', json, response);
|
||||
//}, function(error) {
|
||||
//// TODO: Handle saving errors
|
||||
//App.getChannel().trigger('afterEditorSave', {}, error);
|
||||
//});
|
||||
};
|
||||
|
||||
Module.SaveView = Marionette.LayoutView.extend({
|
||||
|
@@ -220,23 +220,25 @@ define('newsletter_editor/components/sidebar', [
|
||||
// send test email
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
mailpoet_post_wpi('newsletter_preview.php', data, function(response) {
|
||||
if(response.success !== undefined && response.success === true) {
|
||||
MailPoet.Notice.success(App.getConfig().get('translations.testEmailSent'));
|
||||
} else if(response.error !== undefined) {
|
||||
if(response.error.length === 0) {
|
||||
MailPoet.Notice.error(App.getConfig().get('translations.unknownErrorOccurred'));
|
||||
} else {
|
||||
$(response.error).each(function(i, error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
}, function(error) {
|
||||
// an error occurred
|
||||
MailPoet.Modal.loading(false);
|
||||
});
|
||||
console.log('sendPreview disabled');
|
||||
// TODO: Migrate logic to new AJAX format
|
||||
//mailpoet_post_wpi('newsletter_preview.php', data, function(response) {
|
||||
//if(response.success !== undefined && response.success === true) {
|
||||
//MailPoet.Notice.success(App.getConfig().get('translations.testEmailSent'));
|
||||
//} else if(response.error !== undefined) {
|
||||
//if(response.error.length === 0) {
|
||||
//MailPoet.Notice.error(App.getConfig().get('translations.unknownErrorOccurred'));
|
||||
//} else {
|
||||
//$(response.error).each(function(i, error) {
|
||||
//MailPoet.Notice.error(error);
|
||||
//});
|
||||
//}
|
||||
//}
|
||||
//MailPoet.Modal.loading(false);
|
||||
//}, function(error) {
|
||||
//// an error occurred
|
||||
//MailPoet.Modal.loading(false);
|
||||
//});
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -10,8 +10,7 @@
|
||||
|
||||
/*jshint unused:false */
|
||||
/*global tinymce:true */
|
||||
define('mailpoet_custom_fields', ['jquery', 'tinymce'], function(jQuery, tinymce) {
|
||||
tinymce.PluginManager.add('mailpoet_custom_fields', function(editor, url) {
|
||||
tinymce.PluginManager.add('mailpoet_custom_fields', function(editor, url) {
|
||||
var appendLabelAndClose = function(text) {
|
||||
editor.insertContent('[' + text + ']');
|
||||
editor.windowManager.close();
|
||||
@@ -56,5 +55,4 @@ define('mailpoet_custom_fields', ['jquery', 'tinymce'], function(jQuery, tinymce
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -592,4 +592,3 @@ var wpLink;
|
||||
|
||||
$( document ).ready( wpLink.init );
|
||||
})( jQuery );
|
||||
|
@@ -83,6 +83,8 @@ class Menu {
|
||||
function newsletterEditor() {
|
||||
$data = array();
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
|
||||
wp_enqueue_style('editor', includes_url('css/editor.css'));
|
||||
echo $this->renderer->render('newsletter/editor.html', $data);
|
||||
}
|
||||
}
|
||||
|
@@ -159,15 +159,19 @@
|
||||
<%= partial('newsletter_editor_template_sidebar_preview', 'newsletter/templates/components/sidebar/preview.hbs') %>
|
||||
<%= partial('newsletter_editor_template_sidebar_styles', 'newsletter/templates/components/sidebar/styles.hbs') %>
|
||||
|
||||
<%= stylesheet(
|
||||
'newsletter_editor.css'
|
||||
) %>
|
||||
|
||||
<%= javascript(
|
||||
'vendor.js',
|
||||
'lib/tinymce/tinymce.jquery.min.js',
|
||||
'lib/tinymce/jquery.tinymce.min.js',
|
||||
'lib/mailpoet_custom_fields/plugin.js',
|
||||
'lib/wplink/plugin.js',
|
||||
'newsletter_editor.js'
|
||||
) %>
|
||||
|
||||
<%= stylesheet(
|
||||
'newsletter_editor.css'
|
||||
) %>
|
||||
|
||||
<script type="text/javascript">
|
||||
var templates = {
|
||||
styles: Handlebars.compile(jQuery('#newsletter_editor_template_styles').html()),
|
||||
|
@@ -46,7 +46,7 @@ baseConfig = {
|
||||
{
|
||||
include: require.resolve('handlebars'),
|
||||
loader: 'expose-loader?Handlebars',
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -72,19 +72,10 @@ config.push(_.extend({}, baseConfig, {
|
||||
'backbone.supermodel',
|
||||
'interact.js',
|
||||
'backbone.radio',
|
||||
//'moment-with-locales',
|
||||
'tinymce/tinymce.jquery.js',
|
||||
'tinymce/jquery.tinymce.min.js',
|
||||
//'tinymce',
|
||||
//'jquery.tinymce',
|
||||
'select2',
|
||||
'spectrum-colorpicker',
|
||||
'sticky-kit',
|
||||
|
||||
|
||||
|
||||
//'newsletter_editor/tinymce/wplink.js',
|
||||
//'newsletter_editor/tinymce/mailpoet_custom_fields/plugin.js',
|
||||
'newsletter_editor/communicationsFix.js',
|
||||
'newsletter_editor/App',
|
||||
'newsletter_editor/components/config.js',
|
||||
@@ -117,7 +108,8 @@ config.push(_.extend({}, baseConfig, {
|
||||
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'),
|
||||
],
|
||||
externals: {
|
||||
'jquery': 'jQuery'
|
||||
'jquery': 'jQuery',
|
||||
'tinymce': 'tinymce'
|
||||
}
|
||||
}));
|
||||
|
||||
|
Reference in New Issue
Block a user