Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit ac3564a

Browse files
authored
Merge pull request #197 from accordproject/dl-disallow-uneditable-cut
fix(SlateAsInputEditor): disallow cut functionality if in uneditable text
2 parents f946b38 + 9323908 commit ac3564a

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

package-lock.json

+14-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SlateAsInputEditor/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,14 @@ const SlateAsInputEditor = React.forwardRef((props, ref) => {
461461
setTimeout(editor.focus, 0);
462462
};
463463

464+
const onCutHandler = (event, editor, next) => {
465+
if (!isEditable(editor, 'cut')) {
466+
event.preventDefault();
467+
return false;
468+
}
469+
return next();
470+
};
471+
464472
return (
465473
<div>
466474
<ToolbarWrapper {...editorProps} id="slate-toolbar-wrapper-id" />
@@ -472,6 +480,7 @@ const SlateAsInputEditor = React.forwardRef((props, ref) => {
472480
value={Value.fromJSON(value)}
473481
readOnly={props.readOnly}
474482
onChange={onChangeHandler}
483+
onCut={onCutHandler}
475484
onFocus={onFocusHandler}
476485
schema={slateSchema}
477486
plugins={plugins}

0 commit comments

Comments
 (0)