init: the first public commit for AFFiNE

This commit is contained in:
DarkSky
2022-07-22 15:49:21 +08:00
commit e3e3741393
1451 changed files with 108124 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
{
"presets": [
[
"@nrwl/web/babel",
{
"useBuiltIns": "usage"
}
]
]
}

View File

@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@@ -0,0 +1,11 @@
# datasource-commands
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build datasource-commands` to build the library.
## Running unit tests
Run `nx test datasource-commands` to execute the unit tests via [Jest](https://jestjs.io).

View File

@@ -0,0 +1,15 @@
/* eslint-disable */
export default {
displayName: 'datasource-commands',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/datasource/commands',
};

View File

@@ -0,0 +1,7 @@
{
"name": "@toeverything/datasource/commands",
"version": "0.0.1",
"license": "MIT",
"type": "commonjs",
"dependencies": {}
}

View File

@@ -0,0 +1,33 @@
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/datasource/commands/src",
"projectType": "library",
"tags": ["datasource:commands"],
"targets": {
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/datasource/commands",
"main": "libs/datasource/commands/src/index.ts",
"tsConfig": "libs/datasource/commands/tsconfig.lib.json",
"assets": ["libs/datasource/commands/*.md"]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/datasource/commands/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/datasource/commands"],
"options": {
"jestConfig": "libs/datasource/commands/jest.config.ts",
"passWithNoTests": true
}
}
}
}

View File

@@ -0,0 +1 @@
export * from './lib/datasource-commands';

View File

@@ -0,0 +1,48 @@
import { BlockFlavors } from '@toeverything/datasource/db-service';
/**
*
* commands for control blocks
* @export
* @class BlockCommands
*/
export class BlockCommands {
private _workspace: string;
constructor(workspace: string) {
this._workspace = workspace;
}
/**
*
* create a block after typed id
* @param {keyof BlockFlavors} type
* @param {string} blockId
* @return {*}
* @memberof BlockCommands
*/
public async createNextBlock(
type: keyof BlockFlavors = 'text',
blockId: string
) {
// const block = await this._editor.getBlockById(blockId);
// if (block) {
// const next_block = await this._editor.createBlock(type);
// await block.after(next_block);
// this._editor.selectionManager.activeNodeByNodeId(next_block.id);
// return next_block;
// }
// return undefined;
}
/**
*
* remove block by block id
* @param {string} blockId
* @memberof BlockCommands
*/
public async removeBlock(blockId: string) {
// const block = await this._editor.getBlockById(blockId);
// if (block) {
// block.remove();
// }
}
}

View File

@@ -0,0 +1,2 @@
export * from './block-command';
export * from './text-command';

View File

@@ -0,0 +1,43 @@
/**
*
* commands for control text and text styles
* @export
* @class TextCommand
*/
export class TextCommands {
private _workspace: string;
constructor(workspace: string) {
this._workspace = workspace;
}
/**
*
* get block text by block id
* @param {string} blockId
* @return {*}
* @memberof TextCommand
*/
public async getBlockText(blockId: string) {
// let string = '';
// const block = await this._editor.getBlockById(blockId);
// if (block) {
// string = block.getProperty('text')?.value[0]?.text || '';
// }
// return string;
}
/**
*
* set block text by block id
* @param {string} blockId
* @param {string} text
* @memberof TextCommand
*/
public async setBlockText(blockId: string, text: string) {
// const block = await this._editor.getBlockById(blockId);
// if (block) {
// block.setProperty('text', { value: [{ text: text }] });
// }
}
}

View File

@@ -0,0 +1,7 @@
import { EditorCommands } from './datasource-commands';
describe('datasourceCommands', () => {
// it('should work', () => {
// expect(EditorCommands()).toEqual('datasource-commands');
// });
});

View File

@@ -0,0 +1,16 @@
import { BlockCommands, TextCommands } from './commands';
/**
*
* commands for operate servers
* @export
* @class Commands
*/
export class Commands {
public blockCommands: BlockCommands;
public textCommands: TextCommands;
constructor(workspace: string) {
this.blockCommands = new BlockCommands(workspace);
this.textCommands = new TextCommands(workspace);
}
}

View File

@@ -0,0 +1,23 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"strictNullChecks": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": []
},
"include": ["**/*.ts"],
"exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"]
}

View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}