Preparatory work for flexible plugin API
This commit is contained in:
parent
d4ab1aedb4
commit
b1db6e90e0
|
@ -1,7 +1,7 @@
|
|||
import React from 'preact/compat';
|
||||
import { useState, useRef, useEffect } from 'preact/hooks';
|
||||
import Environment from '../Environment';
|
||||
import DOMWidget from './DOMWidget';
|
||||
import DOMWidget from './widgets/DOMWidget';
|
||||
import setPosition from './setPosition';
|
||||
import i18n from '../i18n';
|
||||
|
||||
|
@ -139,32 +139,21 @@ const Editor = props => {
|
|||
}
|
||||
};
|
||||
|
||||
const widgets = props.widget ? props.widgets.map(fn => <DOMWidget widget={fn} />) : [];
|
||||
const widgets = props.widgets ? props.widgets.map(fn => <DOMWidget widget={fn} />) : [];
|
||||
|
||||
return (
|
||||
<div ref={element} className="r6o-editor">
|
||||
<div className="arrow" />
|
||||
<div className="inner">
|
||||
{React.Children.map(props.children, child =>
|
||||
React.cloneElement(child, {
|
||||
...child.props,
|
||||
annotation : currentAnnotation,
|
||||
readOnly : props.readOnly,
|
||||
onAppendBody,
|
||||
onUpdateBody,
|
||||
onRemoveBody,
|
||||
onSaveAndClose : onOk
|
||||
}))
|
||||
}
|
||||
|
||||
{widgets.map(widget =>
|
||||
React.cloneElement(widget, {
|
||||
annotation : currentAnnotation,
|
||||
readOnly : props.readOnly,
|
||||
config: props.config,
|
||||
onAppendBody,
|
||||
onUpdateBody,
|
||||
onRemoveBody,
|
||||
onSaveAndClose : onOk
|
||||
onSaveAndClose: onOk
|
||||
})
|
||||
)}
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ import Editor from './Editor';
|
|||
import CommentWidget from './widgets/comment/CommentWidget';
|
||||
import TagWidget from './widgets/tag/TagWidget';
|
||||
|
||||
/** Standard widgets included by default **/
|
||||
const DEFAULT_WIDGETS = {
|
||||
COMMENT: CommentWidget,
|
||||
TAG: TagWidget
|
||||
};
|
||||
|
||||
Editor.CommentWidget = CommentWidget;
|
||||
Editor.TagWidget = TagWidget;
|
||||
|
||||
|
|
Loading…
Reference in New Issue