@casualoffice/sheets 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chrome.cjs +2 -1
- package/dist/chrome.cjs.map +1 -1
- package/dist/chrome.js +2 -1
- package/dist/chrome.js.map +1 -1
- package/dist/collab.cjs +8 -3
- package/dist/collab.cjs.map +1 -1
- package/dist/collab.d.cts +27 -2
- package/dist/collab.d.ts +27 -2
- package/dist/collab.js +8 -3
- package/dist/collab.js.map +1 -1
- package/dist/embed/embed-runtime.js +103 -103
- package/dist/index.cjs +50 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/sheets.cjs +51 -2
- package/dist/sheets.cjs.map +1 -1
- package/dist/sheets.d.cts +30 -4
- package/dist/sheets.d.ts +30 -4
- package/dist/sheets.js +51 -2
- package/dist/sheets.js.map +1 -1
- package/package.json +1 -1
- package/src/chrome/fonts.ts +6 -1
- package/src/collab/attachCollab.ts +9 -3
- package/src/collab/index.ts +3 -0
- package/src/collab/ws-url.ts +35 -5
- package/src/collab/ws-url.unit.test.ts +55 -0
- package/src/embed-runtime/index.tsx +36 -0
- package/src/sheets/CasualSheetsIframe.tsx +5 -3
- package/src/sheets/index.ts +1 -0
- package/src/sheets/read-only.ts +106 -0
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ export { CapturedSignature, DrawnSignaturePad, DrawnSignaturePadProps, SigningCo
|
|
|
2
2
|
export { C as CancelReason, D as DocAnchor, S as SheetAnchor, a as SignatureAnchor, b as SignatureCompletePayload, c as SignatureField, d as SignatureMethod, e as SignatureMode, f as SignedFieldPayload, g as SigningSessionConfig } from './types-s_O0u6Cg.cjs';
|
|
3
3
|
export { EmbedHostHandlers, EmbedHostTransport, EmbedHostTransportOptions, EmbedTransport, EmbedTransportHandlers, EmbedTransportOptions } from './embed.cjs';
|
|
4
4
|
export { C as CasualApp, a as CasualEnvelope, d as CommandSetLocaleData, e as CommandSetReadOnlyData, f as CommandSetThemeData, E as EditorHelloData, h as ExitData, H as HostHelloData, L as LoadRequestData, i as LoadResponseData, j as LoadResponseDataErr, k as LoadResponseDataOk, l as LockLostData, S as SaveNotifyData, m as SaveRequestData, n as SaveResponseData, o as SaveResponseDataErr, p as SaveResponseDataOk, q as SelectionChangedData, s as SignatureCancelData, t as SignatureCompleteData, u as SignatureFieldSignedData, v as SignatureRequestAckData, w as SignatureRequestData, T as TelemetryEventData, x as isCasualEnvelope } from './protocol-Cq4Cdoyi.cjs';
|
|
5
|
-
export { CasualSheets, CasualSheetsIframe, CasualSheetsIframeProps, CasualSheetsIframeRef, CasualSheetsProps, HostFileBridge } from './sheets.cjs';
|
|
5
|
+
export { CasualSheets, CasualSheetsIframe, CasualSheetsIframeProps, CasualSheetsIframeRef, CasualSheetsProps, HostFileBridge, applyReadOnly, getEditable } from './sheets.cjs';
|
|
6
6
|
export { C as CasualSheetsAPI, R as RangeRef, c as createCasualSheetsAPI } from './api-CI_qPlRB.cjs';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@univerjs/core';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { CapturedSignature, DrawnSignaturePad, DrawnSignaturePadProps, SigningCo
|
|
|
2
2
|
export { C as CancelReason, D as DocAnchor, S as SheetAnchor, a as SignatureAnchor, b as SignatureCompletePayload, c as SignatureField, d as SignatureMethod, e as SignatureMode, f as SignedFieldPayload, g as SigningSessionConfig } from './types-s_O0u6Cg.js';
|
|
3
3
|
export { EmbedHostHandlers, EmbedHostTransport, EmbedHostTransportOptions, EmbedTransport, EmbedTransportHandlers, EmbedTransportOptions } from './embed.js';
|
|
4
4
|
export { C as CasualApp, a as CasualEnvelope, d as CommandSetLocaleData, e as CommandSetReadOnlyData, f as CommandSetThemeData, E as EditorHelloData, h as ExitData, H as HostHelloData, L as LoadRequestData, i as LoadResponseData, j as LoadResponseDataErr, k as LoadResponseDataOk, l as LockLostData, S as SaveNotifyData, m as SaveRequestData, n as SaveResponseData, o as SaveResponseDataErr, p as SaveResponseDataOk, q as SelectionChangedData, s as SignatureCancelData, t as SignatureCompleteData, u as SignatureFieldSignedData, v as SignatureRequestAckData, w as SignatureRequestData, T as TelemetryEventData, x as isCasualEnvelope } from './protocol-DqDaG2yG.js';
|
|
5
|
-
export { CasualSheets, CasualSheetsIframe, CasualSheetsIframeProps, CasualSheetsIframeRef, CasualSheetsProps, HostFileBridge } from './sheets.js';
|
|
5
|
+
export { CasualSheets, CasualSheetsIframe, CasualSheetsIframeProps, CasualSheetsIframeRef, CasualSheetsProps, HostFileBridge, applyReadOnly, getEditable } from './sheets.js';
|
|
6
6
|
export { C as CasualSheetsAPI, R as RangeRef, c as createCasualSheetsAPI } from './api-CI_qPlRB.js';
|
|
7
7
|
import 'react';
|
|
8
8
|
import '@univerjs/core';
|
package/dist/index.js
CHANGED
|
@@ -1507,6 +1507,53 @@ function applyAppearance(api, container, appearance) {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
|
+
// src/sheets/read-only.ts
|
|
1511
|
+
import { CustomCommandExecutionError, ICommandService as ICommandService2, IPermissionService } from "@univerjs/core";
|
|
1512
|
+
import { WorkbookEditablePermission } from "@univerjs/sheets";
|
|
1513
|
+
var READONLY_BLOCK = /(set-cell-edit-visible|set-activate-cell-edit|set-range-values|set-style|set-bold|set-italic|set-underline|set-strike|set-font|set-background|set-text|set-horizontal|set-vertical|set-wrap|set-rotation|set-border|set-number-format|insert-|delete-|remove-|clear-selection|cut-content|paste|move-range|move-rows|move-cols|merge|split|add-worksheet|set-worksheet-name|set-worksheet-row|set-worksheet-col|auto-fill|reorder|set-defined-name|set-tab-color|set-frozen-cancel)/;
|
|
1514
|
+
function applyReadOnly(univerApi, unitId, onBlock) {
|
|
1515
|
+
const injector = univerApi._injector;
|
|
1516
|
+
const cmd = injector?.get(ICommandService2);
|
|
1517
|
+
const vetoDisposable = cmd?.beforeCommandExecuted((info) => {
|
|
1518
|
+
if (READONLY_BLOCK.test(info.id)) {
|
|
1519
|
+
onBlock?.(info.id);
|
|
1520
|
+
throw new CustomCommandExecutionError(`read-only: blocked ${info.id}`);
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1523
|
+
const svc = injector?.get(IPermissionService);
|
|
1524
|
+
const id = new WorkbookEditablePermission(unitId).id;
|
|
1525
|
+
let prev;
|
|
1526
|
+
if (svc) {
|
|
1527
|
+
try {
|
|
1528
|
+
const existing = svc.getPermissionPoint(id);
|
|
1529
|
+
if (existing) {
|
|
1530
|
+
prev = existing.value;
|
|
1531
|
+
svc.updatePermissionPoint(id, false);
|
|
1532
|
+
} else {
|
|
1533
|
+
const point = new WorkbookEditablePermission(unitId);
|
|
1534
|
+
point.value = false;
|
|
1535
|
+
svc.addPermissionPoint(point);
|
|
1536
|
+
}
|
|
1537
|
+
} catch {
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return () => {
|
|
1541
|
+
vetoDisposable?.dispose();
|
|
1542
|
+
try {
|
|
1543
|
+
svc?.updatePermissionPoint(id, prev === void 0 ? true : prev);
|
|
1544
|
+
} catch {
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
function getEditable(univerApi, unitId) {
|
|
1549
|
+
const injector = univerApi._injector;
|
|
1550
|
+
const svc = injector?.get(IPermissionService);
|
|
1551
|
+
if (!svc) return void 0;
|
|
1552
|
+
const id = new WorkbookEditablePermission(unitId).id;
|
|
1553
|
+
const point = svc.getPermissionPoint(id);
|
|
1554
|
+
return point ? point.value : void 0;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1510
1557
|
// src/sheets/CasualSheetsIframe.tsx
|
|
1511
1558
|
import {
|
|
1512
1559
|
forwardRef,
|
|
@@ -1625,7 +1672,7 @@ var CasualSheetsIframe = forwardRef(
|
|
|
1625
1672
|
apiRef.current = {
|
|
1626
1673
|
setViewMode: (mode) => transportRef.current?.sendSetViewMode({ viewMode: mode }),
|
|
1627
1674
|
iframe: () => iframeRef.current,
|
|
1628
|
-
executeCommand: (command) => transportRef.current?.sendCommandExecute({ command })
|
|
1675
|
+
executeCommand: (command, args) => transportRef.current?.sendCommandExecute({ command, args })
|
|
1629
1676
|
};
|
|
1630
1677
|
}
|
|
1631
1678
|
const url = `${embedBasePath}/embed.html?app=sheet&docId=${encodeURIComponent(docId)}&viewMode=${viewMode}`;
|
|
@@ -1654,8 +1701,10 @@ export {
|
|
|
1654
1701
|
SigningProvider,
|
|
1655
1702
|
TypedSignatureField,
|
|
1656
1703
|
UploadedSignatureField,
|
|
1704
|
+
applyReadOnly,
|
|
1657
1705
|
createCasualSheetsAPI,
|
|
1658
1706
|
createSigningController,
|
|
1707
|
+
getEditable,
|
|
1659
1708
|
isCasualEnvelope,
|
|
1660
1709
|
useSigning
|
|
1661
1710
|
};
|