Skip to content

Commit 9fb6b7a

Browse files
authored
Merge pull request accordproject#76 from accordproject/dl-forward-ref
feat(SlateAsInputEditor): forward ref to the Slate Editor
2 parents 3904f68 + d51d9da commit 9fb6b7a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/SlateAsInputEditor/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ function uuidv4() {
9191
* @param {*} props the props for the component. See the declared PropTypes
9292
* for details.
9393
*/
94-
function SlateAsInputEditor(props) {
94+
// eslint-disable-next-line react/display-name
95+
const SlateAsInputEditor = React.forwardRef((props, ref) => {
9596
/**
9697
* Destructure props for efficiency
9798
*/
@@ -104,7 +105,7 @@ function SlateAsInputEditor(props) {
104105
/**
105106
* A reference to the Slate Editor.
106107
*/
107-
const editorRef = useRef(null);
108+
const editorRef = ref || useRef(null);
108109

109110
/**
110111
* Slate Schema augmented by plugins
@@ -141,7 +142,6 @@ function SlateAsInputEditor(props) {
141142
augmentedSchema = plugin.augmentSchema(augmentedSchema);
142143
}
143144
});
144-
console.log('Slate schema', augmentedSchema);
145145
setSlateSchema(augmentedSchema);
146146
}, [plugins]);
147147

@@ -173,7 +173,7 @@ function SlateAsInputEditor(props) {
173173
}
174174
});
175175
}
176-
}, [value.document, lockText]);
176+
}, [value.document, lockText, editorRef]);
177177

178178
/**
179179
* Render a Slate inline.
@@ -443,7 +443,7 @@ function SlateAsInputEditor(props) {
443443
</EditorWrapper>
444444
</div>
445445
);
446-
}
446+
});
447447

448448
/**
449449
* The property types for this component

0 commit comments

Comments
 (0)