Skip to content

Commit

Permalink
move tldraw/next inside of logseq
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed May 16, 2022
1 parent a62d6e7 commit e02a7dd
Show file tree
Hide file tree
Showing 434 changed files with 34,554 additions and 38,456 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"cljs:debug": "clojure -M:cljs release app --debug",
"cljs:report": "clojure -M:cljs run shadow.cljs.build-report app report.html",
"cljs:build-electron": "clojure -A:cljs compile app electron",
"cljs:lint": "clojure -M:clj-kondo --parallel --lint src"
"cljs:lint": "clojure -M:clj-kondo --parallel --lint src",
"tldraw:build": "cd tldraw && yarn build"
},
"dependencies": {
"@capacitor/android": "3.2.2",
Expand Down
2 changes: 1 addition & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:dev-http {3001 ["static" "."]
3002 ["public/workspaces" "."]}

:js-options {:js-package-dirs ["node_modules" "tldraw"]}
:js-options {:js-package-dirs ["node_modules" "tldraw/apps"]}

:builds
{:app {:target :browser
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
wide-mode? (state/sub :ui/wide-mode?)
right-sidebar-blocks (state/sub-right-sidebar-blocks)
route-name (get-in route-match [:data :name])
margin-less-pages? (#{:graph :whiteboard} route-name)
margin-less-pages? (boolean (#{:graph :whiteboard} route-name))
db-restoring? (state/sub :db/restoring?)
indexeddb-support? (state/sub :indexeddb/support?)
page? (= :page route-name)
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/extensions/tldraw.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{:style {:overscroll-behavior "none"}}
[:div.draw-wrap.relative
{:on-blur #(state/set-block-component-editing-mode! false)
:style {:height "calc(100vh - 120px)" }}
:style {:height "calc(100vh - 80px)" }}

(tldraw {:PageComponent page
:searchHandler (comp clj->js vec search/page-search)
Expand Down
3 changes: 3 additions & 0 deletions tldraw/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules/*
**/out/*
**/.next/*
16 changes: 16 additions & 0 deletions tldraw/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"ignorePatterns": ["*.js"],
"overrides": [
{
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": [0]
}
}
]
}
2 changes: 2 additions & 0 deletions tldraw/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
17 changes: 17 additions & 0 deletions tldraw/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules/
build/
dist/
docs/
.idea/*

.DS_Store
coverage
*.log

.vercel
.next
apps/www/public/workbox-*
apps/www/public/worker-*
apps/www/public/sw.js
apps/www/public/sw.js.map
.env
17 changes: 17 additions & 0 deletions tldraw/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.github/
/.vscode/
/node_modules/
/build/
/tmp/
.idea/*
/docs/

coverage
*.log
.gitlab-ci.yml

package-lock.json
/*.tgz
/tmp*
/mnt/
/package/
11 changes: 11 additions & 0 deletions tldraw/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "es5",
"singleQuote": true,
"semi": false,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"jsxSingleQuote": false,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
}
21 changes: 21 additions & 0 deletions tldraw/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Stephen Ruiz Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "dist/index.mjs",
"scripts": {
"build": "zx build.mjs",
"build:packages": "yarn build",
"dev": "tsup --watch",
"dev:vite": "tsup --watch --sourcemap inline"
},
Expand All @@ -17,11 +18,13 @@
"@types/node": "^14.14.35",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"autoprefixer": "^10.4.7",
"concurrently": "^7.0.0",
"esbuild": "^0.13.8",
"mobx": "^6.3.7",
"mobx-react-lite": "^3.2.2",
"perfect-freehand": "^1.0.16",
"postcss": "^8.4.13",
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"react-select": "^5.3.2",
Expand Down
3 changes: 3 additions & 0 deletions tldraw/apps/tldraw-logseq/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = ctx => ({
plugins: [require('autoprefixer')()],
})
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@radix-ui/react-icons'
import { observer } from 'mobx-react-lite'
import { Button } from '~components/Button'
import { EraserIcon, LineIcon } from '~components/icons'
import { EraserIcon, LineIcon, LogseqIcon } from '~components/icons'

export const PrimaryTools = observer(function PrimaryTools() {
const app = useApp()
Expand All @@ -40,7 +40,6 @@ export const PrimaryTools = observer(function PrimaryTools() {

return (
<div className="primary-tools">
<button className="floating-button"></button>
<div className="panel floating-panel" data-tool-locked={app.settings.isToolLocked}>
<Button
data-tool="select"
Expand Down Expand Up @@ -136,10 +135,9 @@ export const PrimaryTools = observer(function PrimaryTools() {
onClick={handleToolClick}
onDoubleClick={handleToolDoubleClick}
>
🥹
<LogseqIcon />
</Button>
</div>
<button className="floating-button"></button>
</div>
)
})
14 changes: 14 additions & 0 deletions tldraw/apps/tldraw-logseq/src/components/icons/LogseqIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as React from 'react'

// @ts-expect-error don't bother fix it ...
import iconBase64 from './logseq-icon.png'

export function LogseqIcon() {
return (
<img
style={{ borderRadius: '50%', width: '20px', height: '20px' }}
src={'data:image/png;base64,' + iconBase64}
alt="logseq"
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './EraserIcon'
export * from './MultiplayerIcon'
export * from './DiscordIcon'
export * from './LineIcon'
export * from './LogseqIcon'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
type="text"
value={q}
onChange={handleChange}
onKeyDown={e => {
if (e.key === 'Enter') {
commitChange(q)
}
}}
list="logseq-portal-search-results"
/>
<datalist id="logseq-portal-search-results">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export default defineConfig({
platform: 'browser',
format: ['cjs', 'esm'],
entry: ['src/index.ts'],
clean: true
clean: true,
loader: {
'.png': 'base64',
},
})

Binary file added tldraw/assets/recording.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tldraw/assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tldraw/assets/sentry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tldraw/assets/tldraw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions tldraw/assets/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tldraw/cljs-demo/.clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{: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
promesa.core/recur clojure.core/recur
rum.core/defcc rum.core/defc
rum.core/defcontext clojure.core/def
clojure.test.check.clojure-test/defspec clojure.core/def
clojure.test.check.properties/for-all clojure.core/for}
:skip-comments true}
68 changes: 68 additions & 0 deletions tldraw/cljs-demo/.clj-kondo/hooks/rum.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(ns hooks.rum
(:require [clj-kondo.hooks-api :as api]))

(defn fn-body? [x]
(and (seq? x)
(vector? (first x))))

(defn rewrite-body [mixins body defcs?]
(if defcs?
(let [[binding-vec & body] (:children body)
[state-arg & rest-args] (:children binding-vec)
;; the original vector without the state argument
fn-args (assoc binding-vec :children rest-args)
body (api/list-node
(list* (api/token-node 'let*)
(api/vector-node [state-arg (api/token-node nil)])
state-arg
(concat mixins body)))
body (api/list-node [fn-args body])]
body)
(let [[binding-vec & body] (:children body)]
(api/list-node (cons binding-vec (concat mixins body))))))

(defn rewrite
([node] (rewrite node false))
([node defcs?]
(let [args (rest (:children node))
component-name (first args)
?docstring (when (string? (api/sexpr (second args)))
(second args))
args (if ?docstring
(nnext args)
(next args))
bodies
(loop [args* (seq args)
mixins []
bodies []]
(if args*
(let [a (first args*)
a-sexpr (api/sexpr a)]
(cond (vector? a-sexpr) ;; a-sexpr is a binding vec and the rest is the body of the function
[(rewrite-body mixins (api/list-node args*) defcs?)]
(fn-body? a-sexpr)
(recur (next args*)
mixins
(conj bodies (rewrite-body mixins a defcs?)))
;; assume mixin
:else (recur (next args*)
(conj mixins a)
bodies)))
bodies))
new-node (with-meta
(api/list-node
(list* (api/token-node 'defn)
component-name
(if ?docstring
(cons ?docstring bodies)
bodies)))
(meta node))]
new-node)))

(defn defc [{:keys [:node]}]
(let [new-node (rewrite node)]
{:node new-node}))

(defn defcs [{:keys [:node]}]
(let [new-node (rewrite node true)]
{:node new-node}))
27 changes: 27 additions & 0 deletions tldraw/cljs-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
node_modules/
public/js

/target
/checkouts
/src/gen

dist

pom.xml
pom.xml.asc
*.iml
*.jar
*.log
.shadow-cljs
.idea
.lein-*
.nrepl-*
.DS_Store

.hgignore
.hg/

.clj-kondo/.cache
.lsp
.calva
.cpcache
14 changes: 14 additions & 0 deletions tldraw/cljs-demo/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{:paths ["src/main" "src/gen"]

:deps
{rum/rum {:mvn/version "0.12.9"}
org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cljs-bean/cljs-bean {:mvn/version "1.8.0"}}

:aliases
{:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.18.0"}
binaryage/devtools {:mvn/version "1.0.6"}
cider/cider-nrepl {:mvn/version "0.28.3"}}}}}
17 changes: 17 additions & 0 deletions tldraw/cljs-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.0.0-dev",
"name": "tldraw-logseq-demo",
"license": "MIT",
"scripts": {
"dev": "shadow-cljs watch frontend"
},
"devDependencies": {
"node-libs-browser": "^2.2.1",
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"shadow-cljs": "^2.18.0"
},
"dependencies": {
"tldraw-logseq": "*"
}
}
Loading

0 comments on commit e02a7dd

Please sign in to comment.