Skip to content

Commit a634d1e

Browse files
committed
remove unused function
1 parent ccb3b91 commit a634d1e

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {pasteAsMarkdownLink, removeAttachmentLinksFromMarkdown} from './EditorUpload.ts';
1+
import {removeAttachmentLinksFromMarkdown} from './EditorUpload.ts';
22

33
test('removeAttachmentLinksFromMarkdown', () => {
44
expect(removeAttachmentLinksFromMarkdown('a foo b', 'foo')).toBe('a foo b');
@@ -12,13 +12,3 @@ test('removeAttachmentLinksFromMarkdown', () => {
1212
expect(removeAttachmentLinksFromMarkdown('a <img src="/attachments/foo"> b', 'foo')).toBe('a b');
1313
expect(removeAttachmentLinksFromMarkdown('a <img src="/attachments/foo" width="100"/> b', 'foo')).toBe('a b');
1414
});
15-
16-
test('preparePasteAsMarkdownLink', () => {
17-
expect(pasteAsMarkdownLink({value: 'foo', selectionStart: 0, selectionEnd: 0}, 'bar')).toBeNull();
18-
expect(pasteAsMarkdownLink({value: 'foo', selectionStart: 0, selectionEnd: 0}, 'https://gitea.com')).toBeNull();
19-
expect(pasteAsMarkdownLink({value: 'foo', selectionStart: 0, selectionEnd: 3}, 'bar')).toBeNull();
20-
expect(pasteAsMarkdownLink({value: 'foo', selectionStart: 0, selectionEnd: 3}, 'https://gitea.com')).toBe('[foo](https://gitea.com)');
21-
expect(pasteAsMarkdownLink({value: '..(url)', selectionStart: 3, selectionEnd: 6}, 'https://gitea.com')).toBe('[url](https://gitea.com)');
22-
expect(pasteAsMarkdownLink({value: '[](url)', selectionStart: 3, selectionEnd: 6}, 'https://gitea.com')).toBeNull();
23-
expect(pasteAsMarkdownLink({value: 'https://example.com', selectionStart: 0, selectionEnd: 19}, 'https://gitea.com')).toBeNull();
24-
});

web_src/js/features/comp/EditorUpload.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ export function removeAttachmentLinksFromMarkdown(text: string, fileUuid: string
118118
return text;
119119
}
120120

121-
export function pasteAsMarkdownLink(textarea: {value: string, selectionStart: number, selectionEnd: number}, pastedText: string): string | null {
122-
const {value, selectionStart, selectionEnd} = textarea;
123-
const selectedText = value.substring(selectionStart, selectionEnd);
124-
const trimmedText = pastedText.trim();
125-
const beforeSelection = value.substring(0, selectionStart);
126-
const afterSelection = value.substring(selectionEnd);
127-
const isInMarkdownLink = beforeSelection.endsWith('](') && afterSelection.startsWith(')');
128-
const asMarkdownLink = selectedText && isUrl(trimmedText) && !isUrl(selectedText) && !isInMarkdownLink;
129-
return asMarkdownLink ? `[${selectedText}](${trimmedText})` : null;
130-
}
131-
132121
function getPastedImages(e: ClipboardEvent) {
133122
const images: Array<File> = [];
134123
for (const item of e.clipboardData?.items ?? []) {

0 commit comments

Comments
 (0)