mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
init: the first public commit for AFFiNE
This commit is contained in:
10
libs/datasource/commands/.babelrc
Normal file
10
libs/datasource/commands/.babelrc
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@nrwl/web/babel",
|
||||
{
|
||||
"useBuiltIns": "usage"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
18
libs/datasource/commands/.eslintrc.json
Normal file
18
libs/datasource/commands/.eslintrc.json
Normal 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": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
11
libs/datasource/commands/README.md
Normal file
11
libs/datasource/commands/README.md
Normal 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).
|
||||
15
libs/datasource/commands/jest.config.ts
Normal file
15
libs/datasource/commands/jest.config.ts
Normal 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',
|
||||
};
|
||||
7
libs/datasource/commands/package.json
Normal file
7
libs/datasource/commands/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "@toeverything/datasource/commands",
|
||||
"version": "0.0.1",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
"dependencies": {}
|
||||
}
|
||||
33
libs/datasource/commands/project.json
Normal file
33
libs/datasource/commands/project.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
libs/datasource/commands/src/index.ts
Normal file
1
libs/datasource/commands/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/datasource-commands';
|
||||
48
libs/datasource/commands/src/lib/commands/block-command.ts
Normal file
48
libs/datasource/commands/src/lib/commands/block-command.ts
Normal 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();
|
||||
// }
|
||||
}
|
||||
}
|
||||
2
libs/datasource/commands/src/lib/commands/index.ts
Normal file
2
libs/datasource/commands/src/lib/commands/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './block-command';
|
||||
export * from './text-command';
|
||||
43
libs/datasource/commands/src/lib/commands/text-command.ts
Normal file
43
libs/datasource/commands/src/lib/commands/text-command.ts
Normal 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 }] });
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { EditorCommands } from './datasource-commands';
|
||||
|
||||
describe('datasourceCommands', () => {
|
||||
// it('should work', () => {
|
||||
// expect(EditorCommands()).toEqual('datasource-commands');
|
||||
// });
|
||||
});
|
||||
16
libs/datasource/commands/src/lib/datasource-commands.ts
Normal file
16
libs/datasource/commands/src/lib/datasource-commands.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
23
libs/datasource/commands/tsconfig.json
Normal file
23
libs/datasource/commands/tsconfig.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
10
libs/datasource/commands/tsconfig.lib.json
Normal file
10
libs/datasource/commands/tsconfig.lib.json
Normal 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"]
|
||||
}
|
||||
9
libs/datasource/commands/tsconfig.spec.json
Normal file
9
libs/datasource/commands/tsconfig.spec.json
Normal 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"]
|
||||
}
|
||||
Reference in New Issue
Block a user