Textwellの整理してて見つけた。
Drafts
なんかバージョンがむちゃくちゃですね。 41ですか。 5までは追いかけてたんだけど。 久しぶりに覗いてみるとデザインがかっこよくなってます。
アクションで機能アップするところも健在。
DraftsMaker.md
Obsidianでアクションを書いて、DraftsにインストールするTemplaterスクリプト。
<%* title = tp.file.title script = tp.file.content.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,"\\\"") s = '{"uuid":"F754805C-1E93-0000-0000-000000000000","steps":[{"type":"script","data":{"script":"' + script + '"},"uuid":"CA2BDFD3-773C-0000-0000-000000000000"}],"shortName":"","shouldConfirm":false,"disposition":0,"keyCommand":{"optionKey":false,"input":"","controlKey":true,"commandKey":true,"type":"action","discoverabilityTitle":"' + title + '","shiftKey":false},"logLevel":1,"notificationType":1,"tintColor":"none","actionDescription":"","keyUseIcon":true,"icon":"action_script","visibility":2,"supportedPlatform":"any","groupDisposition":0,"name":"' + title + '"}' url = "drafts5://action?data=" + encodeURIComponent(s) open(url) %>
使い方
たとえばDraftsのテキストをObsidianに転送する場合。
title = draft.title text = draft.content url = "obsidian://new?file=" + encodeURIComponent(title) + "&content=" + encodeURIComponent(text) app.openURL(url) editor.focus()
Obsidianに上記スクリプトを書いてDraftsMakerを起動します。 するとDraftsが立ち上がり登録完了。 Obsidianのファイル名がDraftsのアクション名になります。
これでDraftsで書いた文章をObsidianに移すことができます。
Draftsのスクリプト
増えてますね。 ざっと読んだけれど、全体像がわからなかった。
まとめ
Draftsだけで完結するアクションも昔作ったようです。
訂正
Draftsの2行目以降をObsidianの本文にするアクション。
title = "Inbox/" + draft.displayTitle d = draft.lines d.shift() text = d.join("\n") url = "obsidian://new?file=" + encodeURIComponent(title) + "&content=" + encodeURIComponent(text) app.openURL(url) editor.focus()
1行目から見出し記号を外したのをファイル名にします。
Inbox/
のところは書き込み先のフォルダ名で。
draft.linesは行ごとを扱う配列で、draft.line[0]が0行め、つまりタイトルの行になります。 shift()を使うと一行分捨てるので、残りをjoin()して本文とするわけです。