Skip to content

Commit

Permalink
fix: still support deprecated holderId property
Browse files Browse the repository at this point in the history
  • Loading branch information
natterstefan committed Dec 17, 2019
1 parent 2d099f2 commit 10774a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/__stories__/index.stories.tsx
Expand Up @@ -154,6 +154,28 @@ storiesOf('ReactEditorJs', module)

return <App />
})
.add('with custom holder', () => {
let instance: EditorJS = null

const onChange = () => {
action('EditorJs onChange')(instance)
}

return (
<EditorJs
tools={TOOLS}
data={data}
onChange={onChange}
holder="custom-editor-container"
editorInstance={editorInstance => {
instance = editorInstance
action('EditorJs editorInstance')(editorInstance)
}}
>
<div id="custom-editor-container" />
</EditorJs>
)
})
.add('with custom tool (react)', () => {
let editorInstance: EditorJS = null

Expand Down
3 changes: 2 additions & 1 deletion src/editor.tsx
Expand Up @@ -36,6 +36,7 @@ const DEFAULT_ID = 'editorjs'

const EditorJs: FunctionComponent<IEditorJsProps> = (props): ReactElement => {
const {
holderId: deprecatedId,
holder: customHolderId,
editorInstance,
reinitializeOnPropsChange,
Expand All @@ -45,7 +46,7 @@ const EditorJs: FunctionComponent<IEditorJsProps> = (props): ReactElement => {
} = props

const instance: MutableRefObject<EditorJS> = useRef(null)
const holderId = customHolderId || DEFAULT_ID
const holderId = deprecatedId || customHolderId || DEFAULT_ID

const initEditor = useCallback(() => {
if (instance && !instance.current) {
Expand Down

0 comments on commit 10774a4

Please sign in to comment.