Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: send to obsidian via url in favor of clipboard
fix sel.book return empty
- Loading branch information
Showing
10 changed files
with
72 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { MNMark } from "./return"; | ||
export const PREFIX: MNMark = "<!--MN-->\n"; | ||
const version = "2.1.0"; | ||
export const VERSION: string = "v" + version; | ||
export const VERSION: string = version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { MbBookNote } from "@alx-plugins/marginnote"; | ||
import JsonURL from "@jsonurl/jsonurl"; | ||
import { stringify as toQs } from "query-string"; | ||
import Url from "url-parse"; | ||
|
||
import { VERSION } from "./const"; | ||
import { getBody_Note, getBody_Sel, getBody_Toc } from "./parser"; | ||
import { ReturnBody, Selection } from "./return"; | ||
import { showHUD } from "./tools"; | ||
import getText from "./translate"; | ||
|
||
export const SendToc = (src: MbBookNote): void => { | ||
try { | ||
toURL(getBody_Toc(src)); | ||
showHUD(getText("hint_toc_success") + src.noteTitle); | ||
} catch (error) { | ||
showHUD(error); | ||
} | ||
}; | ||
export const SendSel = (src: Selection): void => toURL(getBody_Sel(src)); | ||
export const SendNote = (src: MbBookNote): void => toURL(getBody_Note(src)); | ||
|
||
const toURL = (obj: ReturnBody) => { | ||
const url = new Url("obsidian://mncomp"), | ||
{ type, sendTime, last, data } = obj, | ||
qs = toQs({ | ||
version: VERSION, | ||
type, | ||
sendTime, | ||
last: JsonURL.stringify(last), | ||
data: JsonURL.stringify(data), | ||
}); | ||
url.set("query", qs); | ||
Application.sharedInstance().openURL(NSURL.URLWithString(url.toString())); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters