lucid-extension-sdk 0.0.219 → 0.0.220
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/document/imagedefinition.d.ts +5 -0
- package/document/imagedefinition.js +20 -0
- package/document/pageproxy.js +2 -13
- package/package.json +1 -1
- package/ui/viewport.d.ts +16 -0
- package/ui/viewport.js +21 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SimpleImageFill } from '../core/properties/fillcolor';
|
|
2
2
|
import { StrokeStyle } from '../core/properties/strokestyle';
|
|
3
3
|
import { Box } from '../math';
|
|
4
|
+
import { BlockDefinition } from './blockdefinition';
|
|
4
5
|
/**
|
|
5
6
|
* The information required to create a new image block on the current document
|
|
6
7
|
*/
|
|
@@ -38,3 +39,7 @@ export interface ImageDefinition {
|
|
|
38
39
|
*/
|
|
39
40
|
rotation?: number;
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Turns an image definition into a block definition.
|
|
44
|
+
*/
|
|
45
|
+
export declare function imageToBlockDefinition(definition: ImageDefinition): BlockDefinition;
|
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageToBlockDefinition = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Turns an image definition into a block definition.
|
|
6
|
+
*/
|
|
7
|
+
function imageToBlockDefinition(definition) {
|
|
8
|
+
return {
|
|
9
|
+
className: 'UserImage2Block',
|
|
10
|
+
boundingBox: definition.boundingBox,
|
|
11
|
+
fillStyle: definition.fillStyle,
|
|
12
|
+
properties: {
|
|
13
|
+
opactiy: definition.opacity,
|
|
14
|
+
lineColor: definition.lineColor,
|
|
15
|
+
lineWidth: definition.lineWidth,
|
|
16
|
+
strokeStyle: definition.strokeStyle,
|
|
17
|
+
rounding: definition.rounding,
|
|
18
|
+
rotation: definition.rotation,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.imageToBlockDefinition = imageToBlockDefinition;
|
package/document/pageproxy.js
CHANGED
|
@@ -5,6 +5,7 @@ const commandtypes_1 = require("../commandtypes");
|
|
|
5
5
|
const ruleproxy_1 = require("./documentelement/ruleproxy");
|
|
6
6
|
const elementproxy_1 = require("./elementproxy");
|
|
7
7
|
const groupproxy_1 = require("./groupproxy");
|
|
8
|
+
const imagedefinition_1 = require("./imagedefinition");
|
|
8
9
|
const lineproxy_1 = require("./lineproxy");
|
|
9
10
|
const mapproxy_1 = require("./mapproxy");
|
|
10
11
|
/**
|
|
@@ -121,19 +122,7 @@ class PageProxy extends elementproxy_1.ElementProxy {
|
|
|
121
122
|
*/
|
|
122
123
|
async addImage(def) {
|
|
123
124
|
await this.client.loadBlockClasses(['UserImage2Block']);
|
|
124
|
-
return this.addBlock(
|
|
125
|
-
className: 'UserImage2Block',
|
|
126
|
-
boundingBox: def.boundingBox,
|
|
127
|
-
fillStyle: def.fillStyle,
|
|
128
|
-
properties: {
|
|
129
|
-
opactiy: def.opacity,
|
|
130
|
-
lineColor: def.lineColor,
|
|
131
|
-
lineWidth: def.lineWidth,
|
|
132
|
-
strokeStyle: def.strokeStyle,
|
|
133
|
-
rounding: def.rounding,
|
|
134
|
-
rotation: def.rotation,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
125
|
+
return this.addBlock((0, imagedefinition_1.imageToBlockDefinition)(def));
|
|
137
126
|
}
|
|
138
127
|
/**
|
|
139
128
|
* Updates the page of this page
|
package/package.json
CHANGED
package/ui/viewport.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlockDefinition } from '../document/blockdefinition';
|
|
2
|
+
import { ImageDefinition } from '../document/imagedefinition';
|
|
2
3
|
import { ItemProxy } from '../document/itemproxy';
|
|
3
4
|
import { PageProxy } from '../document/pageproxy';
|
|
4
5
|
import { EditorClient } from '../editorclient';
|
|
@@ -102,11 +103,26 @@ export declare class Viewport {
|
|
|
102
103
|
* or undefined if the user cancels the drag interaction.
|
|
103
104
|
*/
|
|
104
105
|
startDraggingNewBlock(definition: BlockDefinition): Promise<import("..").BlockProxy | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* Start an interaction of the current user dragging a new image onto the current page, exactly
|
|
108
|
+
* as if they started dragging that image out of the normal toolbox. At the time this function is
|
|
109
|
+
* called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
|
|
110
|
+
*
|
|
111
|
+
* @param definition Definition of the image to create if and where the user drops it on-canvas
|
|
112
|
+
* @returns A promise resolving to a reference to the created image, if successfully dropped,
|
|
113
|
+
* or undefined if the user cancels the drag interaction.
|
|
114
|
+
*/
|
|
115
|
+
startDraggingNewImage(definition: ImageDefinition): Promise<import("..").BlockProxy | undefined>;
|
|
105
116
|
/**
|
|
106
117
|
* If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
|
|
107
118
|
* cancel that interaction.
|
|
108
119
|
*/
|
|
109
120
|
cancelDraggingNewBlock(): void;
|
|
121
|
+
/**
|
|
122
|
+
* If startDraggingNewImage has been called, and the drag-new-image interaction is still active,
|
|
123
|
+
* cancel that interaction.
|
|
124
|
+
*/
|
|
125
|
+
cancelDraggingNewImage(): void;
|
|
110
126
|
/**
|
|
111
127
|
* After calling startDraggingNewBlock, call this to simulate the user moving the mouse at the
|
|
112
128
|
* given location within the top-level browser window.
|
package/ui/viewport.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Viewport = void 0;
|
|
4
4
|
const checks_1 = require("../core/checks");
|
|
5
5
|
const fillcolor_1 = require("../core/properties/fillcolor");
|
|
6
|
+
const imagedefinition_1 = require("../document/imagedefinition");
|
|
6
7
|
const itemproxy_1 = require("../document/itemproxy");
|
|
7
8
|
const pageproxy_1 = require("../document/pageproxy");
|
|
8
9
|
const math_1 = require("../math");
|
|
@@ -185,6 +186,19 @@ class Viewport {
|
|
|
185
186
|
});
|
|
186
187
|
return maybeBlockId ? this.client.getBlockProxy(maybeBlockId) : undefined;
|
|
187
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Start an interaction of the current user dragging a new image onto the current page, exactly
|
|
191
|
+
* as if they started dragging that image out of the normal toolbox. At the time this function is
|
|
192
|
+
* called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
|
|
193
|
+
*
|
|
194
|
+
* @param definition Definition of the image to create if and where the user drops it on-canvas
|
|
195
|
+
* @returns A promise resolving to a reference to the created image, if successfully dropped,
|
|
196
|
+
* or undefined if the user cancels the drag interaction.
|
|
197
|
+
*/
|
|
198
|
+
async startDraggingNewImage(definition) {
|
|
199
|
+
await this.client.loadBlockClasses(['UserImage2Block']);
|
|
200
|
+
return await this.startDraggingNewBlock((0, imagedefinition_1.imageToBlockDefinition)(definition));
|
|
201
|
+
}
|
|
188
202
|
/**
|
|
189
203
|
* If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
|
|
190
204
|
* cancel that interaction.
|
|
@@ -192,6 +206,13 @@ class Viewport {
|
|
|
192
206
|
cancelDraggingNewBlock() {
|
|
193
207
|
this.client.sendCommand("cdc" /* CommandName.CancelDragBlockToCanvas */, undefined);
|
|
194
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* If startDraggingNewImage has been called, and the drag-new-image interaction is still active,
|
|
211
|
+
* cancel that interaction.
|
|
212
|
+
*/
|
|
213
|
+
cancelDraggingNewImage() {
|
|
214
|
+
this.cancelDraggingNewBlock();
|
|
215
|
+
}
|
|
195
216
|
/**
|
|
196
217
|
* After calling startDraggingNewBlock, call this to simulate the user moving the mouse at the
|
|
197
218
|
* given location within the top-level browser window.
|