From 05fcda369b42714f3a10b8530e0e0b51249af285 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Sat, 4 Apr 2020 21:06:53 +0200 Subject: [PATCH] Configurable editor widgets --- src/editor/Editor.jsx | 20 +++++++++----------- src/editor/widgets/tag/TagWidget.jsx | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/editor/Editor.jsx b/src/editor/Editor.jsx index 0754ebb..5ad29d6 100644 --- a/src/editor/Editor.jsx +++ b/src/editor/Editor.jsx @@ -70,17 +70,15 @@ const Editor = props => {
- - - + {React.Children.map(props.children, child => + React.cloneElement(child, { + annotation : currentAnnotation, + onAppendBody : onAppendBody, + onUpdateBody : onUpdateBody, + onRemoveBody : onRemoveBody, + onSaveAndClose : onOk + })) + } { props.readOnly ? (
diff --git a/src/editor/widgets/tag/TagWidget.jsx b/src/editor/widgets/tag/TagWidget.jsx index 36378d6..8393f33 100644 --- a/src/editor/widgets/tag/TagWidget.jsx +++ b/src/editor/widgets/tag/TagWidget.jsx @@ -20,12 +20,12 @@ const TagWidget = props => { const onDelete = tag => evt => { evt.stopPropagation(); - props.onRemoveTag(tag); + props.onRemoveBody(tag); } const onKeyDown = evt => { if (evt.which === 13) { // Enter - props.onAddTag({ type: 'TextualBody', purpose: 'tagging', value: newTag.trim() }); + props.onAppendBody({ type: 'TextualBody', purpose: 'tagging', value: newTag.trim() }); setNewTag(''); // Clear the input } }