mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
init: the first public commit for AFFiNE
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user