Skip to content

Commit

Permalink
pkp/pkp-lib#9773 html text enhancement for rich field text
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jun 7, 2024
1 parent 76b4148 commit ff18d10
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/components/Form/fields/FieldRichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
type: String,
required: true,
},
/** Must be `oneline`. */
size: {
type: String,
Expand All @@ -20,6 +21,24 @@ export default {
return ['oneline'].includes(value);
},
},
// @see 5.0+ : https://www.tiny.cloud/docs/configure/content-filtering/#invalid_elements
// @see 6.0+ : https://www.tiny.cloud/docs/tinymce/latest/content-filtering/#invalid_elements
invalidElements: {
type: String,
default() {
return 'em,strong,br';
},
},
// @see 5.0+ : https://www.tiny.cloud/docs/configure/content-filtering/#valid_elements
// @see 6.0+ : https://www.tiny.cloud/docs/tinymce/latest/content-filtering/#valid_elements
validElements: {
type: String,
default() {
return 'b,i,u,sup,sub';
},
},
},
computed: {
/**
Expand Down Expand Up @@ -58,14 +77,10 @@ export default {
subscript: [{inline: 'sub', remove: 'all', exact: true}],
superscript: [{inline: 'sup', remove: 'all', exact: true}],
},
extended_valid_elements: 'b,i',
invalid_elements: 'em strong',
// Allow pasting while stripping all styles, tags, new lines and getting only text content
// More details at https://www.tiny.cloud/docs/tinymce/6/copy-and-paste/
paste_preprocess: (editor, args) => {
args.content = $('<div>' + args.content + '</div>').text();
},
extended_valid_elements: 'b,i',
invalid_elements: this.invalidElements,
valid_elements: this.validElements,
setup: (editor) => {
// Disable new line by preventing enter key
Expand Down

0 comments on commit ff18d10

Please sign in to comment.