|
|
@@ -26,8 +26,18 @@ class MarkdownLinkUtil {
|
|
|
return beginningOfLink >= 0 && endOfLink >= 0;
|
|
|
}
|
|
|
|
|
|
- replaceFocusedMarkdownLinkWithEditor(editor) {
|
|
|
- // GW-3023
|
|
|
+ // replace link(link is an instance of Linker)
|
|
|
+ replaceFocusedMarkdownLinkWithEditor(editor, link) {
|
|
|
+ const curPos = editor.getCursor();
|
|
|
+ const linkStr = link.generateMarkdownText();
|
|
|
+ if (!this.isInLink(editor)) {
|
|
|
+ editor.getDoc().replaceSelection(linkStr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ const line = editor.getDoc().getLine(curPos.line);
|
|
|
+ const { beginningOfLink, endOfLink } = Linker.getBeginningAndEndIndexOfLink(line, curPos.ch);
|
|
|
+ editor.getDoc().replaceRange(linkStr, { line: curPos.line, ch: beginningOfLink }, { line: curPos.line, ch: endOfLink });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|