@vivix-labs/magic-edit 0.0.0-stage → 1.0.0-beta
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/HTML-TO-IMAGE-LICENSE.txt +21 -0
- package/README.md +44 -2
- package/dist/UI-SYSTEM-LICENSE.txt +21 -0
- package/dist/assets/toolbar-divider-DHGQDOLY.svg +5 -0
- package/dist/client-code.css +423 -0
- package/dist/client-code.js +2163 -0
- package/dist/client.js +3 -0
- package/dist/shared.d.ts +53 -0
- package/dist/shared.js +21 -0
- package/package.json +25 -3
- package/studio-plugin.json +6 -0
package/dist/client.js
ADDED
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
interface TargetContext {
|
|
4
|
+
id: string;
|
|
5
|
+
kind: 'surface' | 'media';
|
|
6
|
+
label: string;
|
|
7
|
+
revision?: number;
|
|
8
|
+
ref?: {
|
|
9
|
+
storeId: string;
|
|
10
|
+
objectId: string;
|
|
11
|
+
versionId: string;
|
|
12
|
+
};
|
|
13
|
+
sourceTimeMs?: number;
|
|
14
|
+
endSourceTimeMs?: number;
|
|
15
|
+
visibleText?: string;
|
|
16
|
+
context?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
type AnnotationTarget = TargetContext & {
|
|
19
|
+
element: HTMLElement;
|
|
20
|
+
};
|
|
21
|
+
interface MagicEditToolProps {
|
|
22
|
+
target: Readonly<TargetContext> | null;
|
|
23
|
+
regionCount: number;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface MagicEditProps {
|
|
27
|
+
targets?(): readonly AnnotationTarget[];
|
|
28
|
+
tools?: readonly {
|
|
29
|
+
id: string;
|
|
30
|
+
component: ComponentType<MagicEditToolProps>;
|
|
31
|
+
}[];
|
|
32
|
+
global?: boolean;
|
|
33
|
+
embeddedProject?: {
|
|
34
|
+
projectId: string;
|
|
35
|
+
frame: {
|
|
36
|
+
readonly current: HTMLIFrameElement | null;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface MagicEditToolMount {
|
|
42
|
+
element: HTMLElement;
|
|
43
|
+
props: MagicEditToolProps;
|
|
44
|
+
}
|
|
45
|
+
interface MagicEditSource {
|
|
46
|
+
targets(): readonly AnnotationTarget[];
|
|
47
|
+
mountTools?(mount: MagicEditToolMount | null): void;
|
|
48
|
+
}
|
|
49
|
+
declare function hasGlobalMagicEdit(): boolean;
|
|
50
|
+
/** Publish optional project annotations to the same-origin Studio Home. */
|
|
51
|
+
declare function publishMagicEditSource(source: MagicEditSource): () => void;
|
|
52
|
+
|
|
53
|
+
export { type AnnotationTarget, type MagicEditProps, type MagicEditToolMount, type MagicEditToolProps, hasGlobalMagicEdit, publishMagicEditSource };
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/magic-edit/src/bridge.ts
|
|
2
|
+
var sourceRequest = "vivix:magic-edit-source";
|
|
3
|
+
function hasGlobalMagicEdit() {
|
|
4
|
+
try {
|
|
5
|
+
return window.parent !== window && Boolean(window.parent.document.querySelector("[data-vivix-magic-edit-global]"));
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function publishMagicEditSource(source) {
|
|
11
|
+
function respond(event) {
|
|
12
|
+
const receive = event.detail;
|
|
13
|
+
if (typeof receive === "function") receive(source);
|
|
14
|
+
}
|
|
15
|
+
document.addEventListener(sourceRequest, respond);
|
|
16
|
+
return () => document.removeEventListener(sourceRequest, respond);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
hasGlobalMagicEdit,
|
|
20
|
+
publishMagicEditSource
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vivix-labs/magic-edit",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0-beta",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org/",
|
|
8
|
+
"tag": "beta"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"studio-plugin.json",
|
|
13
|
+
"HTML-TO-IMAGE-LICENSE.txt"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
"./client": "./dist/client.js",
|
|
17
|
+
"./studio-plugin.json": "./studio-plugin.json",
|
|
18
|
+
"./shared": {
|
|
19
|
+
"types": "./dist/shared.d.ts",
|
|
20
|
+
"import": "./dist/shared.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"html-to-image": "1.11.13",
|
|
25
|
+
"react": "19.3.1",
|
|
26
|
+
"@vivix-labs/ui-system": "1.0.0-beta"
|
|
27
|
+
}
|
|
6
28
|
}
|