From 508394152e7580976ec7e8f2ec690870acb34675 Mon Sep 17 00:00:00 2001 From: JimmyLv Date: Wed, 21 Apr 2021 16:20:26 +0800 Subject: [PATCH] feat: add now.sh and create block when no active element --- .gitignore | 3 +++ package.json | 8 ++++---- src/entrys/file.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 958847d..88659e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ .idea/ .cache/ dist/ +public/ *.log node_modules + +.vercel diff --git a/package.json b/package.json index 5f44a9b..27c2f55 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/entrys/file.js b/src/entrys/file.js index c63cb78..4d4e6a2 100644 --- a/src/entrys/file.js +++ b/src/entrys/file.js @@ -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' @@ -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} }}`) }*/