Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into zotero/poc
Browse files Browse the repository at this point in the history
  • Loading branch information
Weihua Lu committed Jul 20, 2021
2 parents 439889f + b3931be commit 65bd4d5
Show file tree
Hide file tree
Showing 38 changed files with 693 additions and 272 deletions.
2 changes: 1 addition & 1 deletion libs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logseq/libs",
"version": "0.0.1-alpha.25",
"version": "0.0.1-alpha.26",
"description": "Logseq SDK libraries",
"main": "dist/lsplugin.user.js",
"typings": "index.d.ts",
Expand Down
15 changes: 10 additions & 5 deletions libs/src/LSPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export interface IAppProxy {
getCurrentGraph: () => Promise<AppGraphInfo | null>

// router
pushState: (k: string, params?: {}) => void
replaceState: (k: string, params?: {}) => void
pushState: (k: string, params?: Record<string, any>, query?: Record<string, any>) => void
replaceState: (k: string, params?: Record<string, any>, query?: Record<string, any>) => void

// ui
showMsg: (content: string, status?: 'success' | 'warning' | string) => void
Expand All @@ -187,12 +187,12 @@ export interface IAppProxy {
registerUIItem: (
type: 'toolbar' | 'pagebar',
opts: { key: string, template: string }
) => boolean
) => void

registerPageMenuItem: (
tag: string,
action: (e: IHookEvent & { page: string }) => void
) => unknown
) => void

// events
onCurrentGraphChanged: IUserHook
Expand Down Expand Up @@ -231,7 +231,7 @@ export interface IEditorProxy extends Record<string, any> {
registerSlashCommand: (
tag: string,
action: BlockCommandCallback | Array<SlashCommandAction>
) => boolean
) => unknown

