Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(watermark): fix invalid plugin configuration #4389

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions packages/watermark/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,32 @@ export class UniverWatermarkPlugin extends Plugin {
}

private async _initWatermarkStorage() {
const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings } = this._config;
const config = this._configService.getConfig<IUniverWatermarkConfig>(WATERMARK_PLUGIN_CONFIG_KEY);
if (!config) {
return;
}
const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings } = config;
if (userWatermarkSettings) {
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.UserInfo, config: { userInfo: { ...WatermarkUserInfoBaseConfig, userWatermarkSettings } } });
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
type: IWatermarkTypeEnum.UserInfo,
config: {
userInfo: merge({}, WatermarkUserInfoBaseConfig, userWatermarkSettings),
},
});
} else if (textWatermarkSettings) {
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Text, config: { text: { ...WatermarkTextBaseConfig, textWatermarkSettings } } });
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
type: IWatermarkTypeEnum.Text,
config: {
text: merge({}, WatermarkTextBaseConfig, textWatermarkSettings),
},
});
} else if (imageWatermarkSettings) {
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Image, config: { image: { ...WatermarkImageBaseConfig, imageWatermarkSettings } } });
this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, {
type: IWatermarkTypeEnum.Image,
config: {
image: merge({}, WatermarkImageBaseConfig, imageWatermarkSettings),
},
});
} else {
const config = await this._localStorageService.getItem<IWatermarkConfigWithType>(UNIVER_WATERMARK_STORAGE_KEY);
if (config?.type === IWatermarkTypeEnum.UserInfo) {
Expand Down
Loading