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 @@
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);
}
}