-
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 all 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 |
---|---|---|
|
@@ -27,6 +27,9 @@ Fliplet.FormBuilder.field('wysiwyg', { | |
computed: { | ||
isInterface: function() { | ||
return Fliplet.Env.get('interface'); | ||
}, | ||
isInteract: function() { | ||
return Fliplet.Env.get('interact'); | ||
} | ||
}, | ||
watch: { | ||
|
@@ -132,46 +135,71 @@ Fliplet.FormBuilder.field('wysiwyg', { | |
|
||
var config = { | ||
target: this.$refs.textarea, | ||
theme: 'modern', | ||
readonly: this.readonly, | ||
mobile: { | ||
theme: this.readonly | ||
? 'silver' | ||
: 'mobile', | ||
plugins: [ 'autosave', 'lists', 'autolink' ], | ||
toolbar: [ 'bold', 'italic', 'underline', 'bullist', 'numlist', 'removeformat' ] | ||
height: lineHeight * this.rows, | ||
menubar: false, | ||
formats: { | ||
removeformat: [ | ||
// Remove block containers | ||
{ | ||
selector: 'div,main,article,aside,header,footer', | ||
remove: 'all', | ||
split: false, | ||
expand: false, | ||
block_expand: true, | ||
deep: true | ||
}, | ||
// Remove inline containers | ||
{ | ||
selector: 'b,strong,em,i,font,u,strike,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,span', | ||
remove: 'all', | ||
split: true, | ||
expand: false, | ||
deep: true | ||
}, | ||
// Remove attributes | ||
{ | ||
selector: '*', | ||
attributes: ['style', 'class', 'id'], | ||
split: false, | ||
expand: false, | ||
deep: true | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
'advlist autolink lists link directionality', | ||
'autoresize fullscreen code paste' | ||
].join(' '), | ||
toolbar: this.readonly | ||
plugins: $vm.isInterface | ||
? false | ||
: [ | ||
'bold italic underline', | ||
'alignleft aligncenter alignright alignjustify | bullist numlist outdent indent', | ||
'ltr rtl | link | removeformat code fullscreen' | ||
].join(' | '), | ||
image_advtab: true, | ||
menubar: false, | ||
: ['advlist autolink lists link searchreplace print directionality', | ||
'table paste pasteplaintext code'], | ||
statusbar: false, | ||
toolbar: this.readonly || $vm.isInterface | ||
? ['bold italic underline alignleft aligncenter alignright alignjustify'].join(' | ') | ||
: ['bold italic underline | alignleft aligncenter alignright alignjustify', | ||
'bullist numlist outdent indent | ltr rtl', | ||
'link | pasteplaintext removeformat | code | formatselect'].join(' | '), | ||
mobile: { | ||
toolbar_mode: 'sliding', | ||
plugins: '' | ||
}, | ||
paste_preprocess: function(plugin, args) { | ||
// Clean up content before pasting | ||
args.content = args.content | ||
.replace(/ contenteditable="(true|false)"/g, ''); | ||
}, | ||
// Prevent URLs from being altered | ||
// https://stackoverflow.com/questions/3796942 | ||
relative_urls: false, | ||
remove_script_host: false, | ||
convert_urls: true, | ||
inline: false, | ||
resize: false, | ||
autoresize_bottom_margin: 0, | ||
autoresize_max_height: lineHeight * this.rows, | ||
autoresize_min_height: lineHeight * this.rows, | ||
autofocus: false, | ||
convert_urls: false, | ||
branding: false, | ||
setup: function(editor) { | ||
$vm.editor = editor; | ||
|
||
editor.on('init', function() { | ||
$vm.addPlaceholder(); | ||
if ($vm.isInterface) { | ||
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. If it's not |
||
$vm.addPlaceholder(); | ||
} | ||
|
||
$vm.addBulletedListShortcutsWindows(); | ||
|
||
if ($vm.defaultValueSource !== 'default') { | ||
|
@@ -221,7 +249,9 @@ Fliplet.FormBuilder.field('wysiwyg', { | |
field: this, | ||
config: config | ||
}).then(function() { | ||
tinymce.init(config); | ||
if (tinymce && !$vm.isInteract) { | ||
tinymce.init(config); | ||
} | ||
}); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,7 +799,6 @@ new Vue({ | |
} | ||
}); | ||
}, | ||
|
||
// Converts @event attributes to v-on:event | ||
convertVueEventAttributes: function(html) { | ||
var $html = $('<div/>').append(html); | ||
|
@@ -874,8 +873,8 @@ new Vue({ | |
if (value === 'settings') { | ||
$vm.setupCodeEditor(); | ||
changeSelectText(); | ||
} else { | ||
tinymce.remove(); | ||
} else if ($vm.$refs.resulthtml) { | ||
$($vm.$refs.resulthtml).tinymce().remove(); | ||
} | ||
}, | ||
'settings.dataStore': function(value) { | ||
|
@@ -983,29 +982,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.
Why would it have a toolbar if it's
readonly
? The previous code suggested that if it'sreadonly
thentoolbar: false
.