mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-24 08:55:14 +03:00
fixed image upload issue
This commit is contained in:
parent
2029888b21
commit
11360071cb
@ -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 });
|
||||
}
|
||||
})
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user