Skip to content

Commit

Permalink
Revert "feat(plguin): integration"
Browse files Browse the repository at this point in the history
This reverts commit ba6b642.
  • Loading branch information
tiensonqin committed May 8, 2021
1 parent ebdba0e commit a14a6a5
Show file tree
Hide file tree
Showing 16 changed files with 12 additions and 119 deletions.
2 changes: 0 additions & 2 deletions resources/electron-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
</head>
<body>
<div id="root"></div>
<script>window.__LSP__HOST__ = true</script>
<script>window.user = null</script>
<script src="./js/magic_portal.js"></script>
<script>let worker = new Worker('./js/worker.js')
Expand All @@ -50,7 +49,6 @@
</script>
<script defer src="./js/highlight.min.js"></script>
<script defer src="./js/interact.min.js"></script>
<script defer src="./js/lsplugin.core.js"></script>
<script defer src="./js/main.js"></script>
<script defer src="./js/code-editor.js"></script>
<script defer src="./js/age-encryption.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions resources/electron.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</head>
<body>
<div id="root"></div>
<script>window.__LSP__HOST__ = true</script>
<script>window.user = null</script>
<script src="./js/magic_portal.js"></script>
<script>let worker = new Worker('./js/worker.js')
Expand All @@ -51,7 +50,6 @@
</script>
<script defer src="./js/highlight.min.js"></script>
<script defer src="./js/interact.min.js"></script>
<script defer src="./js/lsplugin.core.js"></script>
<script defer src="./js/main.js"></script>
<script defer src="./js/code-editor.js"></script>
<script defer src="./js/age-encryption.js"></script>
Expand Down
6 changes: 1 addition & 5 deletions resources/js/preload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const { ipcRenderer, contextBridge, shell, clipboard, webFrame } = require('electron')
const { ipcRenderer, contextBridge, shell, clipboard } = require('electron')

const IS_MAC = process.platform === 'darwin'
const IS_WIN32 = process.platform === 'win32'
Expand Down Expand Up @@ -136,8 +136,4 @@ contextBridge.exposeInMainWorld('apis', {

getFilePathFromClipboard,
isClipboardHasImage,

setZoomFactor (factor) {
webFrame.setZoomFactor(factor)
}
})
31 changes: 0 additions & 31 deletions src/electron/electron/handler.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,6 @@
(remove nil?))]
(vec (cons {:path (fix-win-path! path)} result))))

(defn- get-ls-dotdir-root
[]
(let [lg-dir (str (.getPath app "home") "/.logseq")]
(if-not (fs/existsSync lg-dir)
(and (fs/mkdirSync lg-dir) lg-dir)
lg-dir)))

