This commit is contained in:
feruz 2021-03-11 10:55:40 +02:00
parent 944237fd99
commit d94d2f310d
4 changed files with 15 additions and 65 deletions

View File

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

View File

@ -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,
},
];

View File

@ -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';

View File

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