alfred-bear
Version:
Alfred Workflow to handle bear templates
34 lines (33 loc) • 966 B
JavaScript
import open from "open";
import { BearTemplateError } from "./Error.js";
import urlencode from "urlencode";
const BEAR_CREATE_NOTE = "bear://x-callback-url/create?";
export class BearNote {
constructor() { }
set text(text) {
if (!text)
throw new BearTemplateError(`No template content was given.`);
else
this._text = `text=${urlencode(text)}`;
}
get text() {
var _a;
return (_a = this._text) !== null && _a !== void 0 ? _a : "";
}
set newWindow(newWindow) {
if (!!newWindow)
this._newWindow = `&new_window=true`;
}
get newWindow() {
var _a;
return (_a = this._newWindow) !== null && _a !== void 0 ? _a : "";
}
open() {
if (this._text) {
open(`${BEAR_CREATE_NOTE}${this._text}${this.newWindow}`);
}
else {
throw new BearTemplateError(`No template content was given.`);
}
}
}