Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
Merge fix-event/onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Andries-Smit authored May 30, 2018
2 parents 9fff30f + 4085a1e commit 9b56887
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rich-text",
"widgetName": "RichText",
"version": "1.2.0",
"version": "1.2.1",
"description": "Rich inline or toolbar text editing",
"scripts": {
"start": "nodemon --watch webpack.config.js --watch Gruntfile.js --exec grunt",
Expand Down
8 changes: 4 additions & 4 deletions src/components/RichText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface CommonRichTextProps {

export interface RichTextProps extends CommonRichTextProps {
className?: string;
onChange: (value: string) => void;
onBlur: () => void;
onChange?: (value: string) => void;
onBlur?: () => void;
style?: object;
}

Expand Down Expand Up @@ -178,15 +178,15 @@ export class RichText extends Component<RichTextProps> {
private handleTextChange() {
if (this.quill) {
const value = this.quill.root.innerHTML !== this.undoDefault ? this.quill.root.innerHTML : "";
if (this.props.value !== value) {
if (this.props.value !== value && this.props.onChange) {
this.props.onChange(value);
this.textChanged = true;
}
}
}

private handleSelectionChange() {
if (this.textChanged && this.quill && !this.quill.hasFocus()) {
if (this.textChanged && this.quill && !this.quill.hasFocus() && this.props.onBlur) {
this.props.onBlur();
this.textChanged = false;
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/RichTextContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type ReadOnlyStyle = "bordered" | "text" | "borderedToolbar";

export default class RichTextContainer extends Component<RichTextContainerProps, RichTextContainerState> {
private subscriptionHandles: number[] = [];
private defaultValue: string | null;
private defaultValue: string | null | undefined;
private isEditing = false;

constructor(props: RichTextContainerProps) {
Expand All @@ -56,6 +56,7 @@ export default class RichTextContainer extends Component<RichTextContainerProps,
}

render() {
const readOnly = this.isReadOnly();
return createElement(ValidateConfigs, { ...this.props as RichTextContainerProps, showOnError: false },
createElement(RichText, {
editorOption: this.props.editorOption,
Expand All @@ -68,9 +69,9 @@ export default class RichTextContainer extends Component<RichTextContainerProps,
style: parseStyle(this.props.style),
sanitizeContent: this.props.sanitizeContent,
value: this.state.value,
onChange: this.handleOnChange,
onBlur: this.executeOnChangeAction,
readOnly: this.isReadOnly(),
onChange: !readOnly ? this.handleOnChange : undefined,
onBlur: !readOnly ? this.executeOnChangeAction : undefined,
readOnly,
alertMessage: this.state.alertMessage
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="RichText" version="1.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="RichText" version="1.2.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="RichText.xml"/>
</widgetFiles>
Expand Down

0 comments on commit 9b56887

Please sign in to comment.