/**
* register a custom command in the block context menu (triggered by right clicking the block dot)
Expand Down Expand Up @@ -339,6 +339,11 @@ export interface IEditorProxy extends Record<string, any> {
getBlockProperty: (block: BlockIdentity, key: string) => Promise<any>

getBlockProperties: (block: BlockIdentity) => Promise<any>

scrollToBlockInPage: (
pageName: BlockPageName,
blockId: BlockIdentity
) => void
}

/**
Expand Down
28 changes: 17 additions & 11 deletions libs/src/LSPlugin.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
BlockCommandCallback,
StyleString,
ThemeOptions,
UIOptions, IHookEvent
UIOptions, IHookEvent, BlockIdentity, BlockPageName
} from './LSPlugin'
import Debug from 'debug'
import * as CSS from 'csstype'
Expand All @@ -24,6 +24,7 @@ declare global {
}
}

const PROXY_CONTINUE = Symbol.for('proxy-continue')
const debug = Debug('LSPlugin:user')

/**
Expand Down Expand Up @@ -67,15 +68,13 @@ const app: Partial<IAppProxy> = {
method: 'register-plugin-ui-item',
args: [pid, type, opts]
})

return false
},

registerPageMenuItem (
this: LSPluginUser,
tag: string,
action: (e: IHookEvent & { page: string }) => void
): unknown {
) {
if (typeof action !== 'function') {
return false
}
Expand All @@ -88,8 +87,6 @@ const app: Partial<IAppProxy> = {
type, {
key, label
}, action)

return false
}
}

Expand Down Expand Up @@ -142,15 +139,13 @@ const editor: Partial<IEditorProxy> = {
method: 'register-plugin-slash-command',
args: [this.baseInfo.id, [tag, actions]]
})

return false
},

registerBlockContextMenuItem (
this: LSPluginUser,
tag: string,
action: BlockCommandCallback
): unknown {
) {
if (typeof action !== 'function') {
return false
}
Expand All @@ -163,8 +158,19 @@ const editor: Partial<IEditorProxy> = {
type, {
key, label
}, action)
},

return false
scrollToBlockInPage (
this: LSPluginUser,
pageName: BlockPageName,
blockId: BlockIdentity
) {
const anchor = `block-content-` + blockId
this.App.pushState(
'page',
{ name: pageName },
{ anchor }
)
}
}

Expand Down Expand Up @@ -363,7 +369,7 @@ export class LSPluginUser extends EventEmitter<LSPluginUserEvents> implements IL
return function (this: any, ...args: any) {
if (origMethod) {
const ret = origMethod.apply(that, args)
if (ret === false) return
if (ret !== PROXY_CONTINUE) return
}

// Handle hook
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"gulp:watch": "gulp watch",
"gulp:build": "cross-env NODE_ENV=production gulp build",
"css:build": "postcss tailwind.all.css -o static/css/style.css --verbose --env production",
"css:watch": "postcss tailwind.all.css -o static/css/style.css --verbose --watch",
"cljs:watch": "clojure -M:cljs watch app publishing electron cards",
"css:watch": "TAILWIND_MODE=watch postcss tailwind.all.css -o static/css/style.css --verbose --watch",
"cljs:watch": "clojure -M:cljs watch app electron",
"cljs:electron-watch": "clojure -M:cljs watch app electron",
"cljs:release": "clojure -M:cljs release app publishing electron",
"cljs:electron-release": "clojure -M:cljs release app publishing electron --config-merge '{:asset-path \"./js\"}'",
Expand All @@ -62,6 +62,7 @@
"@excalidraw/excalidraw": "^0.4.2",
"@kanru/rage-wasm": "^0.2.1",
"@sentry/browser": "^6.4.1",
"@sentry/electron": "^2.5.1",
"@tippyjs/react": "^4.2.5",
"chokidar": "^3.5.1",
"chrono-node": "^2.2.4",
Expand All @@ -81,7 +82,7 @@
"ignore": "^5.1.8",
"is-svg": "4.2.2",
"jszip": "^3.5.0",
"mldoc": "0.8.8",
"mldoc": "0.8.9",
"path": "^0.12.7",
"pixi-graph-fork": "^0.1.3",
"posthog-js": "^1.10.2",
Expand Down
4 changes: 0 additions & 4 deletions resources/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,3 @@ html[data-theme='dark'] .keyboard-shortcut > code {
.overflow-y-scroll {
overflow-y: scroll;
}

.whitespace-no-wrap {
white-space: nowrap;
}
15 changes: 8 additions & 7 deletions resources/js/lsplugin.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Logseq",
"version": "0.2.5",
"version": "0.2.6",
"main": "electron.js",
"author": "Logseq",
"description": "A privacy-first, open-source platform for knowledge management and collaboration.",
Expand Down
4 changes: 4 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
:compiler-options {:infer-externs :auto
:output-feature-set :es-next-in
:source-map true
:source-map-include-sources-content true
:source-map-detail-level :all
:externs ["datascript/externs.js"
"externs.js"]
:warnings {:fn-deprecated false}}
Expand All @@ -54,6 +56,8 @@
:compiler-options
{:infer-externs :auto
:source-map true
:source-map-include-sources-content true
:source-map-detail-level :all
:externs ["datascript/externs.js"
"externs.js"]
:warnings {:fn-deprecated false}}}
Expand Down
3 changes: 2 additions & 1 deletion src/main/frontend/commands.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@

[["Query" [[:editor/input "{{query }}" {:backward-pos 2}]] "Create a DataScript query"]
["Zotero" zotero-steps "Import Zotero journal article"]
["Query table function" [[:editor/input "{{function }}" {:backward-pos 2}]] "Create a query table function"]
["Calculator" [[:editor/input "```calc\n\n```" {:backward-pos 4}]
[:codemirror/focus]] "Insert a calculator"]
["Draw" (fn []
Expand Down Expand Up @@ -569,4 +570,4 @@
[pid {:keys [key label block-id] :as cmd} action]
(let [format (and block-id (:block/format (db-util/pull [:block/uuid block-id])))
inputs (vector (conj action (assoc cmd :pid pid)))]
(handle-steps inputs format)))
(handle-steps inputs format)))
Loading

0 comments on commit 65bd4d5

Please sign in to comment.