Skip to content

Commit

Permalink
allow visual designing some elements
Browse files Browse the repository at this point in the history
  • Loading branch information
zenn1989 committed Aug 30, 2022
1 parent ce667ce commit 075bb43
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/Apps/View/Admin/default/widgets/tinymce/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/** @var \Ffcms\Templex\Template\Template $this */
?>

<script src="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/node_modules/xss/dist/xss.min.js"></script>
<script src="<?= \App::$Alias->scriptUrl ?>/vendor/tinymce/tinymce/tinymce.min.js"></script>
<script src="<?= \App::$Alias->scriptUrl ?>/vendor/phpffcms/ffcms-assets/standalone/tinymce-codeeditor/ce.js"></script>

Expand All @@ -21,14 +22,14 @@ function setResponseUrl(url) {
plugins: [
'advlist autolink lists link image imagetools charmap print preview anchor',
'searchreplace visualblocks code',
'insertdatetime media table paste wordcount pagebreak codesample codeeditor'
'insertdatetime media table paste wordcount pagebreak codesample codeeditor paste'
],
toolbar: 'formatselect | insert | bold italic subscript superscript forecolor backcolor blockquote | removeformat | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | pagebreak codeeditor',
toolbar: 'paste | formatselect | insert | bold italic subscript superscript forecolor backcolor blockquote | removeformat | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | pagebreak codeeditor',
image_advtab: true,
visualblocks_default_state: true,
end_container_on_empty_block: true,
default_link_target: "_blank",
paste_as_text: true,
//paste_as_text: true,
extended_valid_elements: 'i[class|id],span[class,id]',
pagebreak_separator: "<div style=\"page-break-after: always;\">&nbsp;</div>",
pagebreak_split_block: true,
Expand Down Expand Up @@ -62,6 +63,39 @@ function setResponseUrl(url) {
e.on('change', function(){
e.save();
});
},
paste_preprocess: function(plugin, args) {
let htm = args.content;
html = filterXSS(htm, {
whiteList: {
a: ['href', 'title', 'target'],
p: [],
strong: [],
b: [],
table: [],
tr: ['colspan'],
td: ['colspan'],
thead: [],
tbody: []
},
stripIgnoreTag: true,
stripIgnoreTagBody: ['script'],
onTag: function(tag, html, options) {
if (tag === 'table') {
res = html;
if (options.isClosing === true) {
res = "</div>" + res;
} else {
res = res.replace('>', ' class="table table-bordered">');
res = '<div class="table-responsive">' + res;
}
return res;
}
}
});

//console.log(html);
args.content = html;
}
});
</script>

0 comments on commit 075bb43

Please sign in to comment.