From e75a28bb0dea6b79895e5efe3c01631935d026d9 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Sun, 12 Jun 2016 00:52:30 +0200 Subject: [PATCH] Minimal house cleaning --- src/RichText.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/RichText.js b/src/RichText.js index d218e698a6..c0d80d2ec7 100644 --- a/src/RichText.js +++ b/src/RichText.js @@ -21,6 +21,15 @@ const STYLES = { UNDERLINE: 'u' }; +const MARKDOWN_REGEX = { + LINK: /(?:\[([^\]]+)\]\(([^\)]+)\))|\<(\w+:\/\/[^\>]+)\>/g, + ITALIC: /([\*_])([\w\s]+?)\1/g, + BOLD: /([\*_])\1([\w\s]+?)\1\1/g +}; + +const USERNAME_REGEX = /@\S+:\S+/g; +const ROOM_REGEX = /#\S+:\S+/g; + export function contentStateToHTML(contentState: ContentState): string { return contentState.getBlockMap().map((block) => { let elem = BLOCK_RENDER_MAP.get(block.getType()).element; @@ -46,9 +55,6 @@ export function HTMLtoContentState(html: string): ContentState { return ContentState.createFromBlockArray(convertFromHTML(html)); } -const USERNAME_REGEX = /@\S+:\S+/g; -const ROOM_REGEX = /#\S+:\S+/g; - /** * Returns a composite decorator which has access to provided scope. */ @@ -108,12 +114,6 @@ export function getScopedMDDecorators(scope: any): CompositeDecorator { return markdownDecorators; } -const MARKDOWN_REGEX = { - LINK: /(?:\[([^\]]+)\]\(([^\)]+)\))|\<(\w+:\/\/[^\>]+)\>/g, - ITALIC: /([\*_])([\w\s]+?)\1/g, - BOLD: /([\*_])\1([\w\s]+?)\1\1/g -}; - /** * Utility function that looks for regex matches within a ContentBlock and invokes {callback} with (start, end) * From https://facebook.github.io/draft-js/docs/advanced-topics-decorators.html