mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 04:11:50 +03:00
added show schedule and remove function as part 1
This commit is contained in:
parent
ca875a3dc1
commit
d56469919d
@ -57,7 +57,7 @@ class CommentsView extends PureComponent {
|
||||
handleOnUserPress={handleOnUserPress}
|
||||
isLoggedIn={isLoggedIn}
|
||||
isShowMoreButton={commentNumber === 1 && item.children > 0}
|
||||
voteCount={item.vote_count}
|
||||
voteCount={item.net_votes}
|
||||
isShowSubComments={isShowSubComments}
|
||||
key={item.permlink}
|
||||
marginLeft={marginLeft}
|
||||
|
@ -9,6 +9,7 @@ export default {
|
||||
'ko-KR': require('./ko-KR.json'),
|
||||
'lt-LT': require('./lt-LT.json'),
|
||||
'pt-PT': require('./pt-PT.json'),
|
||||
'fa-IR': require('./fa-IR.json'),
|
||||
};
|
||||
|
||||
export const locales = [
|
||||
@ -22,4 +23,5 @@ export const locales = [
|
||||
{ id: 'ko-KR', name: 'Korean' },
|
||||
{ id: 'lt-LT', name: 'Lithuanian' },
|
||||
{ id: 'pt-PT', name: 'Porteguese' },
|
||||
{ id: 'fa-IR', name: 'Persian' },
|
||||
];
|
||||
|
@ -8,6 +8,7 @@ export default [
|
||||
'Porteguese',
|
||||
'Russian',
|
||||
'Turkish',
|
||||
'Persian',
|
||||
];
|
||||
|
||||
export const VALUE = [
|
||||
@ -20,4 +21,5 @@ export const VALUE = [
|
||||
'pt-PT',
|
||||
'ru-RU',
|
||||
'tr-TR',
|
||||
'fa-IR',
|
||||
];
|
||||
|
@ -223,7 +223,7 @@ export const schedule = (
|
||||
upvote,
|
||||
scheduleDate,
|
||||
) => api
|
||||
.post('/api/schedules', {
|
||||
.post('/schedules', {
|
||||
username: user,
|
||||
category: tags[0],
|
||||
title,
|
||||
@ -238,18 +238,18 @@ export const schedule = (
|
||||
})
|
||||
.then(resp => resp.data);
|
||||
|
||||
export const getSchedules = user => api.get(`/api/schedules/${user}`).then(resp => resp.data);
|
||||
export const getSchedules = user => api.get(`/schedules/${user}`).then(resp => resp.data);
|
||||
|
||||
export const removeSchedule = (id, user) => api.delete(`/api/schedules/${user}/${id}`);
|
||||
export const removeSchedule = (user, id) => api.delete(`/schedules/${user}/${id}`);
|
||||
|
||||
export const moveSchedule = (id, user) => api.put(`/api/schedules/${user}/${id}`);
|
||||
export const moveSchedule = (id, user) => api.put(`/schedules/${user}/${id}`);
|
||||
|
||||
// Old image service
|
||||
// Images
|
||||
|
||||
export const getImages = user => api.get(`api/images/${user}`).then(resp => resp.data);
|
||||
|
||||
export const addMyImage = (user, url) => api.post('/api/image', { username: user, image_url: url });
|
||||
export const addMyImage = (user, url) => api.post('/image', { username: user, image_url: url });
|
||||
|
||||
export const uploadImage = (file) => {
|
||||
const fData = new FormData();
|
||||
|
@ -192,7 +192,7 @@ export const getFollowSearch = (user, targetUser) => new Promise((resolve, rejec
|
||||
});
|
||||
});
|
||||
|
||||
export const getIsMuted = async (username, targetUsername) => {
|
||||
export const getIsMuted = async (targetUsername, username) => {
|
||||
let resp;
|
||||
|
||||
try {
|
||||
|
@ -1,7 +1,5 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
Platform, BackHandler, Alert, NetInfo,
|
||||
} from 'react-native';
|
||||
import { Platform, BackHandler, Alert, NetInfo } from 'react-native';
|
||||
import { connect } from 'react-redux';
|
||||
import { addLocaleData } from 'react-intl';
|
||||
import Config from 'react-native-config';
|
||||
@ -20,6 +18,8 @@ import tr from 'react-intl/locale-data/tr';
|
||||
import ko from 'react-intl/locale-data/ko';
|
||||
import lt from 'react-intl/locale-data/lt';
|
||||
import pt from 'react-intl/locale-data/pt';
|
||||
import fa from 'react-intl/locale-data/fa';
|
||||
import he from 'react-intl/locale-data/he';
|
||||
|
||||
// Constants
|
||||
import AUTH_TYPE from '../../../constants/authType';
|
||||
@ -71,7 +71,7 @@ import {
|
||||
import ApplicationScreen from '../screen/applicationScreen';
|
||||
import { Launch } from '../..';
|
||||
|
||||
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt]);
|
||||
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
|
||||
|
||||
class ApplicationContainer extends Component {
|
||||
constructor() {
|
||||
@ -87,7 +87,7 @@ class ApplicationContainer extends Component {
|
||||
const { isIos } = this.state;
|
||||
let isConnected;
|
||||
|
||||
await NetInfo.isConnected.fetch().then((_isConnected) => {
|
||||
await NetInfo.isConnected.fetch().then(_isConnected => {
|
||||
isConnected = _isConnected;
|
||||
});
|
||||
|
||||
@ -104,9 +104,7 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {
|
||||
isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected,
|
||||
} = this.props;
|
||||
const { isDarkTheme: _isDarkTheme, selectedLanguage, isLogingOut, isConnected } = this.props;
|
||||
|
||||
if (_isDarkTheme !== nextProps.isDarkTheme || selectedLanguage !== nextProps.selectedLanguage) {
|
||||
this.setState({ isRenderRequire: false }, () => this.setState({ isRenderRequire: true }));
|
||||
@ -136,7 +134,7 @@ class ApplicationContainer extends Component {
|
||||
await this._getUserData();
|
||||
};
|
||||
|
||||
_handleConntectionChange = (status) => {
|
||||
_handleConntectionChange = status => {
|
||||
const { dispatch, isConnected } = this.props;
|
||||
|
||||
if (isConnected !== status) {
|
||||
@ -170,19 +168,19 @@ class ApplicationContainer extends Component {
|
||||
let realmData = [];
|
||||
let currentUsername;
|
||||
|
||||
await getAuthStatus().then((res) => {
|
||||
await getAuthStatus().then(res => {
|
||||
({ currentUsername } = res);
|
||||
if (res) {
|
||||
getUserData().then(async (userData) => {
|
||||
getUserData().then(async userData => {
|
||||
if (userData.length > 0) {
|
||||
realmData = userData;
|
||||
userData.forEach((accountData, index) => {
|
||||
if (
|
||||
!accountData.accessToken
|
||||
&& !accountData.masterKey
|
||||
&& !accountData.postingKey
|
||||
&& !accountData.activeKey
|
||||
&& !accountData.memoKey
|
||||
!accountData.accessToken &&
|
||||
!accountData.masterKey &&
|
||||
!accountData.postingKey &&
|
||||
!accountData.activeKey &&
|
||||
!accountData.memoKey
|
||||
) {
|
||||
realmData.splice(index, 1);
|
||||
if (realmData.length === 0) {
|
||||
@ -213,7 +211,7 @@ class ApplicationContainer extends Component {
|
||||
await switchAccount(realmObject[0].username);
|
||||
}
|
||||
await getUser(realmObject[0].username)
|
||||
.then(async (accountData) => {
|
||||
.then(async accountData => {
|
||||
dispatch(login(true));
|
||||
|
||||
const isExistUser = await getExistUser();
|
||||
@ -227,7 +225,7 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
this._connectNotificationServer(accountData.name);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
Alert.alert(err);
|
||||
});
|
||||
}
|
||||
@ -239,15 +237,18 @@ class ApplicationContainer extends Component {
|
||||
_getSettings = () => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
getSettings().then((response) => {
|
||||
getSettings().then(response => {
|
||||
if (response) {
|
||||
if (response.isDarkTheme !== '') dispatch(isDarkTheme(response.isDarkTheme));
|
||||
if (response.language !== '') dispatch(setLanguage(response.language));
|
||||
if (response.server !== '') dispatch(setApi(response.server));
|
||||
if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent)));
|
||||
if (response.upvotePercent !== '')
|
||||
dispatch(setUpvotePercent(Number(response.upvotePercent)));
|
||||
if (response.isDefaultFooter !== '') dispatch(isDefaultFooter(response.isDefaultFooter));
|
||||
if (response.notification !== '') {
|
||||
dispatch(changeNotificationSettings({ type: 'notification', action: response.notification }));
|
||||
dispatch(
|
||||
changeNotificationSettings({ type: 'notification', action: response.notification }),
|
||||
);
|
||||
dispatch(changeAllNotificationSettings(response));
|
||||
|
||||
Push.setEnabled(response.notification);
|
||||
@ -261,7 +262,7 @@ class ApplicationContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_connectNotificationServer = (username) => {
|
||||
_connectNotificationServer = username => {
|
||||
const { dispatch, unreadActivityCount } = this.props;
|
||||
const ws = new WebSocket(`${Config.ACTIVITY_WEBSOCKET_URL}?user=${username}`);
|
||||
|
||||
@ -299,10 +300,10 @@ class ApplicationContainer extends Component {
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
_switchAccount = async (targetAccountUsername) => {
|
||||
_switchAccount = async targetAccountUsername => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
await switchAccount(targetAccountUsername).then((accountData) => {
|
||||
await switchAccount(targetAccountUsername).then(accountData => {
|
||||
const realmData = getUserDataWithUsername(targetAccountUsername);
|
||||
const _currentAccount = accountData;
|
||||
_currentAccount.username = accountData.name;
|
||||
|
@ -4,7 +4,9 @@ import { Alert } from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
// Services and Actions
|
||||
import { getDrafts, removeDraft, getSchedules } from '../../../providers/esteem/esteem';
|
||||
import {
|
||||
getDrafts, removeDraft, getSchedules, removeSchedule,
|
||||
} from '../../../providers/esteem/esteem';
|
||||
|
||||
// Middleware
|
||||
|
||||
@ -35,6 +37,7 @@ class DraftsContainer extends Component {
|
||||
// Component Life Cycle Functions
|
||||
componentDidMount() {
|
||||
this._getDrafts();
|
||||
this._getSchedules();
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
@ -82,6 +85,21 @@ class DraftsContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_removeSchedule = (id) => {
|
||||
const { currentAccount, intl } = this.props;
|
||||
|
||||
removeSchedule({ username: currentAccount.name, draftId: id })
|
||||
.then(() => {
|
||||
const { schedules } = this.state;
|
||||
const newSchedules = [...schedules].filter(schedule => schedule._id !== id);
|
||||
|
||||
this.setState({ schedules: this._sortData(newSchedules) });
|
||||
})
|
||||
.catch(() => {
|
||||
Alert.alert(intl.formatMessage({ id: 'alert.fail' }));
|
||||
});
|
||||
};
|
||||
|
||||
_editDraft = (id) => {
|
||||
const { navigation } = this.props;
|
||||
const { drafts } = this.state;
|
||||
@ -115,6 +133,7 @@ class DraftsContainer extends Component {
|
||||
drafts={drafts}
|
||||
schedules={schedules}
|
||||
removeDraft={this._removeDraft}
|
||||
removeSchedule={this._removeSchedule}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ class DraftsScreen extends Component {
|
||||
|
||||
// Component Functions
|
||||
|
||||
_renderItem = (item) => {
|
||||
const { currentAccount, removeDraft, editDraft } = this.props;
|
||||
_renderItem = (item, type) => {
|
||||
const {
|
||||
currentAccount, removeDraft, editDraft, removeSchedule,
|
||||
} = this.props;
|
||||
const tags = item.tags ? item.tags.split(/[ ,]+/) : [];
|
||||
const tag = tags[0] || '';
|
||||
const image = catchDraftImage(item.body);
|
||||
@ -50,7 +52,7 @@ class DraftsScreen extends Component {
|
||||
username={currentAccount.name}
|
||||
reputation={currentAccount.reputation}
|
||||
handleOnPressItem={editDraft}
|
||||
handleOnRemoveItem={removeDraft}
|
||||
handleOnRemoveItem={type === 'schedules' ? removeSchedule : removeDraft}
|
||||
id={item._id}
|
||||
/>
|
||||
);
|
||||
@ -80,7 +82,7 @@ class DraftsScreen extends Component {
|
||||
data={data}
|
||||
keyExtractor={item => item._id}
|
||||
removeClippedSubviews={false}
|
||||
renderItem={({ item }) => this._renderItem(item)}
|
||||
renderItem={({ item }) => this._renderItem(item, type)}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
|
@ -76,7 +76,10 @@ class ProfileContainer extends Component {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {
|
||||
navigation, currentAccount, activeBottomTab, isLoggedIn,
|
||||
navigation,
|
||||
currentAccount,
|
||||
activeBottomTab,
|
||||
isLoggedIn,
|
||||
} = this.props;
|
||||
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name;
|
||||
|
||||
@ -115,34 +118,37 @@ class ProfileContainer extends Component {
|
||||
};
|
||||
|
||||
_handleFollowUnfollowUser = async (isFollowAction) => {
|
||||
const { username, isFollowing } = this.state;
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
const { isFollowing } = this.state;
|
||||
|
||||
this.setState({
|
||||
isProfileLoading: true,
|
||||
});
|
||||
|
||||
if (isFollowAction && !isFollowing) {
|
||||
this._followUser(currentAccount, pinCode, currentAccount.name, username);
|
||||
this._followUser();
|
||||
} else {
|
||||
this._unfollowUser(currentAccount, pinCode, currentAccount.name, username);
|
||||
this._unfollowUser();
|
||||
}
|
||||
};
|
||||
|
||||
_handleMuteUnmuteUser = async (isMuteAction) => {
|
||||
const { username } = this.state;
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
|
||||
_handleMuteUnmuteUser = (isMuteAction) => {
|
||||
this.setState({
|
||||
isProfileLoading: true,
|
||||
});
|
||||
|
||||
if (isMuteAction) {
|
||||
this._muteUser(currentAccount, pinCode, currentAccount.name, username);
|
||||
this._muteUser();
|
||||
} else {
|
||||
this._unfollowUser();
|
||||
}
|
||||
};
|
||||
|
||||
_unfollowUser = (currentAccount, pinCode, follower, following) => {
|
||||
_unfollowUser = () => {
|
||||
const { username } = this.state;
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
const follower = currentAccount.name;
|
||||
const following = username;
|
||||
|
||||
unfollowUser(currentAccount, pinCode, {
|
||||
follower,
|
||||
following,
|
||||
@ -155,7 +161,12 @@ class ProfileContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_followUser = (currentAccount, pinCode, follower, following) => {
|
||||
_followUser = () => {
|
||||
const { username } = this.state;
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
const follower = currentAccount.name;
|
||||
const following = username;
|
||||
|
||||
followUser(currentAccount, pinCode, {
|
||||
follower,
|
||||
following,
|
||||
@ -168,7 +179,12 @@ class ProfileContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_muteUser = async (currentAccount, pinCode, follower, following) => {
|
||||
_muteUser = () => {
|
||||
const { username } = this.state;
|
||||
const { currentAccount, pinCode } = this.props;
|
||||
const follower = currentAccount.name;
|
||||
const following = username;
|
||||
|
||||
ignoreUser(currentAccount, pinCode, {
|
||||
follower,
|
||||
following,
|
||||
@ -184,32 +200,32 @@ class ProfileContainer extends Component {
|
||||
_profileActionDone = (error = null) => {
|
||||
const { username } = this.state;
|
||||
|
||||
this.setState({
|
||||
isProfileLoading: false,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
this.setState({
|
||||
error,
|
||||
});
|
||||
alert(error);
|
||||
}, () => alert(error));
|
||||
} else {
|
||||
this._fetchProfile(username);
|
||||
this._fetchProfile(username, true);
|
||||
}
|
||||
};
|
||||
|
||||
_fetchProfile = async (username = null) => {
|
||||
|
||||
_fetchProfile = async (username = null, isProfileAction = false) => {
|
||||
const {
|
||||
username: _username, isFollowing, isMuted,
|
||||
} = this.state;
|
||||
|
||||
if (username) {
|
||||
const { isLoggedIn, currentAccount } = this.props;
|
||||
let isFollowing;
|
||||
let isMuted;
|
||||
let _isFollowing;
|
||||
let _isMuted;
|
||||
let isFavorite;
|
||||
let follows;
|
||||
|
||||
if (isLoggedIn && currentAccount.name !== username) {
|
||||
isFollowing = await getIsFollowing(username, currentAccount.name);
|
||||
_isFollowing = await getIsFollowing(username, currentAccount.name);
|
||||
|
||||
isMuted = isFollowing ? false : await getIsMuted(username, currentAccount.name);
|
||||
_isMuted = _isFollowing ? false : await getIsMuted(username, currentAccount.name);
|
||||
|
||||
getIsFavorite(username, currentAccount.name).then((isFav) => {
|
||||
isFavorite = isFav;
|
||||
@ -222,14 +238,23 @@ class ProfileContainer extends Component {
|
||||
follows = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This follow code totally a work arround
|
||||
* Ceated for server response delay.
|
||||
*/
|
||||
if (isProfileAction && (isFollowing === _isFollowing && isMuted === _isMuted)) {
|
||||
this._fetchProfile(_username, true);
|
||||
} else {
|
||||
this.setState({
|
||||
follows,
|
||||
isFollowing,
|
||||
isMuted,
|
||||
isFollowing: _isFollowing,
|
||||
isMuted: _isMuted,
|
||||
isFavorite,
|
||||
isReady: true,
|
||||
isProfileLoading: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_loadProfile = async (selectedUser = null) => {
|
||||
@ -337,6 +362,7 @@ class ProfileContainer extends Component {
|
||||
return (
|
||||
<ProfileScreen
|
||||
about={user && user.about && user.about.profile}
|
||||
activePage={activePage}
|
||||
avatar={avatar}
|
||||
comments={comments}
|
||||
currency={currency}
|
||||
@ -359,7 +385,6 @@ class ProfileContainer extends Component {
|
||||
selectedQuickProfile={selectedQuickProfile}
|
||||
selectedUser={user}
|
||||
username={username}
|
||||
activePage={activePage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ const imgTagRegex = /(<img[^>]*>)/g;
|
||||
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
|
||||
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
|
||||
|
||||
export const markDown2Html = (input) => {
|
||||
export const markDown2Html = input => {
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
@ -95,22 +95,25 @@ export const markDown2Html = (input) => {
|
||||
return output;
|
||||
};
|
||||
|
||||
const replaceAuthorNames = input => input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
||||
const replaceAuthorNames = input =>
|
||||
input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
|
||||
const userLower = user.toLowerCase();
|
||||
const preceedings = (preceeding1 || '') + (preceeding2 || '');
|
||||
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
|
||||
});
|
||||
});
|
||||
|
||||
const replaceTags = input => input.replace(tagsRegex, (tag) => {
|
||||
const replaceTags = input =>
|
||||
input.replace(tagsRegex, tag => {
|
||||
if (/#[\d]+$/.test(tag)) return tag;
|
||||
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
|
||||
tag = tag.replace('>', '');
|
||||
const tag2 = tag.trim().substring(1);
|
||||
const tagLower = tag2.toLowerCase();
|
||||
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
|
||||
});
|
||||
});
|
||||
|
||||
const handleATag = input => input.replace(aTagRegex, (link) => {
|
||||
const handleATag = input =>
|
||||
input.replace(aTagRegex, link => {
|
||||
if (dTubeRegex.test(link)) {
|
||||
const dTubeMatch = link.match(dTubeRegex)[0];
|
||||
const execLink = dTubeRegex.exec(dTubeMatch);
|
||||
@ -133,11 +136,12 @@ const handleATag = input => input.replace(aTagRegex, (link) => {
|
||||
}
|
||||
|
||||
return link;
|
||||
});
|
||||
});
|
||||
|
||||
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
|
||||
|
||||
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
||||
const handleMarkdownLink = input =>
|
||||
input.replace(copiedPostRegex, link => {
|
||||
const postMatch = link.match(copiedPostRegex);
|
||||
|
||||
if (postMatch) {
|
||||
@ -147,23 +151,25 @@ const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
|
||||
tag = 'busy';
|
||||
}
|
||||
|
||||
const _permlink = postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
||||
const _permlink =
|
||||
postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
|
||||
|
||||
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
|
||||
'@',
|
||||
'',
|
||||
)}">/${_permlink}</a>`;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const handleLinks = input => input.replace(linkRegex, (link) => {
|
||||
const handleLinks = input =>
|
||||
input.replace(linkRegex, link => {
|
||||
if (link) {
|
||||
if (
|
||||
link
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.indexOf('https://steemitimages.com/0x0/') === 0
|
||||
|| imgRegex.test(link)
|
||||
.indexOf('https://steemitimages.com/0x0/') === 0 ||
|
||||
imgRegex.test(link)
|
||||
) {
|
||||
const imageMatch = link.match(imgRegex);
|
||||
|
||||
@ -191,9 +197,10 @@ const handleLinks = input => input.replace(linkRegex, (link) => {
|
||||
}
|
||||
|
||||
return link;
|
||||
});
|
||||
});
|
||||
|
||||
const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => {
|
||||
const changeMarkdownImage = input =>
|
||||
input.replace(markdownImageRegex, link => {
|
||||
const markdownMatch = link.match(markdownImageRegex);
|
||||
if (markdownMatch[0]) {
|
||||
const firstMarkdownMatch = markdownMatch[0];
|
||||
@ -202,23 +209,26 @@ const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) =>
|
||||
return _link;
|
||||
}
|
||||
return link;
|
||||
});
|
||||
});
|
||||
|
||||
const centerStyling = input => input.replace(
|
||||
const centerStyling = input =>
|
||||
input.replace(
|
||||
centerRegex,
|
||||
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
|
||||
);
|
||||
);
|
||||
|
||||
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
||||
const steemitUrlHandle = input =>
|
||||
input.replace(postRegex, link => {
|
||||
const postMatch = link.match(postRegex);
|
||||
const tag = postMatch[2];
|
||||
const author = postMatch[3].replace('@', '');
|
||||
const permlink = postMatch[4];
|
||||
|
||||
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
||||
});
|
||||
});
|
||||
|
||||
const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
||||
const handleImageTag = input =>
|
||||
input.replace(imgTagRegex, imgTag => {
|
||||
const _imgTag = imgTag.trim();
|
||||
const match = _imgTag.match(imgRegex);
|
||||
|
||||
@ -227,9 +237,14 @@ const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
|
||||
}
|
||||
|
||||
return imgTag;
|
||||
});
|
||||
});
|
||||
|
||||
const createYoutubeIframe = input =>
|
||||
input.replace(youTubeRegex, link => {
|
||||
if (link.indexOf(')') || link.indexOf('(')) {
|
||||
return link;
|
||||
}
|
||||
|
||||
const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
||||
const execVideo = youTubeRegex.exec(link);
|
||||
const match = link.match(youTubeRegex);
|
||||
|
||||
@ -241,9 +256,10 @@ const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
|
||||
}
|
||||
|
||||
return link;
|
||||
});
|
||||
});
|
||||
|
||||
const handleIframe = input => input.replace(iframeRegex, (link) => {
|
||||
const handleIframe = input =>
|
||||
input.replace(iframeRegex, link => {
|
||||
const match = link.match(linkRegex);
|
||||
|
||||
if (match && match[0]) {
|
||||
@ -251,21 +267,22 @@ const handleIframe = input => input.replace(iframeRegex, (link) => {
|
||||
}
|
||||
|
||||
return link;
|
||||
});
|
||||
});
|
||||
|
||||
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
|
||||
const createVimeoIframe = input =>
|
||||
input.replace(vimeoRegex, link => {
|
||||
const execLink = vimeoRegex.exec(link);
|
||||
|
||||
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
|
||||
|
||||
return iframeBody(embedLink);
|
||||
});
|
||||
|
||||
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
||||
});
|
||||
|
||||
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
|
||||
const imageBody = link => `<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
||||
const imageBody = link =>
|
||||
`<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
|
||||
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
|
||||
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));
|
||||
|
||||
// const handleCodeTag = input => input.replace(codeTagRegex, (tag) => {
|
||||
// const stringsRegex = /(?<=>)(.*)(?=<)/g;
|
||||
|
Loading…
Reference in New Issue
Block a user