Skip to content

Commit

Permalink
make sure description text is plain text without html (#4309)
Browse files Browse the repository at this point in the history
SDCP-710
  • Loading branch information
petrjasek authored Aug 18, 2023
1 parent 80d6f25 commit ce18b3b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/apps/authoring/views/article-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@
data-tabindex="editor.description_text.order"
data-clean-pasted-html="editor.description_text.cleanPastedHTML"
data-limit="schema.description_text.maxlength"
data-plain-text="true"
></div>
</div>

Expand Down
2 changes: 2 additions & 0 deletions scripts/core/editor3/components/Editor3Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ interface IProps {
editorState?: EditorState;
scrollContainer?: string;
singleLine?: boolean;
plainText?: boolean;
editorFormat?: Array<RICH_FORMATTING_OPTION>;
tabindex?: number;
suggestingMode?: boolean;
Expand Down Expand Up @@ -690,6 +691,7 @@ export class Editor3Component extends React.Component<IProps, IState> {
Editor3Component.defaultProps = {
readOnly: false,
singleLine: false,
plainText: false,
cleanPastedHtml: false,
editorFormat: [],
};
9 changes: 9 additions & 0 deletions scripts/core/editor3/directive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Editor3Directive {
readOnly: any;
findReplaceTarget: any;
singleLine: any;
plainText?: boolean;
debounce: any;
bindToValue: any;
tabindex: any;
Expand Down Expand Up @@ -202,6 +203,12 @@ class Editor3Directive {
cleanPastedHtml: '=?',

limit: '=?',

/**
* @type {String}
* @description Force the output to be plain text and not contain any html.
*/
plainText: '=?',
};
}

Expand All @@ -227,6 +234,7 @@ class Editor3Directive {
this.findReplaceTarget =
typeof this.findReplaceTarget !== 'undefined';
this.singleLine = this.singleLine || false;
this.plainText = this.plainText || false;
this.debounce = parseInt(this.debounce || '100', 10);
this.bindToValue = this.bindToValue || false;
this.tabindex = this.tabindex || 0;
Expand Down Expand Up @@ -256,6 +264,7 @@ class Editor3Directive {
singleLine={this.singleLine}
cleanPastedHtml={this.cleanPastedHtml}
autocompleteSuggestions={autocompleteSuggestions}
plainText={this.plainText}
/>
</EditorStore.Provider>
</Provider>,
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/editor3/reducers/editor3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const onChange = (
const contentChanged = state.editorState.getCurrentContent() !== editorStateNext.getCurrentContent();

if (!skipOnChange && (contentChanged || force)) {
const plainText = state.singleLine === true;
const plainText = state.plainText === true || state.singleLine === true;

state.onChangeValue(editorStateNext.getCurrentContent(), {plainText});
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/core/editor3/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface IProps {
onChange?: any;
readOnly?: any;
singleLine?: any;
plainText?: any;
tabindex?: any;
showTitle?: any;
editorFormat?: Array<RICH_FORMATTING_OPTION>;
Expand All @@ -74,6 +75,7 @@ export interface IEditorStore {
locked: boolean;
showToolbar: any;
singleLine: any;
plainText: boolean;
tabindex: any;
showTitle: any;
activeCell?: IActiveCell;
Expand Down Expand Up @@ -167,6 +169,7 @@ export default function createEditorStore(
locked: false, // when true, main editor is disabled (ie. when editing sub-components like tables or images)
showToolbar: (props.editorFormat || []).length > 0,
singleLine: props.singleLine,
plainText: props.plainText,
tabindex: props.tabindex,
showTitle: props.showTitle,
activeCell: null, // currently focused table cell
Expand Down

0 comments on commit ce18b3b

Please sign in to comment.