fixed image upload issue

This commit is contained in:
u-e 2018-12-28 17:06:24 +03:00
parent 2029888b21
commit 11360071cb
2 changed files with 21 additions and 7 deletions

View File

@ -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 });
}
})

View File

@ -21,6 +21,7 @@ const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/
const aTagRegex = /(<\s*a[^>]*>(.*?)<\s*[/]\s*a>)/g;
const imgTagRegex = /(<img[^>]*>)/g;
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
const codeTagRegex= /(?:<code[^>]*)(?:(?:\/>)|(?:>.*?<\/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, () => '<center style="text-align:center;">');
const handleCodeTag = input => input.replace(codeTagRegex, (tag) => {
const stringsRegex = /(?<=>)(.*)(?=<)/g;
const match = tag.match(stringsRegex);
if (match && match[0]) {
return `<p class="code" >${match[0]}</p>`;
}
return iframeBody(match[0]);
});
const createCenterImage = input => input.replace(imgCenterRegex, (link) => {
let _link = link;