diff --git a/package.json b/package.json index 430a1ec2..84520aeb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matters/matters-editor", - "version": "0.1.27-alpha.0", + "version": "0.1.27-alpha.1", "description": "The editor component.", "author": "https://github.com/thematters", "homepage": "https://github.com/thematters/matters-editor", diff --git a/src/article.tsx b/src/article.tsx index 7b3cb25b..59fd2faf 100644 --- a/src/article.tsx +++ b/src/article.tsx @@ -97,6 +97,7 @@ export class MattersArticleEditor extends React.Component { componentDidUpdate(prevProps: Props, prevState: State) { this.instance = this.initQuillInstance() + this.resetLinkInputPlaceholder() initAudioPlayers() @@ -260,19 +261,21 @@ export class MattersArticleEditor extends React.Component { update={this.props.editorUpdate} />
- + {this.mentionReference.current && ( + + )} { mentionSelection={this.handleMentionSelection} mentionUsers={this.props.mentionUsers} reference={this.mentionReference} + // FIXME: force update state to re-render + onMount={() => this.setState({ content: this.state.content })} />
diff --git a/src/components/Mention/index.tsx b/src/components/Mention/index.tsx index 1e9b4060..5adc58c2 100644 --- a/src/components/Mention/index.tsx +++ b/src/components/Mention/index.tsx @@ -1,6 +1,4 @@ -import React from 'react' - -import SVGSpinner from '../../icons/Spinner' +import React, { useEffect } from 'react' /** * This component is a mention list container which will be visible when typing `@`. @@ -20,6 +18,7 @@ interface Props { mentionSelection: any mentionUsers: any[] reference: React.RefObject + onMount: () => any } export default ({ @@ -28,9 +27,14 @@ export default ({ mentionSelection, mentionUsers, reference, + onMount, }: Props) => { const hasMention = mentionUsers.length <= 0 && !mentionLoading + useEffect(() => { + onMount() + }, []) + return (
{hasMention diff --git a/src/utils/soap.ts b/src/utils/soap.ts index 2f806d2d..c69cecfe 100644 --- a/src/utils/soap.ts +++ b/src/utils/soap.ts @@ -5,21 +5,22 @@ const docsId = /id="docs\-internal\-guid/ // for copying from GoogleDoc export function soap(html: string) { - if (!html.match(docsId)) return html const doc = parseHTML(html) // GoogleDoc seems always wrap the clipboard under a `` tag with "font-weight:normal;" // ... - if (doc?.children?.length > 0 - && doc.children[0] instanceof Node - && doc.children[0].nodeType === Node.ELEMENT_NODE + if ( + doc?.children?.length > 0 && + doc.children[0] instanceof Node && + doc.children[0].nodeType === Node.ELEMENT_NODE ) { const node = doc.children[0] as HTMLElement - if (node.tagName === 'B' - && node.style?.fontWeight === 'normal' - && node.id?.match(/^docs-internal-guid-/) + if ( + node.tagName === 'B' && + node.style?.fontWeight === 'normal' && + node.id?.match(/^docs-internal-guid-/) ) { const body = document.createElement('body') body.append(...node.children)