Skip to content

Commit

Permalink
Merge branch 'master' into mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
llcc authored Nov 22, 2021
2 parents b902081 + e59c2ec commit 6434fa8
Show file tree
Hide file tree
Showing 67 changed files with 857 additions and 10,712 deletions.
14 changes: 12 additions & 2 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{:linters {:unresolved-symbol {:exclude [goog.DEBUG]}}
{:linters {:unresolved-symbol {:exclude [goog.DEBUG
goog.string.unescapeEntities]}}
:hooks {:analyze-call {rum.core/defc hooks.rum/defc
rum.core/defcs hooks.rum/defcs}}
:lint-as {promesa.core/let clojure.core/let
promesa.core/loop clojure.core/loop
garden.def/defstyles clojure.core/def
garden.def/defkeyframes clojure.core/def
rum.core/defcc rum.core/defc
rum.core/with-context clojure.core/doseq
rum.core/defcontext clojure.core/def
clojure.test.check.clojure-test/defspec clojure.core/def
clojure.test.check.properties/for-all clojure.core/for
frontend.modules.outliner.datascript/auto-transact! clojure.core/let}}
nubank.workspaces.core/defcard clojure.core/def
;; src/main
frontend.modules.outliner.datascript/auto-transact! clojure.core/let
frontend.namespaces/import-vars potemkin/import-vars
;; src/test
frontend.react/defc clojure.core/defn}
:skip-comments true}
50 changes: 25 additions & 25 deletions .github/workflows/build-desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
sudo ./linux-install-1.10.1.763.sh
- name: Compile CLJS
run: yarn install && gulp build && yarn cljs:release
run: yarn install && gulp build && yarn cljs:release-electron

- name: Update APP Version
run: |
Expand Down Expand Up @@ -93,12 +93,12 @@ jobs:
with:
node-version: 16

- name: Cache Node Modules
uses: actions/cache@v2
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules

- name: Build/Release Electron App
run: yarn install && yarn electron:make
Expand Down Expand Up @@ -140,12 +140,12 @@ jobs:
with:
node-version: 16

- name: Cache Node Modules
uses: actions/cache@v2
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules

- name: Deps Electron app
run: yarn install
Expand Down Expand Up @@ -200,12 +200,12 @@ jobs:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}

- name: Cache Node Modules
uses: actions/cache@v2
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules

- name: Build/Release Electron App
run: yarn install && yarn electron:make
Expand Down Expand Up @@ -276,12 +276,12 @@ jobs:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATES_P12 }}
p12-password: ${{ secrets.APPLE_CERTIFICATES_P12_PASSWORD }}

- name: Cache Node Modules
uses: actions/cache@v2
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-modules
# - name: Cache Node Modules
# uses: actions/cache@v2
# with:
# path: |
# **/node_modules
# key: ${{ runner.os }}-node-modules

- name: Build/Release Electron App
run: yarn install && yarn electron:make-macos-arm64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Fetch yarn deps
run: yarn cache clean && yarn install

- name: Run Clojure test
- name: Run ClojureScript test
run: |
yarn cljs:test
node static/tests.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ charlie/
docker
android/app/src/main/assets/capacitor.plugin.json
ios/App/App/capacitor.config.json
yarn.lock
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ FROM clojure:openjdk-11-tools-deps-1.10.1.727
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get install -y nodejs

RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
RUN apt-get update && apt-get install ca-certificates && \
wget --no-check-certificate -qO - https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ Run Cypress tests
yarn e2e-test
```

Run Clojure tests. (Note: `.cljc` files may be tested both by ClojureScript, and Clojure.)

```bash
clj -Mtest-clj
```

## Desktop app development

### 1. Compile to JavaScript
Expand Down
18 changes: 10 additions & 8 deletions cypress/integration/app/basic.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
(beforeEach []
(.clearIndexedDB cy))
(before []
(.visit cy "http://localhost:3001"))
(.. cy
(visit "http://localhost:3001")
(get "#main-content-container" #js {:timeout 10000})
(should (fn [result]
(expect result :not.to.contain "Loading")))))

(it "Search" []
(.. cy
(get "#search-button")
(click)
(get "input.cp__palette-input")
(type "welcome to Logseq"))
(.. cy (get "#ui__ac-inner")
(should (fn [result]
Expand All @@ -27,14 +32,11 @@
(.. cy
(get "#search-button")
(click)
(type "new page"))

(.wait cy 1000)

(.. cy
(get "#search-button")
(get "input.cp__palette-input")
(type "new page")
(wait 500)
(type "{enter}"))

;; edit bullet
(util/edit-block "this is my first bullet {enter}")
(util/edit-block "this is my second bullet {enter}")
Expand Down
9 changes: 7 additions & 2 deletions cypress/integration/app/template.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@
(.clearIndexedDB cy)
(cy.wait 1000))
(before []
(.visit cy "http://localhost:3001"))
(.. cy
(visit "http://localhost:3001")
(get "#main-content-container" #js {:timeout 10000})
(should (fn [result]
(expect result :not.to.contain "Loading")))))
(it "template-basic" []
(.. cy
(get "#search-button")
(click)
(get "input.cp__palette-input")
(type "template test page")
(wait 1000)
(type "{enter}"))
(util/edit-block "template")
(.. cy
(realPress #js ["Shift" "Enter"]))
(util/edit-block "template:: template-name{enter}")
(util/edit-block "template:: template-name{enter}{enter}")
(util/tab)
(util/edit-block "line1{enter}")
(util/edit-block "line2{enter}")
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/app/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(defn back-to-home
[]
(.. cy (get ".cp__header-logo")
(.. cy (get ".ui__modal")
(first)
(click)))

Expand Down
10 changes: 3 additions & 7 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
org.clojars.knubie/cljs-run-test {:mvn/version "1.0.1"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}

:test-clj
{:extra-paths ["src/test/"]
:extra-deps
{com.cognitect/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner",
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
:main-opts ["-m" "cognitect.test-runner" "-d" "src/test"]}}}
:clj-kondo
{:extra-deps {clj-kondo/clj-kondo {:mvn/version "2021.10.19"}}
:main-opts ["-m" "clj-kondo.main"]}}}
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports.electron = () => {
}

exports.electronMaker = async () => {
cp.execSync('yarn cljs:release', {
cp.execSync('yarn cljs:release-electron', {
stdio: 'inherit'
})

Expand Down
12 changes: 10 additions & 2 deletions libs/src/LSPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export type SimpleCommandCallback = (e: IHookEvent) => void
export type BlockCommandCallback = (e: IHookEvent & { uuid: BlockUUID }) => Promise<void>
export type BlockCursorPosition = { left: number, top: number, height: number, pos: number, rect: DOMRect }

export type SimpleCommandKeybinding = {
mode?: 'global' | 'non-editing' | 'editing',
binding: string,
mac?: string // special for Mac OS
}

/**
* App level APIs
*/
Expand All @@ -194,14 +200,16 @@ export interface IAppProxy {
key: string,
label: string,
desc?: string,
palette?: boolean
palette?: boolean,
keybinding?: SimpleCommandKeybinding
},
action: SimpleCommandCallback) => void

registerCommandPalette: (
opts: {
key: string,
label: string,
keybinding?: SimpleCommandKeybinding
},
action: SimpleCommandCallback) => void

Expand Down Expand Up @@ -346,7 +354,7 @@ export interface IEditorProxy extends Record<string, any> {
insertBlock: (
srcBlock: BlockIdentity,
content: string,
opts?: Partial<{ before: boolean; sibling: boolean; properties: {} }>
opts?: Partial<{ before: boolean; sibling: boolean; isPageBlock: boolean; properties: {} }>
) => Promise<BlockEntity | null>

insertBatchBlock: (
Expand Down
15 changes: 8 additions & 7 deletions libs/src/LSPlugin.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ThemeOptions,
UIOptions, IHookEvent, BlockIdentity,
BlockPageName,
UIContainerAttrs, SimpleCommandCallback
UIContainerAttrs, SimpleCommandCallback, SimpleCommandKeybinding
} from './LSPlugin'
import Debug from 'debug'
import * as CSS from 'csstype'
Expand Down Expand Up @@ -41,38 +41,39 @@ function registerSimpleCommand (
key: string,
label: string,
desc?: string,
palette?: boolean
palette?: boolean,
keybinding?: SimpleCommandKeybinding
},
action: SimpleCommandCallback
) {
if (typeof action !== 'function') {
return false
}

const { key, label, desc, palette } = opts
const { key, label, desc, palette, keybinding } = opts
const eventKey = `SimpleCommandHook${key}${++registeredCmdUid}`

this.Editor['on' + eventKey](action)

this.caller?.call(`api:call`, {
method: 'register-plugin-simple-command',
args: [this.baseInfo.id, [{ key, label, type, desc }, ['editor/hook', eventKey]], palette]
args: [this.baseInfo.id, [{ key, label, type, desc, keybinding }, ['editor/hook', eventKey]], palette]
})
}

const app: Partial<IAppProxy> = {
registerCommand: registerSimpleCommand,

registerCommandPalette (
opts: { key: string; label: string },
opts: { key: string; label: string, keybinding?: SimpleCommandKeybinding },
action: SimpleCommandCallback) {

const { key, label } = opts
const { key, label, keybinding } = opts
const group = 'global-palette-command'

return registerSimpleCommand.call(
this, group,
{ key, label, palette: true },
{ key, label, palette: true, keybinding },
action)
},

Expand Down
Loading

0 comments on commit 6434fa8

Please sign in to comment.