diff --git a/src/screens/editor/container/editorContainer.js b/src/screens/editor/container/editorContainer.js index 8a60c122a..31dac8b0a 100644 --- a/src/screens/editor/container/editorContainer.js +++ b/src/screens/editor/container/editorContainer.js @@ -103,7 +103,7 @@ class EditorContainer extends Component { // height: 400, // cropping: true, // writeTempFile: true, - // includeBase64: true, + includeBase64: true, // multiple: true, }) .then((image) => { @@ -119,7 +119,7 @@ class EditorContainer extends Component { // width: 300, // height: 400, // cropping: true, - // includeBase64: true, + includeBase64: true, }) .then((image) => { this._handleMediaOnSelected(image); @@ -145,16 +145,13 @@ class EditorContainer extends Component { const file = { uri: media.path, type: media.mime, - name: media.filename, + name: media.filename || `IMG_${Math.random()}.JPG`, size: media.size, - source: media.sourceURL, - // data: `data:${media.mime};base64,${media.data}`, - // base64: media.data, }; uploadImage(file) .then((res) => { - if (res.data) { + if (res.data && res.data.url) { this.setState({ uploadedImage: res.data, isUploading: false }); } }) diff --git a/src/utils/markdownToHtml.js b/src/utils/markdownToHtml.js index 41651c050..122392a0c 100644 --- a/src/utils/markdownToHtml.js +++ b/src/utils/markdownToHtml.js @@ -21,6 +21,7 @@ const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/ const aTagRegex = /(<\s*a[^>]*>(.*?)<\s*[/]\s*a>)/g; const imgTagRegex = /(]*>)/g; const iframeRegex = /(?:]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g; +const codeTagRegex= /(?:]*)(?:(?:\/>)|(?:>.*?<\/code>))/g; export const markDown2Html = (input) => { if (!input) { @@ -68,6 +69,10 @@ export const markDown2Html = (input) => { output = handleIframe(output); } + if (codeTagRegex.test(output)) { + output = handleCodeTag(output); + } + if (linkRegex.test(output)) { output = handleLinks(output); } @@ -154,6 +159,18 @@ const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => const centerStyling = input => input.replace(centerRegex, () => '
'); +const handleCodeTag = input => input.replace(codeTagRegex, (tag) => { + const stringsRegex = /(?<=>)(.*)(?=<)/g; + const match = tag.match(stringsRegex); + + if (match && match[0]) { + return `

${match[0]}

`; + } + + return iframeBody(match[0]); + +}); + const createCenterImage = input => input.replace(imgCenterRegex, (link) => { let _link = link;