Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 committed Jul 30, 2024
1 parent cafa8de commit c5101df
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/docs/src/commands/mutations/docs-rename.mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@
* limitations under the License.
*/

import { CommandType, type ICommand } from '@univerjs/core';
import type { DocumentDataModel, ICommand } from '@univerjs/core';
import { CommandType, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';

export interface IDocsRenameMutationParams {
name: string;
unitId: string;
}

export const DocsRenameMutation: ICommand = {
id: 'doc.mutation.rename-doc',
type: CommandType.MUTATION,
handler: () => {
handler: (accessor, params: IDocsRenameMutationParams) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const doc = univerInstanceService.getUnit<DocumentDataModel>(params.unitId, UniverInstanceType.UNIVER_DOC);
if (!doc) {
return false;
}
doc.setName(params.name);
return true;
},
};

0 comments on commit c5101df

Please sign in to comment.