浏览代码

refactor(unused): rm adoc support

Andelf 2 年之前
父节点
当前提交
ebd2865d30

+ 0 - 1
deps/graph-parser/src/logseq/graph_parser/util.cljs

@@ -172,7 +172,6 @@
   [format]
   [format]
   (case (keyword format)
   (case (keyword format)
     :md :markdown
     :md :markdown
-    :asciidoc :adoc
     ;; default
     ;; default
     (keyword format)))
     (keyword format)))
 
 

+ 9 - 45
src/main/frontend/components/content.cljs

@@ -31,29 +31,6 @@
 
 
 ;; TODO i18n support
 ;; TODO i18n support
 
 
-(defn- set-format-js-loading!
-  [format value]
-  (when format
-    (swap! state/state assoc-in [:format/loading format] value)))
-
-(defn- lazy-load
-  [format]
-  (let [format (gp-util/normalize-format format)]
-    (when-let [record (format/get-format-record format)]
-      (when-not (protocol/loaded? record)
-        (set-format-js-loading! format true)
-        (protocol/lazyLoad record
-                           (fn [_result]
-                             (set-format-js-loading! format false)))))))
-
-(defn lazy-load-js
-  [state]
-  (when-let [format (:format (last (:rum/args state)))]
-    (let [loader? (contains? config/html-render-formats format)]
-      (when loader?
-        (when-not (format/loaded? format)
-          (lazy-load format))))))
-
 (rum/defc custom-context-menu-content
 (rum/defc custom-context-menu-content
   []
   []
   [:.menu-links-wrapper
   [:.menu-links-wrapper
@@ -420,17 +397,13 @@
 
 
 (rum/defc non-hiccup-content < rum/reactive
 (rum/defc non-hiccup-content < rum/reactive
   [id content on-click on-hide config format]
   [id content on-click on-hide config format]
-  (let [edit? (state/sub [:editor/editing? id])
-        loading (state/sub :format/loading)]
+  (let [edit? (state/sub [:editor/editing? id])]
     (if edit?
     (if edit?
       (editor/box {:on-hide on-hide
       (editor/box {:on-hide on-hide
                    :format format}
                    :format format}
                   id
                   id
                   config)
                   config)
-      (let [format (gp-util/normalize-format format)
-            loading? (get loading format)
-            markup? (contains? config/html-render-formats format)
-            on-click (fn [e]
+      (let [on-click (fn [e]
                        (when-not (util/link? (gobj/get e "target"))
                        (when-not (util/link? (gobj/get e "target"))
                          (util/stop e)
                          (util/stop e)
                          (editor-handler/reset-cursor-range! (gdom/getElement (str id)))
                          (editor-handler/reset-cursor-range! (gdom/getElement (str id)))
@@ -438,17 +411,12 @@
                          (state/set-edit-input-id! id)
                          (state/set-edit-input-id! id)
                          (when on-click
                          (when on-click
                            (on-click e))))]
                            (on-click e))))]
-        (cond
-          (and markup? loading?)
-          [:div "loading ..."]
-
-          :else                       ; other text formats
-          [:pre.cursor.content.pre-white-space
-           {:id id
-            :on-click on-click}
-           (if (string/blank? content)
-             [:div.cursor "Click to edit"]
-             content)])))))
+        [:pre.cursor.content.pre-white-space
+         {:id id
+          :on-click on-click}
+         (if (string/blank? content)
+           [:div.cursor "Click to edit"]
+           content)]))))
 
 
 (defn- set-draw-iframe-style!
 (defn- set-draw-iframe-style!
   []
   []
@@ -463,16 +431,12 @@
           (d/set-style! draw :margin-left (str (- (/ (- width 570) 2)) "px")))))))
           (d/set-style! draw :margin-left (str (- (/ (- width 570) 2)) "px")))))))
 
 
 (rum/defcs content < rum/reactive
 (rum/defcs content < rum/reactive
-  {:will-mount (fn [state]
-                 (lazy-load-js state)
-                 state)
-   :did-mount (fn [state]
+  {:did-mount (fn [state]
                 (set-draw-iframe-style!)
                 (set-draw-iframe-style!)
                 (image-handler/render-local-images!)
                 (image-handler/render-local-images!)
                 state)
                 state)
    :did-update (fn [state]
    :did-update (fn [state]
                  (set-draw-iframe-style!)
                  (set-draw-iframe-style!)
-                 (lazy-load-js state)
                  (image-handler/render-local-images!)
                  (image-handler/render-local-images!)
                  state)}
                  state)}
   [state id {:keys [format
   [state id {:keys [format

+ 1 - 4
src/main/frontend/config.cljs

@@ -104,14 +104,11 @@
 
 
 (def media-formats (set/union (gp-config/img-formats) audio-formats))
 (def media-formats (set/union (gp-config/img-formats) audio-formats))
 
 
-(def html-render-formats
-  #{:adoc :asciidoc})
-
 (defn extname-of-supported?
 (defn extname-of-supported?
   ([input] (extname-of-supported?
   ([input] (extname-of-supported?
             input
             input
             [image-formats doc-formats audio-formats
             [image-formats doc-formats audio-formats
-             video-formats markup-formats html-render-formats
+             video-formats markup-formats
              (gp-config/text-formats)]))
              (gp-config/text-formats)]))
   ([input formats]
   ([input formats]
    (when-let [input (some->
    (when-let [input (some->

+ 1 - 10
src/main/frontend/format.cljs

@@ -1,15 +1,13 @@
 (ns frontend.format
 (ns frontend.format
   "Main ns for providing common operations on file content like conversion to html
   "Main ns for providing common operations on file content like conversion to html
-and edn. Can handle org, markdown and adoc formats"
+and edn. Can handle org-mode and markdown formats"
   (:require [frontend.format.mldoc :refer [->MldocMode] :as mldoc]
   (:require [frontend.format.mldoc :refer [->MldocMode] :as mldoc]
-            [frontend.format.adoc :refer [->AdocMode]]
             [frontend.format.protocol :as protocol]
             [frontend.format.protocol :as protocol]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.mldoc :as gp-mldoc]
             [logseq.graph-parser.util :as gp-util]
             [logseq.graph-parser.util :as gp-util]
             [clojure.string :as string]))
             [clojure.string :as string]))
 
 
 (defonce mldoc-record (->MldocMode))
 (defonce mldoc-record (->MldocMode))
-(defonce adoc-record (->AdocMode))
 
 
 (defn get-format-record
 (defn get-format-record
   [format]
   [format]
@@ -18,8 +16,6 @@ and edn. Can handle org, markdown and adoc formats"
     mldoc-record
     mldoc-record
     :markdown
     :markdown
     mldoc-record
     mldoc-record
-    :adoc
-    adoc-record
     nil))
     nil))
 
 
 ;; html
 ;; html
@@ -48,8 +44,3 @@ and edn. Can handle org, markdown and adoc formats"
      (if-let [record (get-format-record format)]
      (if-let [record (get-format-record format)]
        (protocol/toEdn record content config)
        (protocol/toEdn record content config)
        nil))))
        nil))))
-
-(defn loaded?
-  [format]
-  (when-let [record (get-format-record format)]
-    (protocol/loaded? record)))

+ 0 - 30
src/main/frontend/format/adoc.cljs

@@ -1,30 +0,0 @@
-(ns frontend.format.adoc
-  "Partial implementation of format protocol for adoc that uses asciidoctor"
-  (:require [frontend.format.protocol :as protocol]
-            [frontend.loader :as loader]))
-
-(defn loaded? []
-  js/window.Asciidoctor)
-
-(defrecord AdocMode []
-  protocol/Format
-  (toEdn [_this _content _config]
-    nil)
-  (toHtml [_this content _config _references]
-    (when (loaded?)
-      (let [config {:attributes {:showTitle false
-                                 :hardbreaks true
-                                 :icons "font"
-                                 ;; :source-highlighter "pygments"
-                                 }}]
-        (.convert (js/window.Asciidoctor) content (clj->js config)))))
-  (loaded? [_this]
-    (some? (loaded?)))
-  (lazyLoad [_this ok-handler]
-    (loader/load
-     "https://cdnjs.cloudflare.com/ajax/libs/asciidoctor.js/1.5.9/asciidoctor.min.js"
-     ok-handler))
-  (exportMarkdown [_this _content _config _references]
-    (throw "not support"))
-  (exportOPML [_this _content _config _title _references]
-    (throw "not support")))

+ 0 - 4
src/main/frontend/format/mldoc.cljs

@@ -62,10 +62,6 @@
     (->edn content config))
     (->edn content config))
   (toHtml [_this content config references]
   (toHtml [_this content config references]
     (export "html" content config references))
     (export "html" content config references))
-  (loaded? [_this]
-    true)
-  (lazyLoad [_this _ok-handler]
-    true)
   (exportMarkdown [_this content config references]
   (exportMarkdown [_this content config references]
     (parse-export-markdown content config references))
     (parse-export-markdown content config references))
   (exportOPML [_this content config title references]
   (exportOPML [_this content config title references]

+ 0 - 2
src/main/frontend/format/protocol.cljs

@@ -3,7 +3,5 @@
 (defprotocol Format
 (defprotocol Format
   (toEdn [this content config])
   (toEdn [this content config])
   (toHtml [this content config references])
   (toHtml [this content config references])
-  (loaded? [this])
-  (lazyLoad [this ok-handler])
   (exportMarkdown [this content config references])
   (exportMarkdown [this content config references])
   (exportOPML [this content config title references]))
   (exportOPML [this content config title references]))

+ 0 - 1
src/main/frontend/state.cljs

@@ -45,7 +45,6 @@
      :indexeddb/support?      true
      :indexeddb/support?      true
      :me                      nil
      :me                      nil
      :git/current-repo        current-graph
      :git/current-repo        current-graph
-     :format/loading          {}
      :draw?                   false
      :draw?                   false
      :db/restoring?           nil
      :db/restoring?           nil