-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ^:hide-source lookup, Mafs expansion, support for adding viewers
- Loading branch information
Showing
6 changed files
with
147 additions
and
79 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,18 +1,24 @@ | ||
(ns maria.editor.extensions.emmy | ||
(:require [emmy.viewer.sci] | ||
[emmy.portal.css :refer [inject!]] | ||
[emmy.portal.css :refer [inject!] :rename {inject! inject-css!}] | ||
[emmy.viewer.css :refer [css-map]] | ||
[promesa.core :as p] | ||
[sci.ctx-store :as ctx] | ||
[shadow.lazy :as lazy])) | ||
[emmy.mafs] | ||
[maria.editor.extensions.reagent :as ext.reagent] | ||
[maria.editor.code.show-values :as show] | ||
[sci.ctx-store :refer [get-ctx]])) | ||
|
||
(defn show-emmy [opts x] | ||
(when (vector? x) | ||
(let [m (meta x)] | ||
(cond (= emmy.mafs/default-viewer (:nextjournal.clerk/viewer m)) | ||
(show/reagent-eval opts (emmy.viewer/expand x)) | ||
|
||
(:portal.viewer/reagent? m) | ||
(show/reagent-eval opts x))))) | ||
|
||
(defn install! [] | ||
;; capture bound sci context | ||
(let [ctx (ctx/get-ctx)] | ||
;; first install reagent (necessary for viewers) | ||
(p/let [install! (lazy/load (lazy/loadable maria.editor.extensions.reagent/install!))] | ||
(ctx/with-ctx ctx | ||
(install!) | ||
(doseq [href (apply concat (vals css-map))] | ||
(inject! href)) | ||
(emmy.viewer.sci/install!))))) | ||
(show/add-global-viewers! (get-ctx) :before :vector [show-emmy]) | ||
(ext.reagent/install!) | ||
(doseq [href (apply concat (vals css-map))] | ||
(inject-css! href)) | ||
(emmy.viewer.sci/install!)) |