(defn- get-ls-default-plugins
[]
(let [plugins-root (path/join (get-ls-dotdir-root) "plugins")
_ (if-not (fs/existsSync plugins-root)
(fs/mkdirSync plugins-root))
dirs (js->clj (fs/readdirSync plugins-root #js{"withFileTypes" true}))
dirs (->> dirs
(filter #(.isDirectory %))
(filter #(not (string/starts-with? (.-name %) "_")))
(map #(path/join plugins-root (.-name %))))]
dirs))

(defmethod handle :openDir [^js window _messages]
(let [result (.showOpenDialogSync dialog (bean/->js
{:properties ["openDirectory" "createDirectory" "promptToCreate"]}))
Expand Down Expand Up @@ -197,18 +178,6 @@
(when dir
(watch-dir! window dir)))

(defmethod handle :openDialogSync [^js window _messages]
(let [result (.showOpenDialogSync dialog (bean/->js
{:properties ["openDirectory"]}))
path (first result)]
path))

(defmethod handle :getLogseqDotDirRoot []
(get-ls-dotdir-root))

(defmethod handle :getUserDefaultPlugins []
(get-ls-default-plugins))

(defmethod handle :default [args]
(println "Error: no ipc handler for: " (bean/->js args)))

Expand Down
10 changes: 0 additions & 10 deletions src/main/frontend/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
[frontend.components.repo :as repo]
[frontend.components.search :as search]
[frontend.components.export :as export]
[frontend.components.plugins :as plugins]
[frontend.components.right-sidebar :as sidebar]
[frontend.handler.page :as page-handler]
[frontend.handler.web.nfs :as nfs]
Expand Down Expand Up @@ -72,7 +71,6 @@
(rum/defc dropdown-menu < rum/reactive
[{:keys [me current-repo t default-home]}]
(let [projects (state/sub [:me :projects])
developer-mode? (state/sub [:ui/developer-mode?])
logged? (state/logged?)]
(ui/dropdown-with-links
(fn [{:keys [toggle-fn]}]
Expand Down Expand Up @@ -116,14 +114,6 @@
:options {:on-click #(ui-handler/toggle-settings-modal!)}
:icon svg/settings-sm})

(when developer-mode?
{:title (t :plugins)
:options {:href (rfe/href :plugins)}})

(when developer-mode?
{:title (t :themes)
:options {:on-click #(plugins/open-select-theme!)}})

(when current-repo
{:title (t :export)
:options {:on-click #(state/set-modal! export/export)}
Expand Down
11 changes: 5 additions & 6 deletions src/main/frontend/components/plugins.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
[:sup.inline-block.px-1.text-xs.opacity-30 version]]
[:div.desc.text-xs.opacity-60
[:p description]
;;[:small (js/JSON.stringify (bean/->js settings))]
]
[:small (js/JSON.stringify (bean/->js settings))]]
[:div.flag
[:p.text-xs.text-gray-300.pr-2.flex.justify-between.dark:opacity-40
[:small author]
Expand Down Expand Up @@ -147,9 +146,9 @@
([type payload opts]
(let [id (str "slot__" (util/rand-str 8))]
(rum/use-effect!
(fn []
(plugin-handler/hook-plugin-app type {:slot id :payload payload} nil)
#())
[])
(fn []
(plugin-handler/hook-plugin-app type {:slot id :payload payload} nil)
#())
[])
[:div.lsp-hook-ui-slot
(merge opts {:id id})])))
7 changes: 2 additions & 5 deletions src/main/frontend/components/settings.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
(config-handler/set-config! :date-formatter format))))}
(for [format (sort (date/journal-title-formatters))]
[:option (cond->
{:key format}
{:key format}
(= format custom-date-format)
(assoc :selected "selected"))
format])]]]]
Expand Down Expand Up @@ -352,10 +352,7 @@
[:div.mt-1.sm:mt-0.sm:col-span-2
[:div.rounded-md.sm:max-w-xs
(ui/toggle developer-mode?
(fn []
(let [mode (not developer-mode?)]
(state/set-developer-mode! mode)
(and mode (js/alert (t :developer-mode-alert)))))
#(state/set-developer-mode! (not developer-mode?))
true)]]]
[:div.text-sm.opacity-50
(t :settings-page/developer-mode-desc)]
Expand Down
4 changes: 1 addition & 3 deletions src/main/frontend/components/theme.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.handler.route :as route-handler]
[frontend.handler.plugin :as plugin-handler]
[frontend.components.svg :as svg]))

(rum/defc container
Expand All @@ -13,8 +12,7 @@
(.setAttribute doc "data-theme" (if (= theme "white") "light" theme))
(if (= theme "dark") ;; for tailwind dark mode
(.add cls "dark")
(.remove cls "dark"))
(plugin-handler/hook-plugin-app :theme-mode-changed theme nil))
(.remove cls "dark")))
[theme])

(rum/use-effect!
Expand Down
9 changes: 0 additions & 9 deletions src/main/frontend/components/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,3 @@ html.is-resizing-buf {
transition: none;
}
}

body[data-page=plugins] {
.cp__sidebar-main-content {
max-width: 1280px;
width: 80%;
padding-left: 30px;
padding-right: 30px;
}
}
4 changes: 1 addition & 3 deletions src/main/frontend/core.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns frontend.core
(:require [rum.core :as rum]
[frontend.handler :as handler]
[frontend.handler.plugin :as plugin-handler]
[frontend.handler.route :as route]
[frontend.page :as page]
[frontend.routes :as routes]
Expand Down Expand Up @@ -45,8 +44,7 @@
;; this is called in the index.html and must be exported
;; so it is available even in :advanced release builds

(plugin-handler/setup!
#(handler/start! start))
(handler/start! start)

;; popup to notify user, could be toggled in settings
;; (handler/request-notifications-if-not-asked)
Expand Down
6 changes: 0 additions & 6 deletions src/main/frontend/dicts.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ title: How to take dummy notes?
:all-journals "All journals"
:my-publishing "My publishing"
:settings "Settings"
:plugins "Plugins"
:themes "Themes"
:developer-mode-alert "If you want enable plugin system just now, please restart app."
:import "Import"
:join-community "Join the community"
:sponsor-us "Sponsor Us"
Expand Down Expand Up @@ -1051,9 +1048,6 @@ title: How to take dummy notes?
:all-files "所有文件"
:my-publishing "我的发布"
:settings "设置"
:plugins "插件"
:themes "主题"
:developer-mode-alert "如果希望插件功能立刻生效, 请重启应用"
:import "导入"
:join-community "加入社区"
:sponsor-us "赞助我们!"
Expand Down
5 changes: 1 addition & 4 deletions src/main/frontend/handler/plugin.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
[frontend.util :as util]
[frontend.fs :as fs]
[frontend.handler.notification :as notifications]
[frontend.storage :as storage]
[camel-snake-kebab.core :as csk]
[frontend.state :as state]
[medley.core :as md]
[electron.ipc :as ipc]
[cljs-bean.core :as bean]
[clojure.string :as string]))

(defonce lsp-enabled?
(and (util/electron?)
(= (storage/get "developer-mode") "true")))
(defonce lsp-enabled? (util/electron?))

;; state handlers
(defn register-plugin
Expand Down
6 changes: 0 additions & 6 deletions src/main/frontend/handler/route.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
title (get-title (:name data) path-params)]
(util/set-title! title)))

(defn update-page-label!
[route]
(let [{:keys [data]} route]
(set! (. js/document.body.dataset -page) (name (:name data)))))

(defn jump-to-anchor!
[anchor-text]
(when anchor-text
Expand All @@ -92,7 +87,6 @@
(let [route route]
(swap! state/state assoc :route-match route)
(update-page-title! route)
(update-page-label! route)
(when-let [anchor (get-in route [:query-params :anchor])]
(jump-to-anchor! anchor)
(util/scroll-to-top))))
Expand Down
2 changes: 0 additions & 2 deletions src/main/frontend/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.components.sidebar :as sidebar]
[frontend.handler.plugin :as plugin-handler]
[frontend.context.i18n :as i18n]))

