Răsfoiți Sursa

Merge remote-tracking branch 'upstream/master' into whiteboards

Peng Xiao 3 ani în urmă
părinte
comite
1d7374ba86

+ 2 - 2
android/app/build.gradle

@@ -6,8 +6,8 @@ android {
         applicationId "com.logseq.app"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 33
-        versionName "0.7.9"
+        versionCode 34
+        versionName "0.8.0"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         aaptOptions {
              // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

+ 10 - 1
e2e-tests/sidebar.spec.ts

@@ -1,6 +1,6 @@
 import { expect } from '@playwright/test'
 import { test } from './fixtures'
-import { createRandomPage, openLeftSidebar, searchAndJumpToPage } from './utils'
+import { createPage, createRandomPage, openLeftSidebar, randomString, searchAndJumpToPage } from './utils'
 
 /***
  * Test side bar features
@@ -52,3 +52,12 @@ test('recent is updated #4320', async ({ page }) => {
   expect(await firstRecent.textContent()).toContain(page1)
   expect(await secondRecent.textContent()).toContain(page2)
 })
+
+test('recent file name is displayed correctly #6297', async ({ page }) => {
+  const pageName = randomString(5) + "_@#$%^&*()_" + randomString(5)
+  await createPage(page, pageName)
+  await page.fill('textarea >> nth=0', 'Random Content')
+
+  const firstRecent = page.locator('.nav-content-item.recent li >> nth=0')
+  expect(await firstRecent.textContent()).toContain(pageName)
+})

+ 4 - 4
ios/App/App.xcodeproj/project.pbxproj

@@ -542,7 +542,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.7.9;
+				MARKETING_VERSION = 0.8.0;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -568,7 +568,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.7.9;
+				MARKETING_VERSION = 0.8.0;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -593,7 +593,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.7.9;
+				MARKETING_VERSION = 0.8.0;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -620,7 +620,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.7.9;
+				MARKETING_VERSION = 0.8.0;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 36 - 38
libs/src/LSPlugin.core.ts

@@ -437,9 +437,11 @@ class ExistedImportedPluginPackageError extends Error {
 /**
  * Host plugin for local
  */
-class PluginLocal extends EventEmitter<
-  'loaded' | 'unloaded' | 'beforeunload' | 'error' | string
-> {
+class PluginLocal extends EventEmitter<'loaded'
+  | 'unloaded'
+  | 'beforeunload'
+  | 'error'
+  | string> {
   private _sdk: Partial<PluginLocalSDKMetadata> = {}
   private _disposes: Array<() => Promise<any>> = []
   private _id: PluginLocalIdentity
@@ -573,7 +575,7 @@ class PluginLocal extends EventEmitter<
     const localRoot = (this._localRoot = safetyPathNormalize(url))
     const logseq: Partial<LSPluginPkgConfig> = pkg.logseq || {}
 
-    // Pick legal attrs
+      // Pick legal attrs
     ;[
       'name',
       'author',
@@ -681,10 +683,10 @@ class PluginLocal extends EventEmitter<
     <meta charset="UTF-8">
     <title>logseq plugin entry</title>
     ${
-      IS_DEV
-        ? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
-        : `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
-    }
+        IS_DEV
+          ? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
+          : `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
+      }
     
   </head>
   <body>
@@ -1119,8 +1121,7 @@ class PluginLocal extends EventEmitter<
  * Host plugin core
  */
 class LSPluginCore
-  extends EventEmitter<
-    | 'beforeenable'
+  extends EventEmitter<'beforeenable'
     | 'enabled'
     | 'beforedisable'
     | 'disabled'
@@ -1133,10 +1134,8 @@ class LSPluginCore
     | 'settings-changed'
     | 'unlink-plugin'
     | 'beforereload'
-    | 'reloaded'
-  >
-  implements ILSPluginThemeManager
-{
+    | 'reloaded'>
+  implements ILSPluginThemeManager {
   private _isRegistering = false
   private _readyIndicator?: DeferredActor
   private readonly _hostMountedActor: DeferredActor = deferred()
@@ -1150,10 +1149,8 @@ class LSPluginCore
     externals: [],
   }
   private readonly _registeredThemes = new Map<PluginLocalIdentity, Theme[]>()
-  private readonly _registeredPlugins = new Map<
-    PluginLocalIdentity,
-    PluginLocal
-  >()
+  private readonly _registeredPlugins = new Map<PluginLocalIdentity,
+    PluginLocal>()
   private _currentTheme: {
     pid: PluginLocalIdentity
     opt: Theme | LegacyTheme
@@ -1229,21 +1226,22 @@ class LSPluginCore
       return
     }
 
-    const perfTable = new Map<
-      string,
-      { o: PluginLocal; s: number; e: number }
-    >()
+    const perfTable = new Map<string,
+      { o: PluginLocal; s: number; e: number }>()
     const debugPerfInfo = () => {
-      const data = Array.from(perfTable.values()).reduce((ac, it) => {
-        const { options, status, disabled } = it.o
-
-        ac[it.o.id] = {
-          name: options.name,
-          entry: options.entry,
-          status: status,
-          enabled:
-            typeof disabled === 'boolean' ? (!disabled ? '🟢' : '⚫️') : '🔴',
-          perf: !it.e ? it.o.loadErr : `${(it.e - it.s).toFixed(2)}ms`,
+      const data: any = Array.from(perfTable.values()).reduce((ac, it) => {
+        const { id, options, status, disabled } = it.o
+
+        if (disabled !== true &&
+          (options.entry || (!options.name && !options.entry))) {
+          ac[id] = {
+            name: options.name,
+            entry: options.entry,
+            status: status,
+            enabled:
+              typeof disabled === 'boolean' ? (!disabled ? '🟢' : '⚫️') : '🔴',
+            perf: !it.e ? it.o.loadErr : `${(it.e - it.s).toFixed(2)}ms`,
+          }
         }
 
         return ac
@@ -1554,12 +1552,12 @@ class LSPluginCore
       await this.saveUserPreferences(
         theme.mode
           ? {
-              themes: {
-                ...this._userPreferences.themes,
-                mode: theme.mode,
-                [theme.mode]: theme,
-              },
-            }
+            themes: {
+              ...this._userPreferences.themes,
+              mode: theme.mode,
+              [theme.mode]: theme,
+            },
+          }
           : { theme: theme }
       )
     }

+ 2 - 1
libs/src/LSPlugin.ts

@@ -232,7 +232,7 @@ export type SettingSchemaDesc = {
   default: string | number | boolean | Array<any> | object | null
   title: string
   description: string // support markdown
-  inputAs?: 'color' | 'date' | 'datetime-local' | 'range'
+  inputAs?: 'color' | 'date' | 'datetime-local' | 'range' | 'textarea'
   enumChoices?: Array<string>
   enumPicker?: 'select' | 'radio' | 'checkbox' // default: select
 }
@@ -650,6 +650,7 @@ export interface IEditorProxy extends Record<string, any> {
   ) => Promise<void>
 
   editBlock: (srcBlock: BlockIdentity, opts?: { pos: number }) => Promise<void>
+  selectBlock: (srcBlock: BlockIdentity) => Promise<void>
 
   upsertBlockProperty: (
     block: BlockIdentity,

+ 6 - 2
libs/src/LSPlugin.user.ts

@@ -5,6 +5,7 @@ import {
   safetyPathJoin,
 } from './helpers'
 import { LSPluginCaller } from './LSPlugin.caller'
+import * as callableAPIs from './callable.apis'
 import {
   IAppProxy,
   IDBProxy,
@@ -48,6 +49,9 @@ declare global {
   }
 }
 
+type callableMethods =
+  keyof typeof callableAPIs | string // host exported SDK apis & host platform related apis
+
 const PROXY_CONTINUE = Symbol.for('proxy-continue')
 const debug = Debug('LSPlugin:user')
 
@@ -623,14 +627,14 @@ export class LSPluginUser
     })
   }
 
-  _execCallableAPIAsync(method, ...args) {
+  _execCallableAPIAsync(method: callableMethods, ...args) {
     return this._caller.callAsync(`api:call`, {
       method,
       args,
     })
   }
 
-  _execCallableAPI(method, ...args) {
+  _execCallableAPI(method: callableMethods, ...args) {
     this._caller.call(`api:call`, {
       method,
       args,

+ 3 - 0
libs/src/callable.apis.ts

@@ -1,5 +1,8 @@
 import { PluginLocal } from './LSPlugin.core'
 
+/**
+ * Run in host
+ */
 export function setSDKMetadata(this: PluginLocal, data: any) {
   if (this?.sdk && data) {
     this.sdk = Object.assign({}, this.sdk, data)

+ 1 - 1
package.json

@@ -93,7 +93,7 @@
         "codemirror": "5.58.1",
         "d3-force": "3.0.0",
         "diff": "5.0.0",
-        "electron": "15.1.2",
+        "electron": "19.0.10",
         "electron-dl": "3.3.0",
         "fs": "0.0.1-security",
         "fs-extra": "9.1.0",

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
resources/js/lsplugin.core.js


+ 4 - 4
resources/package.json

@@ -1,6 +1,6 @@
 {
   "name": "Logseq-local-test-revert-me-back",
-  "version": "0.7.9",
+  "version": "0.8.0",
   "main": "electron.js",
   "author": "Logseq",
   "license": "AGPL-3.0",
@@ -12,7 +12,7 @@
     "electron:make": "electron-forge make",
     "electron:make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
     "electron:publish:github": "electron-forge publish",
-    "rebuild:better-sqlite3": "electron-rebuild -v 15.1.2 -f -w better-sqlite3",
+    "rebuild:better-sqlite3": "electron-rebuild -v 19.0.10 -f -w better-sqlite3",
     "postinstall": "install-app-deps"
   },
   "config": {
@@ -47,13 +47,13 @@
     "@electron-forge/maker-rpm": "^6.0.0-beta.57",
     "@electron-forge/maker-squirrel": "^6.0.0-beta.57",
     "@electron-forge/maker-zip": "^6.0.0-beta.57",
-    "electron": "15.1.2",
+    "electron": "19.0.10",
     "electron-builder": "^22.11.7",
     "electron-forge-maker-appimage": "trusktr/electron-forge-maker-appimage#patch-1",
     "electron-rebuild": "3.2.5"
   },
   "resolutions": {
-    "**/electron": "15.1.2",
+    "**/electron": "19.0.10",
     "**/node-gyp": "9.0.0"
   }
 }

+ 11 - 8
src/electron/electron/search.cljs

@@ -3,7 +3,8 @@
             ["fs-extra" :as fs]
             ["better-sqlite3" :as sqlite3]
             [clojure.string :as string]
-            ["electron" :refer [app]]))
+            ["electron" :refer [app]]
+            [electron.utils :refer [logger]]))
 
 ;; version of the search cache
 ;; ver. 0.0.1: initial version
@@ -120,12 +121,15 @@
 
 (defn open-db!
   [db-name]
-  (let [[db-sanitized-name db-full-path] (get-db-full-path db-name)
-        db (sqlite3 db-full-path nil)
-        _ (create-blocks-table! db)
-        _ (create-blocks-fts-table! db)
-        _ (add-triggers! db)]
-    (swap! databases assoc db-sanitized-name db)))
+    (let [[db-sanitized-name db-full-path] (get-db-full-path db-name)]
+      (try (let [db (sqlite3 db-full-path nil)]
+             (create-blocks-table! db)
+             (create-blocks-fts-table! db)
+             (add-triggers! db)
+             (swap! databases assoc db-sanitized-name db))
+           (catch :default e
+             (.error logger (str e ": " db-name))
+             (fs/unlinkSync db-full-path)))))
 
 (defn open-dbs!
   []
@@ -236,5 +240,4 @@
   (def repo (first (keys @databases)))
   (query repo
          "select * from blocks_fts")
-
   (delete-db! repo))

+ 1 - 1
src/electron/electron/utils.cljs

@@ -46,7 +46,7 @@
         dirs (js->clj (fs/readdirSync plugins-root #js{"withFileTypes" true}))
         dirs (->> dirs
                   (filter #(.isDirectory %))
-                  (filter #(not (string/starts-with? (.-name %) "_")))
+                  (filter (fn [f] (not (some #(string/starts-with? (.-name f) %) ["_" "."]))))
                   (map #(path/join plugins-root (.-name %))))]
     dirs))
 

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -1139,7 +1139,7 @@
           (page-embed (assoc config :link-depth (inc link-depth)) page-name)))
 
       (block-ref/string-block-ref? a)
-      (when-let [s (-> block-ref/get-string-block-ref-id string/trim)]
+      (when-let [s (-> a block-ref/get-string-block-ref-id string/trim)]
         (when-let [id (some-> s parse-uuid)]
           (block-embed (assoc config :link-depth (inc link-depth)) id)))
 

+ 1 - 1
src/main/frontend/components/page.cljs

@@ -97,7 +97,7 @@
       [:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
        [:span.bullet-container.cursor
         [:span.bullet]]]
-      [:div.flex.flex-1 {:tabindex 0
+      [:div.flex.flex-1 {:tabIndex 0
                          :on-key-press (fn [e]
                                          (when (= "Enter" (util/ekey e))
                                            (handler-fn)))

+ 6 - 1
src/main/frontend/components/plugins.css

@@ -545,7 +545,12 @@
 
         .form-input {
           padding: 5px;
-          width: 50%;
+          width: 70%;
+        }
+
+        textarea.form-input {
+          overflow-y: auto;
+          resize: vertical;
         }
 
         .form-select {

+ 1 - 1
src/main/frontend/components/plugins_settings.cljs

@@ -25,7 +25,7 @@
 
     (let [input-as (util/safe-lower-case (or inputAs (name type)))
           input-as (if (= input-as "string") :text (keyword input-as))]
-      [:input
+      [(if (= input-as :textarea) :textarea :input)
        {:class        (util/classnames [{:form-input (not (contains? #{:color :range} input-as))}])
         :type         (name input-as)
         :defaultValue (or val default)

+ 9 - 5
src/main/frontend/extensions/pdf/assets.cljs

@@ -261,11 +261,15 @@
 (defn fix-local-asset-filename
   [filename]
   (when-not (string/blank? filename)
-    (let [local-asset? (re-find #"[0-9]{13}_\d$" filename)]
-      (-> filename
-          (subs 0 (- (count filename) (if local-asset? 15 0)))
-          (string/replace #"^hls__" "")
-          (string/replace "_" " ")))))
+    (let [local-asset? (re-find #"[0-9]{13}_\d$" filename)
+          hls? (and local-asset? (re-find #"^hls__" filename))]
+      (if (or local-asset? hls?)
+        (-> filename
+            (subs 0 (- (count filename) 15))
+            (string/replace #"^hls__" "")
+            (string/replace "_" " ")
+            (string/trimr))
+        filename))))
 
 (rum/defc human-hls-filename-display
   [title]

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns frontend.version)
 
-(defonce version "0.7.9")
+(defonce version "0.8.0")

+ 8 - 1
src/main/logseq/api.cljs

@@ -442,6 +442,11 @@
   [block-uuid]
   (editor-handler/open-block-in-sidebar! (uuid block-uuid)))
 
+(def ^:export select_block
+  (fn [block-uuid]
+    (when-let [block (db-model/get-block-by-uuid block-uuid)]
+      (editor-handler/select-block! (:block/uuid block)) nil)))
+
 (def ^:export edit_block
   (fn [block-uuid ^js opts]
     (when-let [block-uuid (and block-uuid (uuid block-uuid))]
@@ -545,7 +550,9 @@
 (def ^:export get_current_block
   (fn [^js opts]
     (let [block (state/get-edit-block)
-          block (or block (some-> (first (state/get-selection-blocks))
+          block (or block
+                    (some-> (or (first (state/get-selection-blocks))
+                                (gdom/getElement (state/get-editing-block-dom-id)))
                             (.getAttribute "blockid")
                             (db-model/get-block-by-uuid)))]
       (get_block (:db/id block) opts))))

+ 15 - 0
src/test/frontend/extensions/pdf/assets_test.cljs

@@ -0,0 +1,15 @@
+(ns frontend.extensions.pdf.assets-test
+  (:require [clojure.test :as test :refer [are deftest testing]]
+            [frontend.extensions.pdf.assets :as assets]))
+
+(deftest fix-local-asset-filename
+  (testing "matched filenames"
+    (are [x y] (= y (assets/fix-local-asset-filename x))
+      "2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"
+      "hls__2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"))
+  (testing "non matched filenames"
+    (are [x y] (= y (assets/fix-local-asset-filename x))
+      "foo" "foo"
+      "foo_bar" "foo_bar"
+      "foo__bar" "foo__bar"
+      "foo_bar.pdf" "foo_bar.pdf")))

+ 11 - 11
yarn.lock

@@ -324,7 +324,7 @@
   resolved "https://registry.yarnpkg.com/@capacitor/status-bar/-/status-bar-1.0.6.tgz#d58c9087cfc7c7377e8009bea86152e4fdd2939e"
   integrity sha512-5MGWFq76iiKvHpbZ/Xc0Zig3WZyzWZ62wvC4qxak8OuVHBNG4fA1p/XXY9teQPaU3SupEJHnLkw6Gn1LuDp+ew==
 
-"@electron/get@^1.13.0":
+"@electron/get@^1.14.1":
   version "1.14.1"
   resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.14.1.tgz#16ba75f02dffb74c23965e72d617adc721d27f40"
   integrity sha512-BrZYyL/6m0ZXz/lDxy/nlVhQz+WF+iPS6qXolEU8atw7h6v1aYkjwJZ63m+bJMBTxDE66X+r2tPS4a/8C82sZw==
@@ -879,10 +879,10 @@
   resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644"
   integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==
 
-"@types/node@^14.6.2":
-  version "14.18.12"
-  resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24"
-  integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==
+"@types/node@^16.11.26":
+  version "16.11.44"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.44.tgz#447e3eecad9d19bd779f4a575f361d34898c0722"
+  integrity sha512-gwP6+QDgL5TDBIWh1lbYh3EFPU11pa+8xcamcsA3ROkp3A9X+/3Y5cRgq93VPEEE+CGfxlQnqkg1kkWGBgh3fw==
 
 "@types/normalize-package-data@^2.4.0":
   version "2.4.1"
@@ -2542,13 +2542,13 @@ electron-to-chromium@^1.4.84:
   resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.87.tgz#1aeacfa50b2fbf3ecf50a78fbebd8f259d4fe208"
   integrity sha512-EXXTtDHFUKdFVkCnhauU7Xp8wmFC1ZG6GK9a1BeI2vvNhy61IwfNPo/CRexhf7mh4ajxAHJPind62BzpzVUeuQ==
 
-electron@15.1.2:
-  version "15.1.2"
-  resolved "https://registry.yarnpkg.com/electron/-/electron-15.1.2.tgz#be1e362ab7307e38155709b0862e6a87f5e748b3"
-  integrity sha512-cU5x1ZvhwcTtzClJrsxqbvCocs40uhuXcdXbXFMpe6XnbnjruTbwrB2V0OxN01pStDrYihnfKo2yhfEvhO3zmw==
+electron@19.0.10:
+  version "19.0.10"
+  resolved "https://registry.yarnpkg.com/electron/-/electron-19.0.10.tgz#4d2f03f307fbb70a295ff419112130b75661eda9"
+  integrity sha512-EiWtPWdD7CzkRkp1cw7t0N9W2qhI5XZOudHX7daOh5wI076nsdV2dtlAf/XyTHhPNoKR5qhTWrSnYL9PY6D1vg==
   dependencies:
-    "@electron/get" "^1.13.0"
-    "@types/node" "^14.6.2"
+    "@electron/get" "^1.14.1"
+    "@types/node" "^16.11.26"
     extract-zip "^1.0.3"
 
 element-resize-detector@^1.1.14:

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff