Skip to content

Commit

Permalink
Allow onChange to be string or void
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie-n committed Jun 18, 2024
1 parent c07a965 commit b696f25
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion dist/components/form/components/FormRichText.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface QuillEditorProps {
style?: CSSProperties;
id?: string;
modules?: Record<string, unknown>;
onChange?: (value: string) => string | void;
valueChange?(value: string): any;
value?: string;
}
declare const _default: React.ForwardRefExoticComponent<QuillEditorProps & React.RefAttributes<Quill>>;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/form/components/FormRichText.d.ts.map

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

26 changes: 13 additions & 13 deletions dist/components/form/components/FormRichText.js

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

2 changes: 1 addition & 1 deletion dist/components/form/components/FormRichText.js.map

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

2 changes: 1 addition & 1 deletion dist/index.es.js

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25532,9 +25532,21 @@ Quill.register({
}, true);

var FormRichText = function (_a, ref) {
var modules = _a.modules, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["modules", "value", "onChange"]);
var modules = _a.modules, value = _a.value, valueChange = _a.valueChange, rest = __rest(_a, ["modules", "value", "valueChange"]);
var editorRef = React.useRef(null);
var quillRef = React.useRef(null);
var setValue = function (quillRef) {
var delta = quillRef.clipboard.convert({ html: value });
quillRef.setContents(delta, 'silent');
};
var configureListeners = function (quill) {
quill.on('text-change', function () {
var _a;
if (valueChange) {
valueChange(((_a = quillRef.current) === null || _a === void 0 ? void 0 : _a.getSemanticHTML()) || '');
}
});
};
React.useEffect(function () {
if (editorRef.current) {
var quill = new Quill(editorRef.current, modules);
Expand All @@ -25552,18 +25564,6 @@ var FormRichText = function (_a, ref) {
}
}, []);
React.useImperativeHandle(ref, function () { return quillRef.current; });
var setValue = function (quillRef) {
var delta = quillRef.clipboard.convert({ html: value });
quillRef.setContents(delta, 'silent');
};
var configureListeners = function (quill) {
quill.on('text-change', function (e) {
var _a;
if (onChange) {
onChange(((_a = quillRef.current) === null || _a === void 0 ? void 0 : _a.getSemanticHTML()) || '');
}
});
};
return React.createElement("div", { ref: editorRef, style: rest.style, id: rest.id });
};
var FormRichText$1 = React.forwardRef(FormRichText);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.min.js

Large diffs are not rendered by default.

0 comments on commit b696f25

Please sign in to comment.