@univerjs/sheets-thread-comment-ui
TypeScript icon, indicating that this package has built-in type declarations

0.8.1 • Public • Published

@univerjs/sheets-thread-comment-ui

Package Overview

Package Name UMD Namespace Version License Downloads Contains CSS Contains i18n locales
@univerjs/sheets-thread-comment-ui UniverSheetsThreadComment ⭕️ ⭕️

Introduction

@univerjs/sheets-thread-comment-ui provides the comment/annotation function of Univer Sheets.

Usage

Installation

# Use npm
npm install @univerjs/sheets-thread-comment-ui

# Use pnpm
pnpm add @univerjs/sheets-thread-comment-ui

Register the plugin

import { UniverSheetsThreadCommentPlugin, IThreadCommentMentionDataService} from '@univerjs/sheets-thread-comment-ui';

const mockUser = {
    userID: 'mockId',
    name: 'MockUser',
    avatar: 'icon-url',
    anonymous: false,
    canBindAnonymous: false,
};

class CustomMentionDataService implements IThreadCommentMentionDataService {
    trigger: string = '@';

     // Get the common interface implementation of the mentioned user
    async getMentions(search: string) {
        return [
            {
                id: mockUser.userID,
                label: mockUser.name,
                type: 'user',
                icon: mockUser.avatar,
            },
            {
                id: '2',
                label: 'User2',
                type: 'user',
                icon: mockUser.avatar,
            },
        ];
    }
}

univer.registerPlugin(UniverSheetsThreadCommentPlugin);

API

import {
    AddCommentCommand,
    DeleteCommentCommand,
    UpdateCommentCommand,
    ResolveCommentCommand,
    DeleteCommentTreeCommand,
} from '@univerjs/sheets-thread-comment-ui';
import type {
    IAddCommentCommandParams,
    IDeleteCommentCommandParams,
    IResolveCommentCommandParams,
    IUpdateCommentCommandParams,
    IDeleteCommentTreeCommandParams,
} from '@univerjs/sheets-thread-comment-ui';

// Add comment by command
const commandService = univer.__getInjector().get(ICommandService);

commandService.executeCommand(AddCommentCommand.id, {
    unitId: 'unitId',
    subUnitId: 'subUnitId',
    comment: {
        // comment content
    },
} as IAddCommentCommandParams);

Readme

Keywords

none

Package Sidebar

Install

npm i @univerjs/sheets-thread-comment-ui

Homepage

univer.ai

Weekly Downloads

2,870

Version

0.8.1

License

Apache-2.0

Unpacked Size

159 kB

Total Files

60

Last publish

Collaborators

  • wendellhu95
  • jikkai
  • wbfsa
  • yuhongz
  • mengshukeji