-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OD-378 [Feature] Upgrade TinyMCE 4 to TinyMCE 5 for Form component #375
base: master
Are you sure you want to change the base?
Changes from 11 commits
29ab6aa
e0f1b42
4d60c31
8e93fd2
7d15fbf
6d242e3
401ab4a
8cb425e
29e2e6a
86a08d5
cf624b9
84e4487
c6320e3
d5dd6dc
ce51c1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -750,56 +750,6 @@ new Vue({ | |
this.accessRules.splice(accessRuleIndex, 1); | ||
} | ||
}, | ||
setupCodeEditor: function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like we're removing code editor from somewhere else in the form builder that's unrelated to the Rich Text field. It looks like the form submission confirmation HTML. We can't remove that. What version of TinyMCE is running in the builder interface? If it's TinyMCE 4, then we can keep this running without having to change anything, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I returned setup for builder. |
||
var $vm = this; | ||
|
||
tinymce.init({ | ||
target: $vm.$refs.resulthtml, | ||
theme: 'modern', | ||
mobile: { | ||
theme: 'mobile', | ||
plugins: ['autosave', 'lists', 'autolink'], | ||
toolbar: ['bold', 'italic', 'underline', 'bullist', 'numlist', 'removeformat'] | ||
}, | ||
plugins: [ | ||
'advlist autolink lists link directionality', | ||
'autoresize fullscreen code paste' | ||
].join(' '), | ||
toolbar: [ | ||
'bold italic underline', | ||
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent', | ||
'ltr rtl | link | removeformat code fullscreen' | ||
].join(' | '), | ||
image_advtab: true, | ||
menubar: false, | ||
statusbar: false, | ||
inline: false, | ||
resize: false, | ||
autoresize_bottom_margin: 5, | ||
autofocus: false, | ||
branding: false, | ||
valid_elements: '*[*]', | ||
allow_script_urls: true, | ||
min_height: 200, | ||
setup: function(editor) { | ||
editor.on('init', function() { | ||
$vm.resultEditor = editor; | ||
|
||
// initialize value if it was set prior to initialization | ||
if ($vm.settings.resultHtml) { | ||
var updatedHtml = $vm.convertVueEventAttributes($vm.settings.resultHtml); | ||
|
||
editor.setContent(updatedHtml, { format: 'raw' }); | ||
} | ||
}); | ||
|
||
editor.on('change', function() { | ||
$vm.settings.resultHtml = editor.getContent(); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
// Converts @event attributes to v-on:event | ||
convertVueEventAttributes: function(html) { | ||
var $html = $('<div/>').append(html); | ||
|
@@ -869,13 +819,8 @@ new Vue({ | |
} | ||
}, | ||
'section': function(value) { | ||
var $vm = this; | ||
|
||
if (value === 'settings') { | ||
$vm.setupCodeEditor(); | ||
changeSelectText(); | ||
} else { | ||
tinymce.remove(); | ||
} | ||
}, | ||
'settings.dataStore': function(value) { | ||
|
@@ -983,29 +928,6 @@ new Vue({ | |
$(selector).removeClass('is-loading'); | ||
} | ||
|
||
$($vm.$refs.templateDescription).tinymce({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? |
||
plugins: [ | ||
'lists advlist image charmap hr code', | ||
'searchreplace wordcount insertdatetime table textcolor colorpicker' | ||
], | ||
toolbar: [ | ||
'formatselect |', | ||
'bold italic underline strikethrough |', | ||
'forecolor backcolor |', | ||
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent |', | ||
'blockquote subscript superscript | table insertdatetime charmap hr |', | ||
'removeformat | code' | ||
].join(' '), | ||
menubar: false, | ||
statusbar: false, | ||
min_height: 300, | ||
setup: function(ed) { | ||
$vm.editor = ed; | ||
$vm.editor.on('keyup paste', function() { | ||
$vm.settings.description = $vm.editor.getContent(); | ||
}); | ||
} | ||
}); | ||
|
||
if ($vm.chooseTemplate && $vm.$refs.templateGallery) { | ||
setTimeout(function() { | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Paste as Plain Text plugin | ||
if (tinymce && tinymce.majorVersion === '5') { | ||
tinymce.PluginManager.add('pasteplaintext', function (editor, url) { | ||
var openDialog = function () { | ||
return editor.windowManager.open({ | ||
title: 'Paste as Plain Text', | ||
body: { | ||
type: 'panel', | ||
items: [ | ||
{ | ||
type: 'htmlpanel', | ||
html: '<p>Please paste inside the following box using the keyboard (<strong style="font-weight:600">Cmd/Ctrl + V</strong>) and hit <strong style="font-weight:600">Paste</strong>.<br></p><style>.tox .tox-form__group--stretched { height: 240px; }</style>' | ||
}, | ||
{ | ||
type: 'textarea', | ||
name: 'text' | ||
} | ||
] | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'cancel', | ||
text: 'Cancel' | ||
}, | ||
{ | ||
type: 'submit', | ||
text: 'Paste', | ||
primary: true | ||
} | ||
], | ||
onSubmit: function (api) { | ||
var data = api.getData(); | ||
|
||
/* Insert content when the window form is submitted */ | ||
editor.insertContent(data.text.replace(/(?:\r\n|\r|\n)/g, '<br>')); | ||
api.close(); | ||
} | ||
}); | ||
}; | ||
|
||
/* Add a button that opens a window */ | ||
editor.ui.registry.addButton('pasteplaintext', { | ||
icon: 'paste-text', | ||
tooltip: 'Paste as Plain Text', | ||
onAction: function () { | ||
openDialog(); | ||
} | ||
}); | ||
|
||
/* Return the metadata for the plugin */ | ||
return { | ||
getMetadata: function () { | ||
return { | ||
name: 'Paste as Plain Text' | ||
}; | ||
} | ||
}; | ||
}); | ||
} |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not
interface
, e.g. preview/live app, placeholder should also work as it currently does.