Skip to content
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

pkp/pkp-lib#9773 html text enhancement for rich field text #361

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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