Skip to content

Commit

Permalink
feat: add now.sh and create block when no active element
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Apr 21, 2021
1 parent e5fd41b commit 5083941
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.idea/
.cache/
dist/
public/
*.log
node_modules

.vercel
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"main": "index.js",
"scripts": {
"dev": "parcel src/index.js --port 8080",
"build:styled": "parcel build src/index.js --out-dir dist/js",
"build:styled": "parcel build src/index.js --out-dir public/js",
"dev:file": "parcel src/entrys/file.js --port 8080",
"build:file": "parcel build src/entrys/file.js --out-dir dist",
"prebuild": "rm -rf dist",
"build:file": "parcel build src/entrys/file.js --out-dir public",
"prebuild": "rm -rf public",
"build": "npm run build:styled && npm run build:file",
"deploy": "gh-pages -d dist"
"deploy": "gh-pages -d public"
},
"husky": {
"hooks": {
Expand Down
11 changes: 9 additions & 2 deletions src/entrys/file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Uppy from '@uppy/core'
import Dashboard from '@uppy/dashboard'
import XHRUpload from '@uppy/xhr-upload'
import { updateActiveBlock } from 'roam-client'
import { createBlock, updateActiveBlock } from 'roam-client'
import { ProgressBar } from 'uppy'
import 'uppy/dist/uppy.min.css'
import { appendCSSToPageByEnv, appendIcon } from '../utils/dom-helper'
Expand Down Expand Up @@ -102,7 +102,14 @@ var uppy = new Uppy({
console.log('successful[0] result response', response)

// if (response.uploadURL.endsWith('png')) {
updateActiveBlock(`![](${response.uploadURL})`)
const mdLink = `![](${response.uploadURL})`
if (document.activeElement.type === 'textarea') {
updateActiveBlock(mdLink)
} else {
// 'https://roamresearch.com/#/app/Note-Tasking/page/1OLUyHxAM'
const uid = location.href.substring(location.href.length - 9)
createBlock({ node: { text: mdLink }, parentUid: uid })
}
/*} else {
updateActiveBlock(`{{iframe: ${response.uploadURL} }}`)
}*/
Expand Down

0 comments on commit 5083941

Please sign in to comment.