@tmagic/stage 1.5.0-beta.4 → 1.5.0-beta.6
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/tmagic-stage.js +24 -18
- package/dist/tmagic-stage.umd.cjs +25 -13
- package/package.json +4 -4
- package/src/MoveableActionsAble.ts +23 -3
- package/src/MoveableOptionsManager.ts +2 -1
- package/src/StageRender.ts +13 -13
- package/src/index.ts +5 -1
- package/src/util.ts +4 -4
- package/types/index.d.ts +32 -8
package/dist/tmagic-stage.js
CHANGED
|
@@ -4,7 +4,8 @@ import KeyController from 'keycon';
|
|
|
4
4
|
import { merge, throttle } from 'lodash-es';
|
|
5
5
|
import { Env } from '@tmagic/core';
|
|
6
6
|
import MoveableHelper from 'moveable-helper';
|
|
7
|
-
import
|
|
7
|
+
import Moveable__default from 'moveable';
|
|
8
|
+
export * from 'moveable';
|
|
8
9
|
import Guides from '@scena/guides';
|
|
9
10
|
|
|
10
11
|
const GHOST_EL_ID_PREFIX = "ghost_el_";
|
|
@@ -610,9 +611,10 @@ class DragResizeHelper {
|
|
|
610
611
|
|
|
611
612
|
const ableCss = ".moveable-button {\n width: 20px;\n height: 20px;\n background: #4af;\n border-radius: 4px;\n appearance: none;\n border: 0;\n color: white;\n font-size: 12px;\n font-weight: bold;\n margin-left: 2px;\n position: relative;\n}\n.moveable-remove-button:before, .moveable-remove-button:after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(45deg);\n width: 14px;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n cursor: pointer;\n}\n.moveable-remove-button:after {\n transform: translate(-50%, -50%) rotate(-45deg);\n}\n\n.moveable-select-parent-arrow-top-icon {\n transform: rotateZ(-45deg);\n width: 4px;\n height: 4px;\n border-color: #fff;\n border-width: 2px 2px 0 0;\n border-style: solid;\n position: absolute;\n left: 4px;\n top: 4px;\n}\n\n.moveable-select-parent-arrow-body-icon {\n width: 7px;\n height: 11px;\n border-color: #fff;\n border-width: 0 0 2px 2px;\n border-style: solid;\n}\n\n.moveable-drag-area-button {\n cursor: move;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon {\n width: 2px;\n height: 2px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-top {\n transform: rotateZ(-45deg) translateX(-50%);\n left: 50%;\n top: 3px;\n transform-origin: left;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-bottom {\n transform: rotateZ(135deg) translateX(-50%);\n transform-origin: left;\n left: 50%;\n top: auto;\n bottom: 3px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-right {\n transform: rotateZ(45deg) translateY(-50%);\n transform-origin: top;\n right: 3px;\n left: auto;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-left {\n transform: rotateZ(235deg) translateY(-50%);\n transform-origin: top;\n left: 3px;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-horizontal {\n width: 2px;\n height: 11px;\n background-color: #fff;\n position: absolute;\n transform: translateX(-50%);\n left: 50%;\n top: 4px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-vertical {\n width: 11px;\n height: 2px;\n background-color: #fff;\n position: absolute;\n transform: translateY(-50%);\n left: 4px;\n top: 50%;;\n}\n\n";
|
|
612
613
|
|
|
613
|
-
const MoveableActionsAble = (handler) => ({
|
|
614
|
+
const MoveableActionsAble = (handler, customizedButton = []) => ({
|
|
614
615
|
name: "actions",
|
|
615
616
|
props: [],
|
|
617
|
+
always: true,
|
|
616
618
|
events: [],
|
|
617
619
|
render(moveable, React) {
|
|
618
620
|
const rect = moveable.getRect();
|
|
@@ -636,10 +638,14 @@ const MoveableActionsAble = (handler) => ({
|
|
|
636
638
|
{
|
|
637
639
|
className: "moveable-editable",
|
|
638
640
|
style: {
|
|
639
|
-
transform: `translate(${pos2[0] -
|
|
641
|
+
transform: `translate(${pos2[0] - (customizedButton.length + 3) * 20}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg)`
|
|
640
642
|
}
|
|
641
643
|
},
|
|
642
644
|
[
|
|
645
|
+
...customizedButton.map((buttonRenderer) => {
|
|
646
|
+
const options = buttonRenderer(React);
|
|
647
|
+
return React.createElement("button", options.props || {}, ...options.children || []);
|
|
648
|
+
}),
|
|
643
649
|
React.createElement(
|
|
644
650
|
"button",
|
|
645
651
|
{
|
|
@@ -761,7 +767,7 @@ class MoveableOptionsManager extends EventEmitter {
|
|
|
761
767
|
*/
|
|
762
768
|
getOptions(isMultiSelect, runtimeOptions = {}) {
|
|
763
769
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
764
|
-
const customizedOptions = this.getCustomizeOptions();
|
|
770
|
+
const customizedOptions = this.getCustomizeOptions() || {};
|
|
765
771
|
this.options = merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
766
772
|
return this.options;
|
|
767
773
|
}
|
|
@@ -1001,7 +1007,7 @@ class StageDragResize extends MoveableOptionsManager {
|
|
|
1001
1007
|
const options = this.init(el);
|
|
1002
1008
|
this.dragResizeHelper.clear();
|
|
1003
1009
|
this.moveable?.destroy();
|
|
1004
|
-
this.moveable = new
|
|
1010
|
+
this.moveable = new Moveable__default(this.container, {
|
|
1005
1011
|
...options
|
|
1006
1012
|
});
|
|
1007
1013
|
this.bindResizeEvent();
|
|
@@ -1183,7 +1189,7 @@ class StageHighlight extends EventEmitter$1 {
|
|
|
1183
1189
|
this.moveable.zoom = 2;
|
|
1184
1190
|
this.moveable.updateRect();
|
|
1185
1191
|
} else {
|
|
1186
|
-
this.moveable = new
|
|
1192
|
+
this.moveable = new Moveable__default(this.container, {
|
|
1187
1193
|
target: this.targetShadow?.el,
|
|
1188
1194
|
origin: false,
|
|
1189
1195
|
rootContainer: this.getRootContainer(),
|
|
@@ -1256,7 +1262,7 @@ class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
1256
1262
|
this.setElementGuidelines(this.targetList);
|
|
1257
1263
|
this.moveableForMulti?.destroy();
|
|
1258
1264
|
this.dragResizeHelper.clear();
|
|
1259
|
-
this.moveableForMulti = new
|
|
1265
|
+
this.moveableForMulti = new Moveable__default(
|
|
1260
1266
|
this.container,
|
|
1261
1267
|
this.getOptions(true, {
|
|
1262
1268
|
target: this.dragResizeHelper.getShadowEls()
|
|
@@ -2370,6 +2376,16 @@ class StageRender extends EventEmitter$1 {
|
|
|
2370
2376
|
getTargetElement(id) {
|
|
2371
2377
|
return getElById()(this.getDocument(), id);
|
|
2372
2378
|
}
|
|
2379
|
+
postTmagicRuntimeReady() {
|
|
2380
|
+
this.contentWindow = this.iframe?.contentWindow;
|
|
2381
|
+
this.contentWindow.magic = this.getMagicApi();
|
|
2382
|
+
this.contentWindow.postMessage(
|
|
2383
|
+
{
|
|
2384
|
+
tmagicRuntimeReady: true
|
|
2385
|
+
},
|
|
2386
|
+
"*"
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2373
2389
|
/**
|
|
2374
2390
|
* 销毁实例
|
|
2375
2391
|
*/
|
|
@@ -2433,16 +2449,6 @@ class StageRender extends EventEmitter$1 {
|
|
|
2433
2449
|
this.emit("onload");
|
|
2434
2450
|
injectStyle(this.contentWindow.document, style);
|
|
2435
2451
|
};
|
|
2436
|
-
postTmagicRuntimeReady() {
|
|
2437
|
-
this.contentWindow = this.iframe?.contentWindow;
|
|
2438
|
-
this.contentWindow.magic = this.getMagicApi();
|
|
2439
|
-
this.contentWindow.postMessage(
|
|
2440
|
-
{
|
|
2441
|
-
tmagicRuntimeReady: true
|
|
2442
|
-
},
|
|
2443
|
-
"*"
|
|
2444
|
-
);
|
|
2445
|
-
}
|
|
2446
2452
|
}
|
|
2447
2453
|
|
|
2448
2454
|
class StageCore extends EventEmitter$1 {
|
|
@@ -2746,4 +2752,4 @@ class StageCore extends EventEmitter$1 {
|
|
|
2746
2752
|
}
|
|
2747
2753
|
}
|
|
2748
2754
|
|
|
2749
|
-
export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, PAGE_CLASS, RenderType, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
2755
|
+
export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, MoveableActionsAble, PAGE_CLASS, RenderType, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
@@ -607,9 +607,10 @@
|
|
|
607
607
|
|
|
608
608
|
const ableCss = ".moveable-button {\n width: 20px;\n height: 20px;\n background: #4af;\n border-radius: 4px;\n appearance: none;\n border: 0;\n color: white;\n font-size: 12px;\n font-weight: bold;\n margin-left: 2px;\n position: relative;\n}\n.moveable-remove-button:before, .moveable-remove-button:after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(45deg);\n width: 14px;\n height: 2px;\n background: #fff;\n border-radius: 1px;\n cursor: pointer;\n}\n.moveable-remove-button:after {\n transform: translate(-50%, -50%) rotate(-45deg);\n}\n\n.moveable-select-parent-arrow-top-icon {\n transform: rotateZ(-45deg);\n width: 4px;\n height: 4px;\n border-color: #fff;\n border-width: 2px 2px 0 0;\n border-style: solid;\n position: absolute;\n left: 4px;\n top: 4px;\n}\n\n.moveable-select-parent-arrow-body-icon {\n width: 7px;\n height: 11px;\n border-color: #fff;\n border-width: 0 0 2px 2px;\n border-style: solid;\n}\n\n.moveable-drag-area-button {\n cursor: move;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon {\n width: 2px;\n height: 2px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-top {\n transform: rotateZ(-45deg) translateX(-50%);\n left: 50%;\n top: 3px;\n transform-origin: left;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-bottom {\n transform: rotateZ(135deg) translateX(-50%);\n transform-origin: left;\n left: 50%;\n top: auto;\n bottom: 3px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-right {\n transform: rotateZ(45deg) translateY(-50%);\n transform-origin: top;\n right: 3px;\n left: auto;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-top-icon-left {\n transform: rotateZ(235deg) translateY(-50%);\n transform-origin: top;\n left: 3px;\n top: 50%;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-horizontal {\n width: 2px;\n height: 11px;\n background-color: #fff;\n position: absolute;\n transform: translateX(-50%);\n left: 50%;\n top: 4px;\n}\n\n.moveable-drag-area-button .moveable-select-parent-arrow-body-icon-vertical {\n width: 11px;\n height: 2px;\n background-color: #fff;\n position: absolute;\n transform: translateY(-50%);\n left: 4px;\n top: 50%;;\n}\n\n";
|
|
609
609
|
|
|
610
|
-
const MoveableActionsAble = (handler) => ({
|
|
610
|
+
const MoveableActionsAble = (handler, customizedButton = []) => ({
|
|
611
611
|
name: "actions",
|
|
612
612
|
props: [],
|
|
613
|
+
always: true,
|
|
613
614
|
events: [],
|
|
614
615
|
render(moveable, React) {
|
|
615
616
|
const rect = moveable.getRect();
|
|
@@ -633,10 +634,14 @@
|
|
|
633
634
|
{
|
|
634
635
|
className: "moveable-editable",
|
|
635
636
|
style: {
|
|
636
|
-
transform: `translate(${pos2[0] -
|
|
637
|
+
transform: `translate(${pos2[0] - (customizedButton.length + 3) * 20}px, ${pos2[1] - 28}px) rotate(${rect.rotation}deg)`
|
|
637
638
|
}
|
|
638
639
|
},
|
|
639
640
|
[
|
|
641
|
+
...customizedButton.map((buttonRenderer) => {
|
|
642
|
+
const options = buttonRenderer(React);
|
|
643
|
+
return React.createElement("button", options.props || {}, ...options.children || []);
|
|
644
|
+
}),
|
|
640
645
|
React.createElement(
|
|
641
646
|
"button",
|
|
642
647
|
{
|
|
@@ -758,7 +763,7 @@
|
|
|
758
763
|
*/
|
|
759
764
|
getOptions(isMultiSelect, runtimeOptions = {}) {
|
|
760
765
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
761
|
-
const customizedOptions = this.getCustomizeOptions();
|
|
766
|
+
const customizedOptions = this.getCustomizeOptions() || {};
|
|
762
767
|
this.options = lodashEs.merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
763
768
|
return this.options;
|
|
764
769
|
}
|
|
@@ -2367,6 +2372,16 @@
|
|
|
2367
2372
|
getTargetElement(id) {
|
|
2368
2373
|
return utils.getElById()(this.getDocument(), id);
|
|
2369
2374
|
}
|
|
2375
|
+
postTmagicRuntimeReady() {
|
|
2376
|
+
this.contentWindow = this.iframe?.contentWindow;
|
|
2377
|
+
this.contentWindow.magic = this.getMagicApi();
|
|
2378
|
+
this.contentWindow.postMessage(
|
|
2379
|
+
{
|
|
2380
|
+
tmagicRuntimeReady: true
|
|
2381
|
+
},
|
|
2382
|
+
"*"
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2370
2385
|
/**
|
|
2371
2386
|
* 销毁实例
|
|
2372
2387
|
*/
|
|
@@ -2430,16 +2445,6 @@
|
|
|
2430
2445
|
this.emit("onload");
|
|
2431
2446
|
utils.injectStyle(this.contentWindow.document, style);
|
|
2432
2447
|
};
|
|
2433
|
-
postTmagicRuntimeReady() {
|
|
2434
|
-
this.contentWindow = this.iframe?.contentWindow;
|
|
2435
|
-
this.contentWindow.magic = this.getMagicApi();
|
|
2436
|
-
this.contentWindow.postMessage(
|
|
2437
|
-
{
|
|
2438
|
-
tmagicRuntimeReady: true
|
|
2439
|
-
},
|
|
2440
|
-
"*"
|
|
2441
|
-
);
|
|
2442
|
-
}
|
|
2443
2448
|
}
|
|
2444
2449
|
|
|
2445
2450
|
class StageCore extends EventEmitter.EventEmitter {
|
|
@@ -2753,6 +2758,7 @@
|
|
|
2753
2758
|
exports.HIGHLIGHT_EL_ID_PREFIX = HIGHLIGHT_EL_ID_PREFIX;
|
|
2754
2759
|
exports.Mode = Mode;
|
|
2755
2760
|
exports.MouseButton = MouseButton;
|
|
2761
|
+
exports.MoveableActionsAble = MoveableActionsAble;
|
|
2756
2762
|
exports.PAGE_CLASS = PAGE_CLASS;
|
|
2757
2763
|
exports.RenderType = RenderType;
|
|
2758
2764
|
exports.SELECTED_CLASS = SELECTED_CLASS;
|
|
@@ -2780,6 +2786,12 @@
|
|
|
2780
2786
|
exports.isStatic = isStatic;
|
|
2781
2787
|
exports.removeSelectedClassName = removeSelectedClassName;
|
|
2782
2788
|
exports.up = up;
|
|
2789
|
+
Object.keys(Moveable).forEach(k => {
|
|
2790
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2791
|
+
enumerable: true,
|
|
2792
|
+
get: () => Moveable[k]
|
|
2793
|
+
});
|
|
2794
|
+
});
|
|
2783
2795
|
|
|
2784
2796
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2785
2797
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.0-beta.
|
|
2
|
+
"version": "1.5.0-beta.6",
|
|
3
3
|
"name": "@tmagic/stage",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/tmagic-stage.umd.cjs",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"typescript": "*",
|
|
48
|
-
"@tmagic/
|
|
49
|
-
"@tmagic/
|
|
50
|
-
"@tmagic/
|
|
48
|
+
"@tmagic/schema": "1.5.0-beta.6",
|
|
49
|
+
"@tmagic/utils": "1.5.0-beta.6",
|
|
50
|
+
"@tmagic/core": "1.5.0-beta.6"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"typescript": {
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import { MoveableManagerInterface, Renderer } from 'moveable';
|
|
1
|
+
import type { MoveableManagerInterface, Renderer } from 'moveable';
|
|
2
2
|
|
|
3
3
|
import { AbleActionEventType } from './const';
|
|
4
4
|
import ableCss from './moveable-able.css?raw';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface AbleCustomizedButton {
|
|
7
|
+
props: {
|
|
8
|
+
className?: string;
|
|
9
|
+
onClick?(e: MouseEvent): void;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
children: ReturnType<Renderer['createElement']>[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default (
|
|
16
|
+
handler: (type: AbleActionEventType) => void,
|
|
17
|
+
customizedButton: ((react: Renderer) => AbleCustomizedButton)[] = [],
|
|
18
|
+
) => ({
|
|
7
19
|
name: 'actions',
|
|
8
20
|
props: [],
|
|
21
|
+
always: true,
|
|
9
22
|
events: [],
|
|
10
23
|
render(moveable: MoveableManagerInterface<any, any>, React: Renderer) {
|
|
11
24
|
const rect = moveable.getRect();
|
|
@@ -33,10 +46,17 @@ export default (handler: (type: AbleActionEventType) => void) => ({
|
|
|
33
46
|
{
|
|
34
47
|
className: 'moveable-editable',
|
|
35
48
|
style: {
|
|
36
|
-
transform: `translate(${pos2[0] -
|
|
49
|
+
transform: `translate(${pos2[0] - (customizedButton.length + 3) * 20}px, ${pos2[1] - 28}px) rotate(${
|
|
50
|
+
rect.rotation
|
|
51
|
+
}deg)`,
|
|
37
52
|
},
|
|
38
53
|
},
|
|
39
54
|
[
|
|
55
|
+
...customizedButton.map((buttonRenderer) => {
|
|
56
|
+
const options = buttonRenderer(React);
|
|
57
|
+
return React.createElement('button', options.props || {}, ...(options.children || []));
|
|
58
|
+
}),
|
|
59
|
+
|
|
40
60
|
React.createElement(
|
|
41
61
|
'button',
|
|
42
62
|
{
|
|
@@ -112,9 +112,10 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
112
112
|
*/
|
|
113
113
|
protected getOptions(isMultiSelect: boolean, runtimeOptions: MoveableOptions = {}): MoveableOptions {
|
|
114
114
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
115
|
-
const customizedOptions = this.getCustomizeOptions();
|
|
115
|
+
const customizedOptions = this.getCustomizeOptions() || {};
|
|
116
116
|
|
|
117
117
|
this.options = merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
118
|
+
|
|
118
119
|
return this.options;
|
|
119
120
|
}
|
|
120
121
|
|
package/src/StageRender.ts
CHANGED
|
@@ -155,6 +155,19 @@ export default class StageRender extends EventEmitter {
|
|
|
155
155
|
return getElById()(this.getDocument(), id);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
public postTmagicRuntimeReady() {
|
|
159
|
+
this.contentWindow = this.iframe?.contentWindow as RuntimeWindow;
|
|
160
|
+
|
|
161
|
+
this.contentWindow.magic = this.getMagicApi();
|
|
162
|
+
|
|
163
|
+
this.contentWindow.postMessage(
|
|
164
|
+
{
|
|
165
|
+
tmagicRuntimeReady: true,
|
|
166
|
+
},
|
|
167
|
+
'*',
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
158
171
|
/**
|
|
159
172
|
* 销毁实例
|
|
160
173
|
*/
|
|
@@ -236,17 +249,4 @@ export default class StageRender extends EventEmitter {
|
|
|
236
249
|
|
|
237
250
|
injectStyle(this.contentWindow.document, style);
|
|
238
251
|
};
|
|
239
|
-
|
|
240
|
-
private postTmagicRuntimeReady() {
|
|
241
|
-
this.contentWindow = this.iframe?.contentWindow as RuntimeWindow;
|
|
242
|
-
|
|
243
|
-
this.contentWindow.magic = this.getMagicApi();
|
|
244
|
-
|
|
245
|
-
this.contentWindow.postMessage(
|
|
246
|
-
{
|
|
247
|
-
tmagicRuntimeReady: true,
|
|
248
|
-
},
|
|
249
|
-
'*',
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
252
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,12 +18,16 @@
|
|
|
18
18
|
|
|
19
19
|
import StageCore from './StageCore';
|
|
20
20
|
|
|
21
|
-
export
|
|
21
|
+
export * from 'moveable';
|
|
22
22
|
export type { GuidesOptions } from '@scena/guides';
|
|
23
|
+
|
|
23
24
|
export { default as StageRender } from './StageRender';
|
|
24
25
|
export { default as StageMask } from './StageMask';
|
|
25
26
|
export { default as StageDragResize } from './StageDragResize';
|
|
26
27
|
export * from './types';
|
|
27
28
|
export * from './const';
|
|
28
29
|
export * from './util';
|
|
30
|
+
export * from './MoveableActionsAble';
|
|
31
|
+
export { default as MoveableActionsAble } from './MoveableActionsAble';
|
|
32
|
+
|
|
29
33
|
export default StageCore;
|
package/src/util.ts
CHANGED
|
@@ -88,13 +88,13 @@ export const getAbsolutePosition = (el: HTMLElement, { top, left }: Offset) => {
|
|
|
88
88
|
return { left, top };
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export const isAbsolute = (style:
|
|
91
|
+
export const isAbsolute = (style: { position?: string }): boolean => style.position === 'absolute';
|
|
92
92
|
|
|
93
|
-
export const isRelative = (style:
|
|
93
|
+
export const isRelative = (style: { position?: string }): boolean => style.position === 'relative';
|
|
94
94
|
|
|
95
|
-
export const isStatic = (style:
|
|
95
|
+
export const isStatic = (style: { position?: string }): boolean => style.position === 'static';
|
|
96
96
|
|
|
97
|
-
export const isFixed = (style:
|
|
97
|
+
export const isFixed = (style: { position?: string }): boolean => style.position === 'fixed';
|
|
98
98
|
|
|
99
99
|
export const isFixedParent = (el: Element) => {
|
|
100
100
|
let fixed = false;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
2
|
-
import { OnResizeStart, OnResize, OnDragStart, OnDrag, OnRotateStart, OnRotate, OnScaleStart, OnScale, OnResizeGroupStart, OnResizeGroup, OnDragGroupStart, OnDragGroup, MoveableOptions } from 'moveable';
|
|
3
|
-
export
|
|
2
|
+
import { OnResizeStart, OnResize, OnDragStart, OnDrag, OnRotateStart, OnRotate, OnScaleStart, OnScale, OnResizeGroupStart, OnResizeGroup, OnDragGroupStart, OnDragGroup, MoveableOptions, Renderer, MoveableManagerInterface } from 'moveable';
|
|
3
|
+
export * from 'moveable';
|
|
4
4
|
import { Id, MApp, MNode, MContainer } from '@tmagic/schema';
|
|
5
5
|
import Guides, { GuidesOptions } from '@scena/guides';
|
|
6
6
|
export { GuidesOptions } from '@scena/guides';
|
|
@@ -698,6 +698,7 @@ declare class StageRender extends EventEmitter$1 {
|
|
|
698
698
|
*/
|
|
699
699
|
getElementsFromPoint(point: Point): HTMLElement[];
|
|
700
700
|
getTargetElement(id: Id): HTMLElement | null;
|
|
701
|
+
postTmagicRuntimeReady(): void;
|
|
701
702
|
/**
|
|
702
703
|
* 销毁实例
|
|
703
704
|
*/
|
|
@@ -712,7 +713,6 @@ declare class StageRender extends EventEmitter$1 {
|
|
|
712
713
|
*/
|
|
713
714
|
private flagSelectedEl;
|
|
714
715
|
private iframeLoadHandler;
|
|
715
|
-
private postTmagicRuntimeReady;
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
/**
|
|
@@ -959,10 +959,18 @@ declare const getAbsolutePosition: (el: HTMLElement, { top, left }: Offset) => {
|
|
|
959
959
|
left: number;
|
|
960
960
|
top: number;
|
|
961
961
|
};
|
|
962
|
-
declare const isAbsolute: (style:
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
declare const
|
|
962
|
+
declare const isAbsolute: (style: {
|
|
963
|
+
position?: string;
|
|
964
|
+
}) => boolean;
|
|
965
|
+
declare const isRelative: (style: {
|
|
966
|
+
position?: string;
|
|
967
|
+
}) => boolean;
|
|
968
|
+
declare const isStatic: (style: {
|
|
969
|
+
position?: string;
|
|
970
|
+
}) => boolean;
|
|
971
|
+
declare const isFixed: (style: {
|
|
972
|
+
position?: string;
|
|
973
|
+
}) => boolean;
|
|
966
974
|
declare const isFixedParent: (el: Element) => boolean;
|
|
967
975
|
declare const getMode: (el: Element) => Mode;
|
|
968
976
|
declare const getScrollParent: (element: HTMLElement, includeHidden?: boolean) => HTMLElement | null;
|
|
@@ -994,4 +1002,20 @@ declare const getBorderWidth: (el: Element) => {
|
|
|
994
1002
|
borderBottomWidth: number;
|
|
995
1003
|
};
|
|
996
1004
|
|
|
997
|
-
|
|
1005
|
+
interface AbleCustomizedButton {
|
|
1006
|
+
props: {
|
|
1007
|
+
className?: string;
|
|
1008
|
+
onClick?(e: MouseEvent): void;
|
|
1009
|
+
[key: string]: any;
|
|
1010
|
+
};
|
|
1011
|
+
children: ReturnType<Renderer['createElement']>[];
|
|
1012
|
+
}
|
|
1013
|
+
declare const _default: (handler: (type: AbleActionEventType) => void, customizedButton?: ((react: Renderer) => AbleCustomizedButton)[]) => {
|
|
1014
|
+
name: string;
|
|
1015
|
+
props: never[];
|
|
1016
|
+
always: boolean;
|
|
1017
|
+
events: never[];
|
|
1018
|
+
render(moveable: MoveableManagerInterface<any, any>, React: Renderer): any;
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
export { AbleActionEventType, type AbleCustomizedButton, type ActionManagerConfig, type ActionManagerEvents, CONTAINER_HIGHLIGHT_CLASS_NAME, type CanSelect, ContainerHighlightType, type CoreEvents, type CustomizeMoveableOptions, type CustomizeMoveableOptionsCallbackConfig, type CustomizeRender, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, type DelayedMarkContainer, type DrEvents, type DragResizeHelperConfig, GHOST_EL_ID_PREFIX, type GetElementsFromPoint, type GetRenderDocument, type GetRootContainer, type GetTargetElement, type GuidesEventData, GuidesType, HIGHLIGHT_EL_ID_PREFIX, type IsContainer, type Magic, type MarkContainerEnd, type MaskEvents, Mode, MouseButton, _default as MoveableActionsAble, type MoveableOptionsManagerConfig, type MultiDrEvents, type Offset, PAGE_CLASS, type Point, type Rect, type RemoveData, type RemoveEventData, type RenderEvents, RenderType, type RuleOptions, type Runtime, type RuntimeWindow, SELECTED_CLASS, SelectStatus, type SortEventData, type StageCoreConfig, StageDragResize, type StageDragResizeConfig, StageDragStatus, type StageHighlightConfig, StageMask, type StageMaskConfig, type StageMultiDragResizeConfig, StageRender, type StageRenderConfig, type TargetElement, type TargetShadowConfig, type UpdateData, type UpdateDragEl, type UpdateEventData, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|