if (!context.accountId) { return ""; } const item = props.item; if (!context.accountId) { return ""; } const composeData = () => { const data = { post: { comment: JSON.stringify(Object.assign({ item }, state.content)), }, index: { comment: JSON.stringify({ key: item, value: { type: "md", }, }), }, }; const notifications = state.extractTagNotifications(state.content.text, { type: "social", path: `${context.accountId}/question/answer`, }); if (props.notifyAccountId) { notifications.push({ key: props.notifyAccountId, value: { type: "answer", item, }, }); } if (notifications.length) { data.index.notify = JSON.stringify( notifications.length > 1 ? notifications : notifications[0] ); } return data; }; State.init({ onChange: ({ content }) => { State.update({ content }); }, }); return ( <> <Widget src="mob.near/widget/Common.Compose" props={{ placeholder: "Reply", initialText: props.initialText, onChange: state.onChange, onHelper: ({ extractTagNotifications }) => { State.update({ extractTagNotifications }); }, composeButton: (onCompose) => ( <CommitButton disabled={!state.content} force className="btn btn-dark rounded-3" data={composeData} onCommit={() => { onCompose(); props.onComment && props.onComment(state.content); }} > Answer </CommitButton> ), }} /> </> );