mirror of
https://github.com/logseq/logseq.git
synced 2026-05-22 03:34:07 +00:00
Merge branch 'feat/db' into refactor/block-schema
This commit is contained in:
@@ -3,25 +3,26 @@
|
||||
and favorite fns. This ns should be agnostic of file or db concerns but there
|
||||
is still some file-specific tech debt to remove from create!"
|
||||
(:require [clojure.string :as string]
|
||||
[frontend.db :as db]
|
||||
[frontend.handler.config :as config-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.state :as state]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.config :as common-config]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.config :as config]
|
||||
[frontend.fs :as fs]
|
||||
[promesa.core :as p]
|
||||
[frontend.handler.block :as block-handler]
|
||||
[logseq.db :as ldb]
|
||||
[frontend.db.conn :as conn]
|
||||
[datascript.core :as d]
|
||||
[frontend.modules.outliner.ui :as ui-outliner-tx]
|
||||
[frontend.modules.outliner.op :as outliner-op]
|
||||
[frontend.config :as config]
|
||||
[frontend.db :as db]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.fs :as fs]
|
||||
[frontend.handler.block :as block-handler]
|
||||
[frontend.handler.config :as config-handler]
|
||||
[frontend.handler.db-based.editor :as db-editor-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.user :as user]
|
||||
[frontend.modules.outliner.op :as outliner-op]
|
||||
[frontend.modules.outliner.ui :as ui-outliner-tx]
|
||||
[frontend.state :as state]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[frontend.handler.notification :as notification]))
|
||||
[logseq.db :as ldb]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- wrap-tags
|
||||
"Tags might have multiple words"
|
||||
@@ -59,11 +60,13 @@
|
||||
(if (and has-tags? (nil? title'))
|
||||
(notification/show! "Page name can't include \"#\"." :warning)
|
||||
(when-not (string/blank? title')
|
||||
(p/let [options' (if db-based?
|
||||
(cond->
|
||||
(update options :tags concat (:block/tags parsed-result))
|
||||
(p/let [current-user-id (user/user-uuid)
|
||||
options' (if db-based?
|
||||
(cond-> (update options :tags concat (:block/tags parsed-result))
|
||||
(nil? (:split-namespace? options))
|
||||
(assoc :split-namespace? true))
|
||||
(assoc :split-namespace? true)
|
||||
current-user-id
|
||||
(assoc :created-by current-user-id))
|
||||
options)
|
||||
result (ui-outliner-tx/transact!
|
||||
{:outliner-op :create-page}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
[frontend.handler.property.file :as property-file]
|
||||
[frontend.handler.property.util :as pu]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.user :as user]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.modules.outliner.op :as outliner-op]
|
||||
[frontend.modules.outliner.tree :as tree]
|
||||
@@ -334,14 +335,16 @@
|
||||
true
|
||||
|
||||
:else
|
||||
(not has-children?))]
|
||||
(not has-children?))
|
||||
current-user-id (user/user-uuid)]
|
||||
(ui-outliner-tx/transact!
|
||||
{:outliner-op :insert-blocks}
|
||||
(save-current-block! {:current-block current-block})
|
||||
(outliner-op/insert-blocks! [new-block] current-block {:sibling? sibling?
|
||||
:keep-uuid? keep-uuid?
|
||||
:ordered-list? ordered-list?
|
||||
:replace-empty-target? replace-empty-target?}))))
|
||||
:replace-empty-target? replace-empty-target?
|
||||
:created-by current-user-id}))))
|
||||
|
||||
(defn- block-self-alone-when-insert?
|
||||
[config uuid]
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
(throw (ex-info (str "fn-sym not found: " fn-sym) {})))))
|
||||
|
||||
(defn unregister-fn!
|
||||
"TODO: not working on multi-arity fns"
|
||||
[fn-sym]
|
||||
(let [ns (namespace fn-sym)
|
||||
s (munge (name fn-sym))]
|
||||
|
||||
@@ -8,6 +8,22 @@ if (typeof window === 'undefined') {
|
||||
global.window = {}
|
||||
}
|
||||
|
||||
// js patches
|
||||
;(function () {
|
||||
if (!window?.console) return
|
||||
const originalError = console.error
|
||||
console.error = (...args) => {
|
||||
if (args[0]?.startsWith(
|
||||
`Warning: Each child in a list should have a unique "key" prop`)) {
|
||||
console.groupCollapsed('[React] ⚠️ key warning!')
|
||||
console.warn(...args)
|
||||
console.groupEnd()
|
||||
return
|
||||
}
|
||||
originalError(...args)
|
||||
}
|
||||
})();
|
||||
|
||||
// Copy from https://github.com/primetwig/react-nestable/blob/dacea9dc191399a3520f5dc7623f5edebc83e7b7/dist/utils.js
|
||||
export const closest = (target, selector) => {
|
||||
// closest(e.target, '.field')
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
* :tags - tag uuids that are added to :block/tags
|
||||
* :persist-op? - when true, add an update-page op
|
||||
* :properties - properties to add to the page
|
||||
* :created-by - when set, set :logseq.property/created-by, only for db-based-graphs
|
||||
TODO: Add other options"
|
||||
[repo conn config title & {:as options}]
|
||||
(if (ldb/db-based-graph? @conn)
|
||||
|
||||
@@ -168,7 +168,9 @@
|
||||
(defn create
|
||||
"Pure function without side effects"
|
||||
[db title*
|
||||
{:keys [create-first-block? properties uuid persist-op? whiteboard? class? today-journal? split-namespace? skip-existing-page-check?]
|
||||
{:keys [create-first-block? properties uuid persist-op? whiteboard?
|
||||
class? today-journal? split-namespace? skip-existing-page-check?
|
||||
created-by]
|
||||
:or {create-first-block? true
|
||||
properties nil
|
||||
uuid nil
|
||||
@@ -203,7 +205,8 @@
|
||||
:page-uuid (when (uuid? uuid) uuid)
|
||||
:skip-existing-page-check? (if (some? skip-existing-page-check?)
|
||||
skip-existing-page-check?
|
||||
true)})
|
||||
true)
|
||||
:created-by created-by})
|
||||
[page parents] (if (and (text/namespace-page? title) split-namespace?)
|
||||
(let [pages (split-namespace-pages db page date-formatter)]
|
||||
[(last pages) (butlast pages)])
|
||||
|
||||
Reference in New Issue
Block a user