DEVONthink 3.8 - JavaScript file loaded with Markdown

First, grats on the huge release! The release notes seemed to go on forever!

Second, I’m trying to understand more around the capabilities of applying JavaScript to a markdown file. Does this possibly allow for us to extend the markdown editor with custom behavior? Are there any developer docs or samples available? I threw together a quick script to just walk the DOM and write out child objects, but hoping there’s some better docs somewhere!


1 Like

Applying JS to MD is hopefully not related to modify the behavior of the editor. I doubt that this would be a viable concept for a commercial product, since it would create a support nightmare. If you need a modifiable editor, have a look at Emacs and Lisp.

As to what you can do with JS in MD: well, you don’t do anything to the MD, but rather to the HTML that it is rendered into. There, you have all the possibilities offered by JS and the DOM. I posted an example here some months ago that added checkbox syntax.

The editor is not web-based and therefore doesn’t support/use CSS/JavaScript.

Thanks for the replies. I figured that was the case, but wasn’t sure if the editor was also a pseudo web-like view.

Now onto another question, is the webview that the markdown’s rendered into “sandboxed” from the rest of DEVONthink? As in, are there any APIs available that we can call from JS to access the inner workings of DT? (e.g. perhaps the AppleScript layer?). I’d expect this to be sandboxed but thought I’d check :slight_smile:

Since DT is (probably) using Apple’s WebView component: no, you can’t. Fortunately. Otherwise, any website could execute whatever OSA command it wanted on your machine. So yes, it is sandboxed.