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

feat: add notExecuteFormula and license with worker #10

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples-node/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CLIENT_PORT=
APP_ENDPOINT=
CLIENT_LICENSE_TEXT=
UNIVER_CLIENT_LICENSE=
2 changes: 1 addition & 1 deletion examples/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CLIENT_PORT=
APP_ENDPOINT=
CLIENT_LICENSE_TEXT=
UNIVER_CLIENT_LICENSE=
1 change: 1 addition & 0 deletions examples/esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function monacoBuildTask() {

const define = {
'process.env.NODE_ENV': args.watch ? '"development"' : '"production"',
'process.env.UNIVER_CLIENT_LICENSE': process.env.UNIVER_CLIENT_LICENSE ? `"${process.env.UNIVER_CLIENT_LICENSE}"` : 'undefined',
};

if (!args.watch) {
Expand Down
7 changes: 7 additions & 0 deletions examples/src/sheets-collaboration-with-worker/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UniverSheetsCollaborationPreset } from '@univerjs/presets/preset-sheets
import sheetsCollaborationZhCN from '@univerjs/presets/preset-sheets-collaboration/locales/zh-CN';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import sheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
import { UniverSheetsDrawingPreset } from '@univerjs/presets/preset-sheets-drawing';

createUniver({
locale: LocaleType.ZH_CN,
Expand All @@ -22,8 +23,14 @@ createUniver({
UniverSheetsCorePreset({
workerURL: new Worker(new URL('./worker.js', import.meta.url), { type: 'module' }),
}),
UniverSheetsDrawingPreset({
collaboration: true,
}),
UniverSheetsAdvancedPreset({
useWorker: true,
// if you want to use the no-limit business feature, you can get 30-day trial license from https://univer.ai/pro/license
// eslint-disable-next-line node/prefer-global/process
license: process.env.UNIVER_CLIENT_LICENSE || 'your license.txt',
}),
UniverSheetsCollaborationPreset(),
],
Expand Down
6 changes: 5 additions & 1 deletion examples/src/sheets-collaboration-with-worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ createUniver({
},
presets: [
UniverSheetsCoreWorkerPreset(),
UniverSheetsAdvancedWorkerPreset(),
UniverSheetsAdvancedWorkerPreset({
// if you want to use the no-limit business feature, you can get 30-day trial license from https://univer.ai/pro/license
// eslint-disable-next-line node/prefer-global/process
license: process.env.UNIVER_CLIENT_LICENSE || 'your license.txt',
}),
],
});
4 changes: 3 additions & 1 deletion packages/preset-sheets-advanced/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export function UniverSheetsAdvancedPreset(config: Partial<IUniverSheetsAdvanced
: [UniverSheetsPivotTablePlugin],
UniverSheetsPivotTableUIPlugin,

UniverProFormulaEnginePlugin,
useWorker
? [UniverProFormulaEnginePlugin, { notExecuteFormula: true }]
: UniverProFormulaEnginePlugin,

UniverSheetsPrintPlugin,

Expand Down
16 changes: 15 additions & 1 deletion packages/preset-sheets-advanced/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import type { IPreset } from './types';
import { UniverProFormulaEnginePlugin } from '@univerjs-pro/engine-formula';
import { UniverLicensePlugin } from '@univerjs-pro/license';
import { UniverSheetsPivotTablePlugin } from '@univerjs-pro/sheets-pivot';

export function UniverSheetsAdvancedWorkerPreset(): IPreset {
export interface IUniverSheetsAdvancedWorkerPresetConfig {
license?: string;
}

export function UniverSheetsAdvancedWorkerPreset(config: Partial<IUniverSheetsAdvancedWorkerPresetConfig> = {
license: '',
}): IPreset {
const {
license,
} = config;

return {
plugins: [
[UniverLicensePlugin, { license }],
UniverProFormulaEnginePlugin,
[UniverSheetsPivotTablePlugin, { notExecuteFormula: false }],
],
};
Expand Down