mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
extension file structure and routing
This commit is contained in:
parent
78126c41e4
commit
2612255b47
28 changed files with 138 additions and 20 deletions
BIN
dist/extension/img/icon128x128.png
vendored
Normal file
BIN
dist/extension/img/icon128x128.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
dist/extension/img/icon16x16.png
vendored
Normal file
BIN
dist/extension/img/icon16x16.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 452 B |
3
dist/extension/js/background.js
vendored
Normal file
3
dist/extension/js/background.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
const a = 1;
|
||||
|
||||
console.log('This is worker script');
|
1
dist/extension/js/foreground.js
vendored
Normal file
1
dist/extension/js/foreground.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
const a = 1;
|
25
dist/extension/manifest.json
vendored
25
dist/extension/manifest.json
vendored
|
@ -1,5 +1,28 @@
|
|||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Anytype",
|
||||
"version": "0.0.1"
|
||||
"description": "Anytype is a next generation software that breaks down barriers between applications, gives back privacy and data ownership to users.",
|
||||
"version": "0.0.1",
|
||||
"icons": {
|
||||
"16": "img/icon16x16.png",
|
||||
"128": "img/icon128x128.png"
|
||||
},
|
||||
"options_page": "settings/index.html",
|
||||
"action": {
|
||||
"default_title": "Chrome Addon v3 Starter",
|
||||
"default_popup": "popup/index.html"
|
||||
},
|
||||
"permissions": [],
|
||||
"host_permissions": [
|
||||
"*://*/*"
|
||||
],
|
||||
"background": {
|
||||
"service_worker": "js/background.js"
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"js": [ "js/foreground.js" ],
|
||||
"matches": [ "<all_urls>" ]
|
||||
}
|
||||
]
|
||||
}
|
11
dist/extension/popup/index.html
vendored
Normal file
11
dist/extension/popup/index.html
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./popup.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="anytypeWebclipperRoot"></div>
|
||||
<script type="text/javascript" src="./popup.js"></script>
|
||||
<script type="text/javascript" src="../js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
1
dist/extension/popup/popup.css
vendored
Normal file
1
dist/extension/popup/popup.css
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
body { width: 400px; height: 800px; }
|
6
dist/extension/popup/popup.js
vendored
Normal file
6
dist/extension/popup/popup.js
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
(() => {
|
||||
|
||||
window.Electron = {
|
||||
};
|
||||
|
||||
})();
|
7
dist/extension/settings/index.html
vendored
Normal file
7
dist/extension/settings/index.html
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -1,16 +1,56 @@
|
|||
import * as React from 'react';
|
||||
import * as hs from 'history';
|
||||
import { Router, Route, Switch } from 'react-router-dom';
|
||||
import { Provider } from 'mobx-react';
|
||||
import { configure } from 'mobx';
|
||||
import { commonStore, authStore, blockStore, detailStore, dbStore, menuStore, popupStore } from 'Store';
|
||||
|
||||
import Index from './page/index';
|
||||
|
||||
configure({ enforceActions: 'never' });
|
||||
|
||||
const Routes = [
|
||||
{ 'path': '/' },
|
||||
];
|
||||
|
||||
const Components = {
|
||||
'/': Index,
|
||||
};
|
||||
|
||||
const memoryHistory = hs.createMemoryHistory;
|
||||
const history = memoryHistory();
|
||||
|
||||
const rootStore = {
|
||||
commonStore,
|
||||
authStore,
|
||||
blockStore,
|
||||
detailStore,
|
||||
dbStore,
|
||||
menuStore,
|
||||
popupStore,
|
||||
};
|
||||
|
||||
class App extends React.Component {
|
||||
|
||||
node: any = null;
|
||||
|
||||
constructor (props: any) {
|
||||
super(props);
|
||||
};
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<Router history={history}>
|
||||
<Provider {...rootStore}>
|
||||
<div ref={node => this.node = node}>
|
||||
<Switch>
|
||||
{Routes.map((item: any, i: number) => (
|
||||
<Route path={item.path} exact={true} key={i} component={Components[item.path]} />
|
||||
))}
|
||||
</Switch>
|
||||
</div>
|
||||
</Provider>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ import * as React from 'react';
|
|||
import * as ReactDOM from 'react-dom';
|
||||
import App from './app';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
ReactDOM.render(<App />, document.getElementById('anytypeWebclipperRoot'));
|
18
extension/page/index.tsx
Normal file
18
extension/page/index.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
import { RouteComponentProps } from 'react-router';
|
||||
import Constant from 'json/constant.json';
|
||||
|
||||
class Index extends React.Component<RouteComponentProps> {
|
||||
|
||||
render () {
|
||||
const prefix = Constant.extension.clipper.prefix;
|
||||
|
||||
return (
|
||||
<div className={`${prefix}-page ${prefix}-pageIndex`}>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
export default Index;
|
|
@ -15,6 +15,7 @@
|
|||
"start:dev": "npm-run-all --parallel start:watch start:electron-wait-webpack",
|
||||
"start:dev-win": "npm-run-all --parallel start:watch start:electron-wait-webpack-win",
|
||||
"build": "webpack --mode=production --node-env=production --config webpack.config.js",
|
||||
"build:dev": "webpack --mode=development --node-env=development --config webpack.config.js",
|
||||
"build:deps": "webpack --config webpack.node.config.js --stats detailed | grep 'node_modules' | sed -E 's/.*(node_modules[\\/][^\\\\/[:space:]]{1,})[\\\\/].*/\\1/' | uniq | node save-node-deps.js",
|
||||
"build:nmh": "go build -o dist/nativeMessagingHost ./go/nativeMessagingHost.go",
|
||||
"build:nmh-win": "go build -o dist/nativeMessagingHost.exe ./gonativeMessagingHost.go",
|
||||
|
|
|
@ -6,6 +6,13 @@
|
|||
"protocol": "anytype",
|
||||
"appName": "Anytype",
|
||||
|
||||
"extension": {
|
||||
"clipper": {
|
||||
"id": "jkmhmgghdjjbafmkgjmplhemjjnkligf",
|
||||
"prefix": "anytypeWebclipper"
|
||||
}
|
||||
},
|
||||
|
||||
"platforms": {
|
||||
"win32": "Windows",
|
||||
"darwin": "Mac",
|
||||
|
@ -35,7 +42,7 @@
|
|||
"route": 250
|
||||
},
|
||||
|
||||
"extension": {
|
||||
"fileExtension": {
|
||||
"image": [ "jpg", "jpeg", "png", "gif", "svg", "webp" ],
|
||||
"video": [ "mp4", "m4v", "mov" ],
|
||||
"cover": [ "jpg", "jpeg", "png" ],
|
||||
|
|
|
@ -217,7 +217,7 @@ const BlockCover = observer(class BlockCover extends React.Component<I.BlockComp
|
|||
onIconUser () {
|
||||
const { rootId } = this.props;
|
||||
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
C.FileUpload('', paths[0], I.FileType.Image, (message: any) => {
|
||||
if (!message.error.code) {
|
||||
UtilObject.setIcon(rootId, '', message.hash);
|
||||
|
|
|
@ -75,7 +75,7 @@ const BlockIconUser = observer(class BlockIconUser extends React.Component<I.Blo
|
|||
onUpload () {
|
||||
const { rootId } = this.props;
|
||||
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
this.setState({ loading: true });
|
||||
|
||||
C.FileUpload('', paths[0], I.FileType.Image, (message: any) => {
|
||||
|
|
|
@ -42,7 +42,7 @@ const BlockAudio = observer(class BlockAudio extends React.Component<I.BlockComp
|
|||
block={block}
|
||||
icon="audio"
|
||||
textFile={translate('blockAudioUpload')}
|
||||
accept={Constant.extension.audio}
|
||||
accept={Constant.fileExtension.audio}
|
||||
onChangeUrl={this.onChangeUrl}
|
||||
onChangeFile={this.onChangeFile}
|
||||
readonly={readonly}
|
||||
|
|
|
@ -50,7 +50,7 @@ const BlockImage = observer(class BlockImage extends React.Component<I.BlockComp
|
|||
block={block}
|
||||
icon="image"
|
||||
textFile={translate('blockImageUpload')}
|
||||
accept={Constant.extension.image}
|
||||
accept={Constant.fileExtension.image}
|
||||
onChangeUrl={this.onChangeUrl}
|
||||
onChangeFile={this.onChangeFile}
|
||||
readonly={readonly}
|
||||
|
|
|
@ -75,7 +75,7 @@ const BlockPdf = observer(class BlockPdf extends React.Component<I.BlockComponen
|
|||
block={block}
|
||||
icon="pdf"
|
||||
textFile={translate('blockPdfUpload')}
|
||||
accept={Constant.extension.pdf}
|
||||
accept={Constant.fileExtension.pdf}
|
||||
onChangeUrl={this.onChangeUrl}
|
||||
onChangeFile={this.onChangeFile}
|
||||
readonly={readonly}
|
||||
|
|
|
@ -54,7 +54,7 @@ const BlockVideo = observer(class BlockVideo extends React.Component<I.BlockComp
|
|||
block={block}
|
||||
icon="video"
|
||||
textFile={translate('blockVideoUpload')}
|
||||
accept={Constant.extension.video}
|
||||
accept={Constant.fileExtension.video}
|
||||
onChangeUrl={this.onChangeUrl}
|
||||
onChangeFile={this.onChangeFile}
|
||||
readonly={readonly}
|
||||
|
|
|
@ -268,7 +268,7 @@ const MenuBlockCover = observer(class MenuBlockCover extends React.Component<I.M
|
|||
const { data } = param;
|
||||
const { onUpload, onUploadStart } = data;
|
||||
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
close();
|
||||
|
||||
if (onUploadStart) {
|
||||
|
|
|
@ -534,7 +534,7 @@ class MenuSmile extends React.Component<I.Menu, State> {
|
|||
|
||||
close();
|
||||
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
C.FileUpload('', paths[0], I.FileType.Image, (message: any) => {
|
||||
if (!message.error.code && onUpload) {
|
||||
onUpload(message.hash);
|
||||
|
|
|
@ -135,7 +135,7 @@ const Controls = observer(class Controls extends React.Component<Props, State> {
|
|||
onIconUser () {
|
||||
const { rootId } = this.props;
|
||||
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
C.FileUpload('', paths[0], I.FileType.Image, (message: any) => {
|
||||
if (message.hash) {
|
||||
UtilObject.setIcon(rootId, '', message.hash);
|
||||
|
|
|
@ -166,7 +166,7 @@ const PopupSettingsPageAccount = observer(class PopupSettingsPageAccount extends
|
|||
};
|
||||
|
||||
onUpload () {
|
||||
Action.openFile(Constant.extension.cover, paths => {
|
||||
Action.openFile(Constant.fileExtension.cover, paths => {
|
||||
this.setState({ loading: true });
|
||||
|
||||
C.FileUpload('', paths[0], I.FileType.Image, (message: any) => {
|
||||
|
|
|
@ -98,8 +98,8 @@ class UtilFile {
|
|||
icon = 'presentation';
|
||||
};
|
||||
|
||||
for (const k in Constant.extension) {
|
||||
if (Constant.extension[k].indexOf(e) >= 0) {
|
||||
for (const k in Constant.fileExtension) {
|
||||
if (Constant.fileExtension[k].indexOf(e) >= 0) {
|
||||
icon = k;
|
||||
break;
|
||||
};
|
||||
|
|
|
@ -64,6 +64,6 @@
|
|||
"exclude": [
|
||||
"node_modules/**/*",
|
||||
"dist/**/*",
|
||||
"extensions/**/*"
|
||||
"extension/**/*"
|
||||
]
|
||||
}
|
|
@ -23,7 +23,7 @@ module.exports = (env, argv) => {
|
|||
},
|
||||
extension: {
|
||||
import: './extension/entry.tsx',
|
||||
filename: 'extension/main.js',
|
||||
filename: 'extension/js/main.js',
|
||||
},
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue