diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 430d0ac855..1a34387f9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,9 +45,7 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} cache: 'yarn' - cache-dependency-path: | - yarn.lock - static/yarn.lock + cache-dependency-path: yarn.lock - name: Set up Java uses: actions/setup-java@v3 @@ -181,105 +179,4 @@ jobs: run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -T - name: Create graph from the export and diff the two graphs - run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T - - e2e-test: - # TODO: Re-enable when ready to enable tests for file graphs - if: false - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'yarn' - cache-dependency-path: | - yarn.lock - static/yarn.lock - - - name: Set up Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: ${{ env.JAVA_VERSION }} - - - name: Set up Clojure - uses: DeLaGuardo/setup-clojure@10.1 - with: - cli: ${{ env.CLOJURE_VERSION }} - - - name: Clojure cache - uses: actions/cache@v3 - id: clojure-deps - with: - path: | - ~/.m2/repository - ~/.gitlibs - key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }} - restore-keys: ${{ runner.os }}-clojure-deps- - - - name: Fetch Clojure deps - if: steps.clojure-deps.outputs.cache-hit != 'true' - run: clojure -A:cljs -P - - - name: Shadow-cljs cache - uses: actions/cache@v3 - with: - path: .shadow-cljs - # ensure update cache every time - key: ${{ runner.os }}-shadow-cljs-${{ github.sha }} - # will match most recent upload - restore-keys: | - ${{ runner.os }}-shadow-cljs- - - - name: Fetch yarn deps - run: yarn install - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true - - # NOTE: require the app to be build in debug mode(compile instead of build). - - name: Prepare E2E test build - run: | - yarn gulp:build && clojure -M:cljs compile app publishing electron - (cd static && yarn install && yarn rebuild:all) - - # Exits with 0 if yarn.lock is up to date or 1 if we forgot to update it - - name: Ensure static yarn.lock is up to date - run: git diff --exit-code static/yarn.lock - - - name: Install Fluxbox - run: sudo apt-get update && sudo apt-get install -y fluxbox - - # Emulate a virtual framebuffer on machines with no display hardware - - name: Run XVFB - run: Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 & - - # Start a lightweight window manager to simulate window actions (maximize,restore etc) - - name: Start Fluxbox - run: DISPLAY=:1.0 fluxbox >/dev/null 2>&1 & - - - name: Run Playwright test - 1/2 - run: DISPLAY=:1.0 npx playwright test --reporter github --shard=1/2 - env: - LOGSEQ_CI: true - DEBUG: "pw:api" - RELEASE: true # skip dev only test - - - name: Run Playwright test - 2/2 - run: DISPLAY=:1.0 npx playwright test --reporter github --shard=2/2 - env: - LOGSEQ_CI: true - DEBUG: "pw:api" - RELEASE: true # skip dev only test - - - name: Save test artifacts - if: ${{ failure() }} - uses: actions/upload-artifact@v4 - with: - name: e2e-test-report - path: e2e-dump/* - retention-days: 1 + run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4ff0bb10b8..5a4b79e640 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/e2e-dump /target /classes /checkouts @@ -15,7 +14,6 @@ pom.xml.asc node_modules/ static/** -!static/yarn.lock tmp cljs-test-runner-out diff --git a/CODEBASE_OVERVIEW.md b/CODEBASE_OVERVIEW.md index 2075c07080..ddecefdfca 100644 --- a/CODEBASE_OVERVIEW.md +++ b/CODEBASE_OVERVIEW.md @@ -52,6 +52,7 @@ This is overview of this repository's most important directories and files. - `src/main/frontend/worker/` contains code for the separate worker asset. - `src/main/frontend/common/` contains common code shared by the worker asset and the frontend. - `src/main/logseq/` contains the api used by plugins. + - `src/main/mobile/` contains code for new mobile app. - `src/dev-cljs/` contains some development utilities. - `deps/` contains ClojureScript dependencies or libraries used by the frontend. diff --git a/clj-e2e/README.md b/clj-e2e/README.md index 9c539aacf9..0d54d20d32 100644 --- a/clj-e2e/README.md +++ b/clj-e2e/README.md @@ -13,3 +13,5 @@ Then, run the project's tests: $ clojure -T:build test If you would like to run individual tests, pass options to the test runner through `clojure -M:test`. For example, add a `^:focus` on a test and then run `clojure -M:test -i focus`. + +If e2e tests fail, `clj-e2e/e2e-dump/` contains console logs and screenshots to help debug. \ No newline at end of file diff --git a/deps/db/src/logseq/db/frontend/class.cljs b/deps/db/src/logseq/db/frontend/class.cljs index 1690be82f5..d53fe5e864 100644 --- a/deps/db/src/logseq/db/frontend/class.cljs +++ b/deps/db/src/logseq/db/frontend/class.cljs @@ -37,8 +37,7 @@ :logseq.class/Task {:title "Task" - :schema {:properties [:logseq.property/status :logseq.property/priority :logseq.property/deadline :logseq.property/scheduled]} - :properties {:logseq.property.class/hide-from-node true}} + :schema {:properties [:logseq.property/status :logseq.property/priority :logseq.property/deadline :logseq.property/scheduled]}} :logseq.class/Query {:title "Query" diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 1e25407722..0b388d947b 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -139,32 +139,8 @@ We have unit, performance and end to end tests. ### End to End Tests Even though we have a nightly release channel, it's hard for testing users (thanks to the brave users!) to notice all issues in a limited time, as Logseq is covering so many features. -The only solution is automatic end-to-end tests - adding tests for GUI software is always painful but necessary. See https://github.com/logseq/logseq/pulls?q=E2E for e2e test examples. -To run end to end tests - -```sh -yarn electron-watch -# in another shell -yarn e2e-test # or npx playwright test -``` - -If e2e failed after first running: -- `rm -rdf ~/.logseq` -- `rm -rdf ~/.config/Logseq` -- `rm -rdf /tmp/` -- Windows: `rmdir /s %APPDATA%/Electron` (Reference: https://www.electronjs.org/de/docs/latest/api/app#appgetpathname) - -There's a `traceAll()` helper function to enable playwright trace file dump for specific test files https://github.com/logseq/logseq/pull/8332 - -If e2e tests fail in the file, they can be debugged by examining a trace dump with [the -playwright trace -viewer](https://playwright.dev/docs/trace-viewer#recording-a-trace). - -Locally this will get dumped into e2e-dump/. - -On CI the trace file will be under Artifacts at the bottom of a run page e.g. -https://github.com/logseq/logseq/actions/runs/3574600322. +To run end to end tests, see [clj-e2e tests](/clj-e2e/README.md). ### Unit Testing diff --git a/gulpfile.js b/gulpfile.js index 2cdecabfb7..ebf0255423 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -52,7 +52,7 @@ const css = { const common = { clean () { return del( - ['./static/**/*', '!./static/yarn.lock', '!./static/node_modules']) + ['./static/**/*', '!./static/node_modules']) }, syncResourceFile () { diff --git a/package.json b/package.json index 8e162ab80a..b84d2562f3 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,6 @@ "dev-electron-app": "gulp electron", "release-electron": "run-s gulp:build && gulp electronMaker", "debug-electron": "cd static/ && yarn electron:debug", - "e2e-test": "cross-env DEBUG=pw:api CI=true npx playwright test --reporter github", "sync-android-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync android", "sync-ios-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync ios", "clean": "gulp clean", diff --git a/scripts/publishing.sh b/scripts/publishing.sh deleted file mode 100755 index dd224fedc4..0000000000 --- a/scripts/publishing.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -yarn clean && yarn release-publishing -/usr/bin/rm -rf /tmp/publishing -mkdir /tmp/publishing -cp -R ./static /tmp/publishing/ -cp ./static/404.html /tmp/publishing/ -/usr/bin/rm -rf /tmp/publishing/static/node_modules/ -/usr/bin/rm /tmp/publishing/static/electron* -/usr/bin/rm /tmp/publishing/static/forge.config.js -/usr/bin/rm /tmp/publishing/static/package.json -/usr/bin/rm /tmp/publishing/static/yarn.lock -/usr/bin/rm /tmp/publishing/static/index.html -/usr/bin/rm /tmp/publishing/static/404.html -/usr/bin/rm /tmp/publishing/static/public.css -cd /tmp/publishing/ -mv ./static/js/publishing/code-editor.js ./static/js/ -tar -zcvf /tmp/logseq_publishing.tar.gz ./ diff --git a/scripts/src/logseq/tasks/dev/db_and_file_graphs.clj b/scripts/src/logseq/tasks/dev/db_and_file_graphs.clj index e1575b86dc..4a2398fe0b 100644 --- a/scripts/src/logseq/tasks/dev/db_and_file_graphs.clj +++ b/scripts/src/logseq/tasks/dev/db_and_file_graphs.clj @@ -19,7 +19,9 @@ "frontend.handler.db-based." "frontend.worker.handler.page.db-based" "frontend.components.property" "frontend.components.class" - "frontend.components.db-based" "frontend.components.objects" "frontend.components.query.view"])) + "frontend.components.db-based" "frontend.components.objects" "frontend.components.query.view" + "mobile.core" "mobile.events" "mobile.externals" "mobile.init" "mobile.ionic" "mobile.state" + "mobile.components"])) (def file-graph-ns "Namespaces or parent namespaces _only_ for file graphs" @@ -57,7 +59,8 @@ "src/main/frontend/components/objects.cljs" "src/main/frontend/components/db_based" "src/main/frontend/components/query/view.cljs" - "src/electron/electron/db.cljs"])) + "src/electron/electron/db.cljs" + "src/main/mobile"])) (def file-graph-paths "Paths _only_ for file graphs" @@ -136,7 +139,10 @@ ;; The next 3 are from components.property.value "{:block/name page-title})" "(when-not (db/get-page journal)" - "(let [value (if datetime? (tc/to-long d) (db/get-page journal))]"} + "(let [value (if datetime? (tc/to-long d) (db/get-page journal))]" + ;; :block/name ones from src/main/mobile + "(if-let [journal (db/get-page page-name)]" + "(p/then #(mobile-state/open-block-modal! (db/get-page page-name)))))))]"} res (grep-many file-concepts db-graph-paths) invalid-lines (when (= 0 (:exit res)) (remove #(some->> (string/split % #":\s+") second string/trim (contains? allowed-exceptions)) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index cc3e93994f..1c8ce70a57 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -2814,7 +2814,7 @@ :on-click #(db-property-handler/delete-property-value! (:db/id block) :block/tags (:db/id tag))} "Remove tag"))]) popup-opts))} - (if (and @*hover? (not private-tag?)) + (if (and @*hover? (not private-tag?) (not config/publishing?)) [:a.inline-flex.text-muted-foreground {:title "Remove this tag" :style {:margin-top 1 @@ -2844,7 +2844,10 @@ (:block/tags block) (remove (fn [t] (or (ldb/inline-tag? (:block/raw-title block) t) - (:logseq.property.class/hide-from-node t) + (if (contains? t :logseq.property.class/hide-from-node) + (:logseq.property.class/hide-from-node t) + ;; Mobile app hides by default while everything else doesn't + (if (util/capacitor-new?) true false)) (contains? hidden-internal-tags (:db/ident t)) (and (util/mobile?) (= (:db/ident t) :logseq.class/Task)))))) popup-opts {:align :end @@ -3079,7 +3082,9 @@ [:div.h-6 (shui/button {:variant :ghost :title "Open block references" - :class "px-1 py-0 w-5 h-5 opacity-70 hover:opacity-100" + :class (str "px-1 py-0 w-5 h-5 opacity-70 hover:opacity-100" (when (and (util/mobile?) + (seq (:block/_parent block))) + " !pr-4")) :size :sm :on-click (fn [e] (if (gobj/get e "shiftKey") @@ -3475,7 +3480,9 @@ :on-drop (fn [event] (block-drop event uuid block original-block *move-to')) :on-drag-end (fn [event] - (dom/remove-class! (.-target event) "dragging") + (doseq [block (or (seq (state/get-selection-blocks)) [(.-target event)])] + (dom/remove-class! block "dragging")) + (dom/remove! js/document.body (dom/sel1 "#dragging-ghost-element")) (block-drag-end event *move-to'))})) (defn- root-block? @@ -3672,8 +3679,22 @@ (fn [event] (when-not (state/editing?) (util/stop-propagation event) - (dom/add-class! (.-target event) "dragging") - (on-drag-start event block block-id)))) + (let [target ^js (.-target event) + blocks (or (seq (state/get-selection-blocks)) [target]) + multiple? (> (count blocks) 1) + element (when multiple? + (let [element (dom/create-element "div")] + (-> element + (dom/set-attr! "id" "dragging-ghost-element") + (dom/set-text! (str "Moving " (count blocks) " blocks")) + (dom/set-class! "p-2 rounded text-sm")) + element))] + (doseq [block blocks] + (dom/add-class! block "dragging")) + (on-drag-start event block block-id) + (when element + (dom/append! js/document.body element) + (dnd/set-drag-image! event element (/ (.-offsetWidth target) 2) (/ (.-offsetHeight target) 2))))))) (:property-default-value? config) (assoc :data-is-property-default-value (:property-default-value? config)) diff --git a/src/main/frontend/components/right_sidebar.cljs b/src/main/frontend/components/right_sidebar.cljs index 790fcd7aae..ca2f09d84e 100644 --- a/src/main/frontend/components/right_sidebar.cljs +++ b/src/main/frontend/components/right_sidebar.cljs @@ -8,6 +8,7 @@ [frontend.components.page :as page] [frontend.components.profiler :as profiler] [frontend.components.shortcut-help :as shortcut-help] + [frontend.config :as config] [frontend.context.i18n :refer [t]] [frontend.date :as date] [frontend.db :as db] @@ -437,7 +438,7 @@ (state/sidebar-add-block! repo "help" :help))} (t :right-side-bar/help)]] - (when (state/sub [:ui/developer-mode?]) + (when (and (state/sub [:ui/developer-mode?]) (not config/publishing?)) [:div.text-sm [:button.button.cp__right-sidebar-settings-btn {:on-click (fn [_e] (state/sidebar-add-block! repo "rtc" :rtc))} diff --git a/src/main/frontend/components/theme.css b/src/main/frontend/components/theme.css index 02753a49cf..0b9cf5f000 100644 --- a/src/main/frontend/components/theme.css +++ b/src/main/frontend/components/theme.css @@ -124,9 +124,11 @@ main.ls-fold-button-on-right { .ls-block { .block-control { @apply absolute -right-3 pr-2 pt-1 top-0 z-[1] - opacity-20 active:opacity-100; + opacity-50 active:opacity-100; + margin-top: 3px; .rotating-arrow.collapsed svg { + margin-left: -2px; transform: rotate(180deg); } } @@ -165,4 +167,4 @@ html[data-font='serif'] .ls-block, .ls-font-serif { html[data-font='mono'] .ls-block, .ls-font-mono { font-family: iawriter-mono, Nitti, Menlo, Courier, monospace; -} \ No newline at end of file +} diff --git a/src/main/frontend/components/views.cljs b/src/main/frontend/components/views.cljs index 442bfa9506..f1127ac7ef 100644 --- a/src/main/frontend/components/views.cljs +++ b/src/main/frontend/components/views.cljs @@ -252,7 +252,7 @@ (p/let [block (or block (and (fn? create-new-block) (create-new-block)))] (when block (cond - (util/meta-key? e) + (or (util/meta-key? e) (util/mobile?)) (redirect!) (.-shiftKey e) @@ -304,26 +304,27 @@ (render block*)))] [:div]) - (let [class (str "h-6 w-6 !p-1 text-muted-foreground transition-opacity duration-100 ease-in bg-gray-01 " - "opacity-" opacity)] - [:div.absolute.-right-1 - [:div.flex.flex-row.items-center - (shui/button - {:variant :ghost - :title "Open" - :on-click (fn [e] - (util/stop-propagation e) - (redirect!)) - :class class} - (ui/icon "arrow-right")) - (shui/button - {:variant :ghost - :title "Open in sidebar" - :class class - :on-click (fn [e] - (util/stop-propagation e) - (add-to-sidebar!))} - (ui/icon "layout-sidebar-right"))]])])) + (when-not (util/mobile?) + (let [class (str "h-6 w-6 !p-1 text-muted-foreground transition-opacity duration-100 ease-in bg-gray-01 " + "opacity-" opacity)] + [:div.absolute.-right-1 + [:div.flex.flex-row.items-center + (shui/button + {:variant :ghost + :title "Open" + :on-click (fn [e] + (util/stop-propagation e) + (redirect!)) + :class class} + (ui/icon "arrow-right")) + (shui/button + {:variant :ghost + :title "Open in sidebar" + :class class + :on-click (fn [e] + (util/stop-propagation e) + (add-to-sidebar!))} + (ui/icon "layout-sidebar-right"))]]))])) (defn build-columns [config properties & {:keys [with-object-name? with-id? add-tags-column?] diff --git a/src/main/frontend/db/async.cljs b/src/main/frontend/db/async.cljs index 46b2d8e9a5..c8a1080ef1 100644 --- a/src/main/frontend/db/async.cljs +++ b/src/main/frontend/db/async.cljs @@ -121,7 +121,9 @@ (when-not skip-refresh? (react/refresh-affected-queries! graph affected-keys {:skip-kv-custom-keys? true})))) - (if children-only? children block)) + (if children-only? + children + (if skip-transact? block (db/entity (:db/id block))))) (p/catch (fn [error] (js/console.error error) (throw (ex-info "get-block error" {:block id-uuid-or-name})))))))) diff --git a/src/main/frontend/handler.cljs b/src/main/frontend/handler.cljs index e14b31fd03..d428852c2d 100644 --- a/src/main/frontend/handler.cljs +++ b/src/main/frontend/handler.cljs @@ -26,7 +26,6 @@ [frontend.handler.plugin-config :as plugin-config-handler] [frontend.handler.repo :as repo-handler] [frontend.handler.repo-config :as repo-config-handler] - [frontend.handler.test :as test] [frontend.handler.ui :as ui-handler] [frontend.handler.user :as user-handler] [frontend.idb :as idb] @@ -138,7 +137,6 @@ [render] (idb/start) - (test/setup-test!) (get-system-info) (set-global-error-notification!) diff --git a/src/main/frontend/handler/dnd.cljs b/src/main/frontend/handler/dnd.cljs index f293090f5e..d7f5afa9a1 100644 --- a/src/main/frontend/handler/dnd.cljs +++ b/src/main/frontend/handler/dnd.cljs @@ -6,10 +6,18 @@ [frontend.handler.property :as property-handler] [frontend.modules.outliner.op :as outliner-op] [frontend.modules.outliner.ui :as ui-outliner-tx] - [frontend.util.ref :as ref] [frontend.state :as state] + [frontend.util.ref :as ref] [logseq.db :as ldb])) +(defn set-drag-image! + ([e image] + (set-drag-image! e image 0 0)) + ([e image offset-x offset-y] + (let [dt (.-dataTransfer e)] + (.setDragImage dt image offset-x offset-y) + e))) + (defn move-blocks [^js event blocks target-block original-block move-to] (let [target-block (db/entity (:db/id target-block)) diff --git a/src/main/frontend/handler/test.cljs b/src/main/frontend/handler/test.cljs deleted file mode 100644 index 26f198b63c..0000000000 --- a/src/main/frontend/handler/test.cljs +++ /dev/null @@ -1,16 +0,0 @@ -(ns frontend.handler.test - "Prepare for running e2e tests" - (:require [frontend.storage :as storage] - [frontend.state :as state])) - -(defn clear-whiteboard-storage-for-e2e-tests - [] - (storage/set :whiteboard/onboarding-whiteboard? false) - (storage/set :whiteboard/onboarding-tour? false) - (state/set-state! :whiteboard/onboarding-whiteboard? false) - (state/set-state! :whiteboard/onboarding-tour? false) - (prn :debug :whiteboard/onboarding-whiteboard? (:whiteboard/onboarding-whiteboard? @state/state))) - -(defn setup-test! - [] - (set! (.-clearWhiteboardStorage js/window) clear-whiteboard-storage-for-e2e-tests)) diff --git a/src/main/frontend/modules/shortcut/config.cljs b/src/main/frontend/modules/shortcut/config.cljs index d58d9f4efe..098d0ae22b 100644 --- a/src/main/frontend/modules/shortcut/config.cljs +++ b/src/main/frontend/modules/shortcut/config.cljs @@ -462,9 +462,11 @@ :binding []} :graph/add {:fn (fn [] (route-handler/redirect! {:to :graphs})) + :inactive config/publishing? :binding []} :graph/db-add {:fn #(state/pub-event! [:graph/new-db-graph]) + :inactive config/publishing? :binding false} :graph/db-save {:fn #(state/pub-event! [:graph/save-db-to-disk]) @@ -541,6 +543,7 @@ :editor/quick-add {:binding (if mac? "mod+e" "mod+alt+e") :db-graph? true + :inactive config/publishing? :fn editor-handler/quick-add} :editor/jump {:binding "mod+j" :fn jump-handler/jump-to} diff --git a/src/main/frontend/persist_db/browser.cljs b/src/main/frontend/persist_db/browser.cljs index 05be274aa3..b80e2025fa 100644 --- a/src/main/frontend/persist_db/browser.cljs +++ b/src/main/frontend/persist_db/browser.cljs @@ -85,7 +85,7 @@ (defn start-db-worker! [] (when-not util/node-test? - (let [worker-url "js/db-worker.js" + (let [worker-url (if config/publishing? "static/js/db-worker.js" "js/db-worker.js") worker (js/Worker. (str worker-url "?electron=" (util/electron?) "&publishing=" config/publishing?)) wrapped-worker* (Comlink/wrap worker) wrapped-worker (fn [qkw direct-pass? & args] diff --git a/src/main/frontend/worker/db_worker.cljs b/src/main/frontend/worker/db_worker.cljs index b8190603c3..42ba275758 100644 --- a/src/main/frontend/worker/db_worker.cljs +++ b/src/main/frontend/worker/db_worker.cljs @@ -249,7 +249,7 @@ (not (number? last-gc-at)) (> (- (common-util/time-ms) last-gc-at) (* 3 24 3600 1000))) ; 3 days ago (println :debug "gc current graph") - (doseq [db [sqlite-db client-ops-db]] + (doseq [db (if @*publishing? [sqlite-db] [sqlite-db client-ops-db])] (sqlite-gc/gc-kvs-table! db {:full-gc? full-gc?}) (.exec db "VACUUM")) (d/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at diff --git a/src/main/frontend/worker/search.cljs b/src/main/frontend/worker/search.cljs index e6d3cd7208..d15c6273d7 100644 --- a/src/main/frontend/worker/search.cljs +++ b/src/main/frontend/worker/search.cljs @@ -7,6 +7,7 @@ [datascript.core :as d] [frontend.common.search-fuzzy :as fuzzy] [goog.object :as gobj] + [logseq.common.config :as common-config] [logseq.common.util :as common-util] [logseq.common.util.namespace :as ns-util] [logseq.db :as ldb] @@ -193,11 +194,17 @@ DROP TRIGGER IF EXISTS blocks_au; (seq (fuzzy/search-normalize match true)) (seq (fuzzy/search-normalize q true)))))) +(defn- hidden-entity? + [entity] + (or (ldb/hidden? entity) + (let [page (:block/page entity)] + (and (ldb/hidden? page) + (not= (:block/title page) common-config/quick-add-page-name))))) + (defn- page-or-object? [entity] (and (or (ldb/page? entity) (ldb/object? entity)) - (not (ldb/hidden? entity)) - (not (ldb/hidden? (:block/page entity))))) + (not (hidden-entity? entity)))) (defn get-all-fuzzy-supported-blocks "Only pages and objects are supported now." @@ -209,9 +216,7 @@ DROP TRIGGER IF EXISTS blocks_au; (map :e))) blocks (->> (distinct (concat page-ids object-ids)) (map #(d/entity db %)))] - (->> blocks - (remove ldb/hidden?) - (remove #(ldb/hidden? (:block/page %)))))) + (remove hidden-entity? blocks))) (defn- sanitize [content] @@ -357,9 +362,7 @@ DROP TRIGGER IF EXISTS blocks_au; (->> (d/datoms db :avet :block/uuid) (map :v) (keep #(d/entity db [:block/uuid %])) - (remove (fn [e] - (or (ldb/hidden? e) - (ldb/hidden? (:block/page e)))))))) + (remove hidden-entity?)))) (defn build-blocks-indice [repo db] @@ -387,8 +390,7 @@ DROP TRIGGER IF EXISTS blocks_au; (keep #(d/entity db-before %) blocks-to-remove-set)) :blocks-to-add (->> (keep #(d/entity db-after %) blocks-to-add-set') - (remove ldb/hidden?) - (remove #(ldb/hidden? (:block/page %))))}))) + (remove hidden-entity?))}))) (defn- get-affected-blocks [repo tx-report] diff --git a/src/main/mobile/components/app.cljs b/src/main/mobile/components/app.cljs index 3a77a33c92..620c089466 100644 --- a/src/main/mobile/components/app.cljs +++ b/src/main/mobile/components/app.cljs @@ -4,7 +4,6 @@ [clojure.string :as string] [frontend.components.journal :as journal] [frontend.components.rtc.indicator :as rtc-indicator] - [frontend.config :as config] [frontend.date :as date] [frontend.db :as db] [frontend.db.conn :as db-conn] @@ -137,7 +136,6 @@ (when (and repo (ldb/get-graph-rtc-uuid (db/get-db)) (user-handler/logged-in?) - (config/db-based-graph? repo) (user-handler/team-member?)) [:<> ;; (rum/with-key (rtc-collaborators) diff --git a/src/main/mobile/components/editor_toolbar.cljs b/src/main/mobile/components/editor_toolbar.cljs index bd4496d056..84b4569b19 100644 --- a/src/main/mobile/components/editor_toolbar.cljs +++ b/src/main/mobile/components/editor_toolbar.cljs @@ -1,7 +1,6 @@ (ns mobile.components.editor-toolbar "Mobile editor toolbar" - (:require [mobile.init :as init] - [frontend.commands :as commands] + (:require [frontend.commands :as commands] [frontend.handler.editor :as editor-handler] [frontend.mobile.camera :as mobile-camera] [frontend.mobile.haptics :as haptics] @@ -11,6 +10,8 @@ [frontend.util.cursor :as cursor] [goog.dom :as gdom] [logseq.common.util.page-ref :as page-ref] + [mobile.init :as init] + [promesa.core :as p] [rum.core :as rum])) (defn- blur-if-compositing @@ -93,6 +94,7 @@ (command #(let [parent-id (state/get-edit-input-id)] (mobile-camera/embed-photo parent-id)) {:icon "camera"} true)] [:div.toolbar-hide-keyboard - (command #(do - (state/clear-edit!) - (init/keyboard-hide)) {:icon "keyboard-show"})]]))) + (command #(p/do! + (editor-handler/save-current-block!) + (state/clear-edit!) + (init/keyboard-hide)) {:icon "keyboard-show"})]]))) diff --git a/src/main/mobile/components/modal.cljs b/src/main/mobile/components/modal.cljs index 4562d5ca64..e40f1cd894 100644 --- a/src/main/mobile/components/modal.cljs +++ b/src/main/mobile/components/modal.cljs @@ -7,7 +7,7 @@ [frontend.handler.page :as page-handler] [frontend.state :as state] [frontend.ui :as ui] - [logseq.db :as ldb] + [logseq.db.frontend.entity-util :as entity-util] [mobile.components.ui :as mobile-ui] [mobile.init :as init] [mobile.ionic :as ion] @@ -49,7 +49,7 @@ {:on-click (fn [] (mobile-ui/open-modal! (str "⚠️ Are you sure you want to delete this " - (if (ldb/page? block) "page" "block") + (if (entity-util/page? block) "page" "block") "?") {:type :alert :on-action (fn [{:keys [role]}] diff --git a/src/main/mobile/components/popup.cljs b/src/main/mobile/components/popup.cljs index fb8d5d9b2e..c302e6ad25 100644 --- a/src/main/mobile/components/popup.cljs +++ b/src/main/mobile/components/popup.cljs @@ -77,21 +77,18 @@ [1 #js [0 1]] [0.75 #js [0 0.75 1]])] (when open? - (if (= :ls-quick-add (:id opts)) - (when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)] - (when (:block/_parent add-page) - (js/setTimeout - (fn [] - (let [block (last (ldb/sort-by-order (:block/_parent add-page)))] - (editor-handler/edit-block! block :max {:container-id :unknown-container}))) - 500))) - (do - (state/clear-edit!) - (init/keyboard-hide)))) + (state/clear-edit!) + (init/keyboard-hide)) (ion/modal (merge {:isOpen (boolean open?) :initialBreakpoint initial-breakpoint + :onDidPresent (fn [] + (when (= :ls-quick-add (:id opts)) + (when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)] + (when (:block/_parent add-page) + (let [block (last (ldb/sort-by-order (:block/_parent add-page)))] + (editor-handler/edit-block! block :max {:container-id :unknown-container})))))) :breakpoints breakpoints :onDidDismiss (fn [] (mobile-state/set-popup! nil) diff --git a/src/main/mobile/components/search.cljs b/src/main/mobile/components/search.cljs index a7a803df6a..a4c3be2d53 100644 --- a/src/main/mobile/components/search.cljs +++ b/src/main/mobile/components/search.cljs @@ -1,8 +1,6 @@ (ns mobile.components.search "Mobile search" - (:require [mobile.ionic :as ion] - [mobile.state :as mobile-state] - [clojure.string :as string] + (:require [clojure.string :as string] [frontend.components.cmdk.core :as cmdk] [frontend.db :as db] [frontend.handler.block :as block-handler] @@ -13,6 +11,8 @@ [frontend.util :as util] [logseq.db :as ldb] [logseq.shui.hooks :as hooks] + [mobile.ionic :as ion] + [mobile.state :as mobile-state] [promesa.core :as p] [rum.core :as rum])) @@ -106,7 +106,7 @@ (ion/item {:on-click #(set-input! item)} [:div.flex.flex-row.items-center.gap-1 - (ui/icon "search" {:size 14 + (ui/icon "search" {:size 15 :class "text-muted-foreground"}) item])))] @@ -122,7 +122,7 @@ (when header [:div.opacity-50.text-sm header]) - [:div.flex.flex-row.items-center.gap-1 - (when icon (ui/icon icon {:size 14 - :class "text-muted-foreground"})) + [:div.flex.flex-row.items-start.gap-1 + (when icon (ui/icon icon {:size 15 + :class "text-muted-foreground mt-1"})) [:div text]]])))))))) diff --git a/tailwind.mobile.css b/tailwind.mobile.css index 28cd22f714..0da6b8fe9d 100644 --- a/tailwind.mobile.css +++ b/tailwind.mobile.css @@ -30,5 +30,6 @@ @import "src/main/frontend/extensions/code.css"; @import "src/main/frontend/components/file_sync.css"; @import "src/main/frontend/components/table.css"; +@import "src/main/frontend/components/command_palette.css"; @import-glob "src/main/mobile/**/[!_]*.css";