Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): api export Date.getTime() for Date
- Loading branch information
Showing
8 changed files
with
88 additions
and
46 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
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,35 +1,21 @@ | ||
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"; | ||
import { ObjToUrl } from "./url-obj"; | ||
|
||
export const SendToc = (src: MbBookNote): void => { | ||
try { | ||
toURL(getBody_Toc(src)); | ||
ObjToUrl(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)); | ||
export const SendSel = (src: Selection): void => send(getBody_Sel(src)); | ||
export const SendNote = (src: MbBookNote): void => send(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())); | ||
}; | ||
const send = (body: ReturnBody) => | ||
Application.sharedInstance().openURL(NSURL.URLWithString(ObjToUrl(body))); |
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,26 @@ | ||
import JsonURL from "@jsonurl/jsonurl"; | ||
import assertNever from "assert-never"; | ||
import { ObsidianProtocolData } from "obsidian"; | ||
import { stringify as toQs } from "query-string"; | ||
import URLParse from "url-parse"; | ||
|
||
import { VERSION } from "./const"; | ||
import { DataType, ReturnBody } from "./return"; | ||
import { copy } from "./tools"; | ||
|
||
export const ObjToUrl = (obj: ReturnBody) => { | ||
// copy(JSON.stringify(obj)); | ||
const url = URLParse("obsidian://mncomp"), | ||
{ type, sendTime, last, data } = obj, | ||
qsObj: QsObj = { | ||
version: VERSION, | ||
type, | ||
sendTime, | ||
last: JsonURL.stringify(last) as string, | ||
data: JsonURL.stringify(data) as string, | ||
}, | ||
qs = toQs(qsObj); | ||
url.set("query", qs); | ||
return url.toString(); | ||
}; | ||
|