mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 11:21:41 +03:00
clean up
This commit is contained in:
parent
944237fd99
commit
d94d2f310d
@ -1,44 +0,0 @@
|
||||
import { isStringWebLink, replaceBetween } from './utils';
|
||||
|
||||
export const writeUrlTextHere = 'https://example.com';
|
||||
export const writeTextHereString = 'Text here';
|
||||
|
||||
export default async ({ text, selection, setTextAndSelection, item, isImage = null }) => {
|
||||
const imagePrefix = isImage ? '!' : '';
|
||||
const itemText = item ? item.text : writeTextHereString;
|
||||
const itemUrl = item ? item.url : writeUrlTextHere;
|
||||
let newText;
|
||||
let newSelection;
|
||||
const selectedText = text.substring(selection.start, selection.end);
|
||||
|
||||
if (selection.start !== selection.end) {
|
||||
if (isStringWebLink(selectedText)) {
|
||||
newText = replaceBetween(text, selection, `\n${imagePrefix}[${itemText}](${selectedText})\n`);
|
||||
newSelection = {
|
||||
start: selection.start + 1,
|
||||
end: selection.start + 1 + itemText && itemText.length,
|
||||
};
|
||||
} else {
|
||||
newText = replaceBetween(text, selection, `\n${imagePrefix}[${selectedText}](${itemUrl})\n`);
|
||||
newSelection = {
|
||||
start: selection.end + 3,
|
||||
end: selection.end + 3 + itemUrl.length,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
newText = replaceBetween(text, selection, `\n${imagePrefix}[${itemText}](${itemUrl})\n`);
|
||||
if (isImage) {
|
||||
newSelection = {
|
||||
start: newText && newText.length,
|
||||
end: newText && newText.length,
|
||||
};
|
||||
} else {
|
||||
newSelection = {
|
||||
start: selection.start + 1,
|
||||
end: selection.start + 1 + (itemText && itemText.length),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
setTextAndSelection({ text: newText, selection: newSelection });
|
||||
};
|
@ -2,7 +2,6 @@ import applyWrapFormat from './applyWrapFormat';
|
||||
import applyWrapFormatNewLines from './applyWrapFormatNewLines';
|
||||
import applyListFormat from './applyListFormat';
|
||||
import applyWebLinkFormat from './applyWebLinkFormat';
|
||||
import applySnippetFormat from './applySnippetFormat';
|
||||
|
||||
export default [
|
||||
{
|
||||
@ -36,9 +35,4 @@ export default [
|
||||
title: 'WEB',
|
||||
onPress: applyWebLinkFormat,
|
||||
},
|
||||
{
|
||||
key: 'snippet',
|
||||
title: 'SNIPPET',
|
||||
onPress: applySnippetFormat,
|
||||
},
|
||||
];
|
||||
|
@ -4,7 +4,7 @@ import { useIntl } from 'react-intl';
|
||||
|
||||
import { getSnippets } from '../../providers/ecency/ecency';
|
||||
|
||||
import { FormInput, MainButton, Tag, ListPlaceHolder } from '..';
|
||||
import { ListPlaceHolder } from '..';
|
||||
|
||||
import styles from './snippetsModalStyles';
|
||||
|
||||
|
@ -6,19 +6,19 @@ export default EStyleSheet.create({
|
||||
justifyContent: 'space-between',
|
||||
padding: 16,
|
||||
},
|
||||
bodyWrapper: { flex: 3, paddingTop: 20 },
|
||||
inputWrapper: { flexDirection: 'row', alignItems: 'center' },
|
||||
text: { color: '$primaryBlack', marginBottom: 8 },
|
||||
weightInput: { flex: 1 },
|
||||
weightFormInput: { textAlign: 'center', color: '$primaryBlack' },
|
||||
weightFormInputWrapper: { marginTop: 0 },
|
||||
usernameInput: { flex: 3, color: '$primaryBlack', marginLeft: 16 },
|
||||
usernameFormInputWrapper: { marginTop: 0, marginLeft: 10 },
|
||||
footerWrapper: { flex: 1 },
|
||||
saveButton: {
|
||||
width: 100,
|
||||
height: 44,
|
||||
alignSelf: 'center',
|
||||
justifyContent: 'center',
|
||||
bodyWrapper: {
|
||||
flex: 3,
|
||||
paddingTop: 20,
|
||||
},
|
||||
itemWrapper: {
|
||||
alignItems: 'center',
|
||||
padding: 16,
|
||||
borderRadius: 8,
|
||||
flexDirection: 'row',
|
||||
backgroundColor: '$primaryBackgroundColor',
|
||||
},
|
||||
itemWrapperGray: {
|
||||
backgroundColor: '$primaryLightBackground',
|
||||
},
|
||||
username: {},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user