logisheets-core 1.2.0 → 1.4.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/ops/index.d.ts +7 -0
- package/dist/ops/index.js +14 -0
- package/dist/utils/uuid.js +12 -2
- package/package.json +2 -2
package/dist/ops/index.d.ts
CHANGED
|
@@ -76,6 +76,13 @@ export declare class WorkbookOps {
|
|
|
76
76
|
insertRowsInBlock(sheetIdx: number, blockId: number, start: number, cnt?: number): Promise<ActionEffect>;
|
|
77
77
|
/** Delete a block. */
|
|
78
78
|
removeBlock(sheetIdx: number, blockId: number): Promise<ActionEffect>;
|
|
79
|
+
/**
|
|
80
|
+
* Move a block so its master (top-left) cell lands at
|
|
81
|
+
* (`newMasterRow`, `newMasterCol`). The engine relocates the whole block
|
|
82
|
+
* region; the caller is responsible for making sure the destination is
|
|
83
|
+
* clear (see the drag-to-move overlay, which cancels on collision).
|
|
84
|
+
*/
|
|
85
|
+
moveBlock(sheetIdx: number, blockId: number, newMasterRow: number, newMasterCol: number): Promise<ActionEffect>;
|
|
79
86
|
/** Apply font styling (bold/italic/underline/strike/color/size). */
|
|
80
87
|
setFont(sheetIdx: number, data: SelectedData, update: FontStyle): Promise<void>;
|
|
81
88
|
/** Apply horizontal/vertical alignment. */
|
package/dist/ops/index.js
CHANGED
|
@@ -126,6 +126,20 @@ export class WorkbookOps {
|
|
|
126
126
|
removeBlock(sheetIdx, blockId) {
|
|
127
127
|
return this.apply([{ type: 'removeBlock', value: { sheetIdx, id: blockId } }], true);
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Move a block so its master (top-left) cell lands at
|
|
131
|
+
* (`newMasterRow`, `newMasterCol`). The engine relocates the whole block
|
|
132
|
+
* region; the caller is responsible for making sure the destination is
|
|
133
|
+
* clear (see the drag-to-move overlay, which cancels on collision).
|
|
134
|
+
*/
|
|
135
|
+
moveBlock(sheetIdx, blockId, newMasterRow, newMasterCol) {
|
|
136
|
+
return this.apply([
|
|
137
|
+
{
|
|
138
|
+
type: 'moveBlock',
|
|
139
|
+
value: { sheetIdx, id: blockId, newMasterRow, newMasterCol },
|
|
140
|
+
},
|
|
141
|
+
], true);
|
|
142
|
+
}
|
|
129
143
|
// ---- formatting -----------------------------------------------------
|
|
130
144
|
//
|
|
131
145
|
// Each method turns the current sheet + selection into style-update
|
package/dist/utils/uuid.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export function simpleUuid() {
|
|
2
|
-
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^
|
|
3
|
-
|
|
2
|
+
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16));
|
|
3
|
+
}
|
|
4
|
+
// `crypto` isn't a typed global here (this package targets ES2020 with no DOM
|
|
5
|
+
// lib, and it must run on both the browser and Node). Reach it through
|
|
6
|
+
// `globalThis` when available (browsers, Node >= 19) and fall back to
|
|
7
|
+
// Math.random otherwise — these ids aren't security-sensitive.
|
|
8
|
+
function randomByte() {
|
|
9
|
+
const webcrypto = globalThis.crypto;
|
|
10
|
+
if (webcrypto?.getRandomValues) {
|
|
11
|
+
return webcrypto.getRandomValues(new Uint8Array(1))[0];
|
|
12
|
+
}
|
|
13
|
+
return Math.floor(Math.random() * 256);
|
|
4
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "logisheets-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "UI-free LogiSheets logic — runs in the browser or on Node. Depends on logisheets-web only for types; the engine Client is injected by the host.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"author": "Jeremy He",
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"logisheets-web": "^1.
|
|
47
|
+
"logisheets-web": "^1.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"logisheets-web": "workspace:*",
|