Skip to content

Commit

Permalink
feat(sheet): support fork file (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound authored Sep 24, 2024
1 parent f535bd3 commit 6a475a7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export { DependentOn, PluginService } from './services/plugin/plugin.service';
export { type DependencyOverride, mergeOverrideWithDependencies } from './services/plugin/plugin-override';
export { IResourceLoaderService } from './services/resource-loader/type';
export { ResourceManagerService } from './services/resource-manager/resource-manager.service';
export type { IResourceHook } from './services/resource-manager/type';
export type { IResourceHook, IResources } from './services/resource-manager/type';
export { IResourceManagerService } from './services/resource-manager/type';
export { type IStyleSheet, ThemeService } from './services/theme/theme.service';

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/services/resource-manager/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export interface IResourceHook<T = any> {
businesses: UniverInstanceType[];
onLoad: (unitID: string, resource: T) => void;
onUnLoad: (unitID: string) => void;
toJson: (unitID: string) => string;
toJson: (unitID: string, model?: T) => string;

parseJson: (bytes: string) => T;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class SheetsDrawingLoadController extends Disposable {
}

private _initSnapshot() {
const toJson = (unitId: string) => {
const map = this._sheetDrawingService.getDrawingDataForUnit(unitId);
const toJson = (unitId: string, model?: IDrawingSubunitMap<ISheetDrawing>) => {
const map = model || this._sheetDrawingService.getDrawingDataForUnit(unitId);
if (map) {
return JSON.stringify(map);
}
Expand All @@ -58,7 +58,7 @@ export class SheetsDrawingLoadController extends Disposable {
this._resourceManagerService.registerPluginResource<IDrawingSubunitMap<ISheetDrawing>>({
pluginName: SHEET_DRAWING_PLUGIN,
businesses: [UniverInstanceType.UNIVER_SHEET],
toJson: (unitId) => toJson(unitId),
toJson: (unitId, model) => toJson(unitId, model),
parseJson: (json) => parseJson(json),
onUnLoad: (unitId) => {
this._sheetDrawingService.removeDrawingDataForUnit(unitId);
Expand Down
2 changes: 2 additions & 0 deletions packages/sheets-drawing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/

/* eslint-disable perfectionist/sort-exports */
export { UniverSheetsDrawingPlugin } from './plugin';
export { ISheetDrawingService, SheetDrawingAnchorType } from './services/sheet-drawing.service';
export { SHEET_DRAWING_PLUGIN } from './controllers/sheet-drawing.controller';
export type { IFloatDomData, ISheetDrawing, ISheetDrawingPosition, ISheetFloatDom } from './services/sheet-drawing.service';

// #region - all commands
Expand Down

0 comments on commit 6a475a7

Please sign in to comment.