mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 21:06:09 +03:00
update the TODO test and fix
This commit is contained in:
parent
a69d950b89
commit
cdc12f8872
2 changed files with 663 additions and 589 deletions
File diff suppressed because it is too large
Load diff
|
@ -316,38 +316,47 @@ public class MarkdownUtil {
|
|||
// CS304 issue link: https://github.com/stefan-niedermann/nextcloud-notes/issues/1186
|
||||
public static int insertLink(@NonNull Editable editable, int selectionStart, int selectionEnd, @Nullable String clipboardUrl) {
|
||||
if (selectionStart == selectionEnd) {
|
||||
char start = editable.charAt(selectionStart-1);
|
||||
char end = editable.charAt(selectionEnd);
|
||||
if (start == ' '||end == ' ') {
|
||||
if (start != ' ') {
|
||||
editable.insert(selectionStart, " ");
|
||||
selectionStart += 1;
|
||||
}
|
||||
if (end != ' ') {
|
||||
editable.insert(selectionEnd, " ");
|
||||
if (selectionStart>0 && selectionEnd<editable.length()) {
|
||||
char start = editable.charAt(selectionStart - 1);
|
||||
char end = editable.charAt(selectionEnd);
|
||||
if (start == ' ' || end == ' ') {
|
||||
if (start != ' ') {
|
||||
editable.insert(selectionStart, " ");
|
||||
selectionStart += 1;
|
||||
}
|
||||
if (end != ' ') {
|
||||
editable.insert(selectionEnd, " ");
|
||||
}
|
||||
editable.insert(selectionStart, "[](" + (clipboardUrl == null ? "" : clipboardUrl) + ")");
|
||||
if (clipboardUrl != null) {
|
||||
selectionEnd += clipboardUrl.length();
|
||||
}
|
||||
return selectionStart + 1;
|
||||
|
||||
} else {
|
||||
while (start != ' ') {
|
||||
selectionStart--;
|
||||
start = editable.charAt(selectionStart);
|
||||
}
|
||||
selectionStart++;
|
||||
while (end != ' ') {
|
||||
selectionEnd++;
|
||||
end = editable.charAt(selectionEnd);
|
||||
}
|
||||
selectionEnd++;
|
||||
editable.insert(selectionStart, "[");
|
||||
editable.insert(selectionEnd, "](" + (clipboardUrl == null ? "" : clipboardUrl) + ")");
|
||||
if (clipboardUrl != null) {
|
||||
selectionEnd += clipboardUrl.length();
|
||||
}
|
||||
return selectionEnd + 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
editable.insert(selectionStart, "[](" + (clipboardUrl == null ? "" : clipboardUrl) + ")");
|
||||
return selectionStart + 1;
|
||||
|
||||
}else {
|
||||
while (start != ' '){
|
||||
selectionStart--;
|
||||
start = editable.charAt(selectionStart);
|
||||
}
|
||||
selectionStart++;
|
||||
while (end != ' '){
|
||||
selectionEnd++;
|
||||
end = editable.charAt(selectionEnd);
|
||||
}
|
||||
selectionEnd++;
|
||||
editable.insert(selectionStart,"[");
|
||||
editable.insert(selectionEnd,"](" + (clipboardUrl == null ? "" : clipboardUrl) + ")");
|
||||
if (clipboardUrl!=null){
|
||||
selectionEnd += clipboardUrl.length();
|
||||
}
|
||||
return selectionEnd + 2;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
final boolean textToFormatIsLink = TextUtils.indexOf(editable.subSequence(selectionStart, selectionEnd), "http") == 0;
|
||||
if (textToFormatIsLink) {
|
||||
|
|
Loading…
Reference in a new issue