(rum/defc route-view
Expand All @@ -16,7 +15,6 @@
(state/setup-electron-updater!)
(ui/inject-document-devices-envs!)
(ui/inject-dynamic-style-node!)
(plugin-handler/host-mounted!)
(let [teardown-fn (comp (ui/setup-patch-ios-fixed-bottom-position!))]
(assoc state ::teardown teardown-fn)))
:will-unmount (fn [state]
Expand Down
7 changes: 1 addition & 6 deletions src/main/frontend/routes.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[frontend.components.file :as file]
[frontend.components.page :as page]
[frontend.components.diff :as diff]
[frontend.components.plugins :as plugins]
[frontend.components.journal :as journal]
[frontend.components.search :as search]
[frontend.components.settings :as settings]
Expand Down Expand Up @@ -66,8 +65,4 @@

["/all-journals"
{:name :all-journals
:view journal/all-journals}]

["/plugins"
{:name :plugins
:view plugins/installed-page}]])
:view journal/all-journals}]])
19 changes: 0 additions & 19 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,6 @@
:electron/updater-pending? false
:electron/updater {}

;; plugin
:plugin/indicator-text nil
:plugin/installed-plugins {}
:plugin/installed-themes []
:plugin/installed-commands {}
:plugin/simple-commands {}
:plugin/selected-theme nil
:plugin/selected-unpacked-pkg nil
:plugin/active-readme nil

;; all notification contents as k-v pairs
:notification/contents {}
:graph/syncing? false
Expand Down Expand Up @@ -1040,15 +1030,6 @@
[]
(:commands (get-config)))

(defn get-plugins-commands
[]
(mapcat seq (flatten (vals (:plugin/installed-commands @state)))))

(defn get-plugins-commands-with-type
[type]
(filterv #(= (keyword (first %)) (keyword type))
(apply concat (vals (:plugin/simple-commands @state)))))

(defn get-scheduled-future-days
[]
(let [days (:scheduled/future-days (get-config))]
Expand Down

0 comments on commit a14a6a5

Please sign in to comment.