@wasao/kagemusha 0.1.0 ā 0.1.1
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/README.md +1 -1
- package/dist/commands/capture.d.ts +1 -0
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +14 -3
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/edit.d.ts +6 -0
- package/dist/commands/edit.d.ts.map +1 -0
- package/dist/commands/edit.js +100 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +14 -16
- package/dist/commands/init.js.map +1 -1
- package/dist/editor/editor/editor.html +313 -0
- package/dist/editor/editor/inject.ts +385 -0
- package/dist/editor/editor.html +338 -0
- package/dist/editor/inject-script.cjs +398 -0
- package/dist/editor/inject-script.cjs.map +1 -0
- package/dist/editor/inject-script.d.cts +2 -0
- package/dist/editor/inject-script.d.cts.map +1 -0
- package/dist/editor/inject-script.d.ts +2 -0
- package/dist/editor/inject-script.d.ts.map +1 -0
- package/dist/editor/inject-script.js +394 -0
- package/dist/editor/inject-script.js.map +1 -0
- package/dist/editor/inject.d.ts +2 -0
- package/dist/editor/inject.d.ts.map +1 -0
- package/dist/editor/inject.js +385 -0
- package/dist/editor/inject.js.map +1 -0
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/annotate.js +1 -1
- package/dist/lib/annotate.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ When you push code, Kagemusha automatically captures screenshots of your app and
|
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
# Install
|
|
21
|
-
npm install -D kagemusha
|
|
21
|
+
npm install -D @wasao/kagemusha
|
|
22
22
|
|
|
23
23
|
# Interactive setup (generates config, discovers pages, creates workflow)
|
|
24
24
|
npx kagemusha init
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAKA,UAAU,cAAc;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAKA,UAAU,cAAc;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD3E"}
|
package/dist/commands/capture.js
CHANGED
|
@@ -18,10 +18,21 @@ export async function captureCommand(options) {
|
|
|
18
18
|
console.log(chalk.blue(`šø Capturing ${definitions.length} screenshot(s)...`));
|
|
19
19
|
const results = await captureScreenshots(config, definitions, projectRoot);
|
|
20
20
|
console.log(chalk.blue("šØ Drawing annotations..."));
|
|
21
|
-
await annotateScreenshots(definitions, results, projectRoot);
|
|
21
|
+
const annotated = await annotateScreenshots(definitions, results, projectRoot);
|
|
22
22
|
console.log(chalk.bold.green(`\nā
Done! Screenshots saved to screenshots/\n`));
|
|
23
|
-
for (const r of
|
|
24
|
-
console.log(chalk.gray(` ${r.id} ā ${r.
|
|
23
|
+
for (const r of annotated) {
|
|
24
|
+
console.log(chalk.gray(` ${r.id} ā ${r.annotatedPath}`));
|
|
25
|
+
}
|
|
26
|
+
if (options.open) {
|
|
27
|
+
const { chromium } = await import("playwright-chromium");
|
|
28
|
+
const browser = await chromium.launch({ headless: false });
|
|
29
|
+
const context = await browser.newContext();
|
|
30
|
+
for (const result of annotated) {
|
|
31
|
+
const page = await context.newPage();
|
|
32
|
+
await page.goto(`file://${result.annotatedPath}`);
|
|
33
|
+
}
|
|
34
|
+
console.log(chalk.gray("\nPress Ctrl+C to close preview.\n"));
|
|
35
|
+
await new Promise(() => { });
|
|
25
36
|
}
|
|
26
37
|
}
|
|
27
38
|
//# sourceMappingURL=capture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAQ1D,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAuB;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC;IAElE,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,IAAI,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE/C,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACxD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC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,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,CAAC;QAC9D,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":"AAMA,UAAU,WAAW;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ;AAUD,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAuHrE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { findProjectRoot, loadConfig, loadDefinitions } from "../lib/config.js";
|
|
6
|
+
const loadEditorScript = () => {
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const scriptPath = path.join(__dirname, "..", "editor", "inject-script.js");
|
|
9
|
+
return fs
|
|
10
|
+
.readFileSync(scriptPath, "utf-8")
|
|
11
|
+
.replace(/^export\s*\{\s*\};?\s*$/m, "");
|
|
12
|
+
};
|
|
13
|
+
export async function editCommand(options) {
|
|
14
|
+
console.log(chalk.bold("\nš„· Kagemusha ā Annotation Editor\n"));
|
|
15
|
+
const projectRoot = findProjectRoot();
|
|
16
|
+
const config = loadConfig(projectRoot);
|
|
17
|
+
let definitions = loadDefinitions(projectRoot);
|
|
18
|
+
if (options.id) {
|
|
19
|
+
definitions = definitions.filter((d) => d.id === options.id);
|
|
20
|
+
}
|
|
21
|
+
if (definitions.length === 0) {
|
|
22
|
+
console.log(chalk.red("No definitions found."));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (definitions.length > 1) {
|
|
26
|
+
const inquirer = await import("inquirer");
|
|
27
|
+
const { selected } = await inquirer.default.prompt({
|
|
28
|
+
type: "list",
|
|
29
|
+
name: "selected",
|
|
30
|
+
message: "Which page to edit?",
|
|
31
|
+
choices: definitions.map((d) => ({ name: d.id, value: d.id })),
|
|
32
|
+
});
|
|
33
|
+
definitions = definitions.filter((d) => d.id === selected);
|
|
34
|
+
}
|
|
35
|
+
const def = definitions[0];
|
|
36
|
+
const { chromium } = await import("playwright-chromium");
|
|
37
|
+
const browser = await chromium.launch({ headless: false });
|
|
38
|
+
const context = await browser.newContext({
|
|
39
|
+
viewport: {
|
|
40
|
+
width: config.screenshot.defaultViewport.width,
|
|
41
|
+
height: config.screenshot.defaultViewport.height,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const page = await context.newPage();
|
|
45
|
+
const urlPath = def.url.replace(/\{(\w+)\}/g, (_, key) => def.urlParams?.[key] ?? "");
|
|
46
|
+
const fullUrl = new URL(urlPath, config.app.baseUrl).toString();
|
|
47
|
+
console.log(chalk.blue(`š Opening ${fullUrl}...`));
|
|
48
|
+
await page.goto(fullUrl, { waitUntil: "networkidle" });
|
|
49
|
+
if (def.hideElements?.length) {
|
|
50
|
+
for (const selector of def.hideElements) {
|
|
51
|
+
await page.evaluate((sel) => {
|
|
52
|
+
document.querySelectorAll(sel).forEach((el) => {
|
|
53
|
+
el.style.display = "none";
|
|
54
|
+
});
|
|
55
|
+
}, selector);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Expose save function from Node.js to browser
|
|
59
|
+
const defPath = path.join(projectRoot, ".kagemusha/definitions", `${def.id}.json`);
|
|
60
|
+
let savedCount = 0;
|
|
61
|
+
let saveResolve;
|
|
62
|
+
const savePromise = new Promise((resolve) => {
|
|
63
|
+
saveResolve = resolve;
|
|
64
|
+
});
|
|
65
|
+
// Expose save function BEFORE injecting script
|
|
66
|
+
await page.exposeFunction("__kagemusha_save", (decorationsJson) => {
|
|
67
|
+
const decorations = JSON.parse(decorationsJson);
|
|
68
|
+
savedCount = decorations.length;
|
|
69
|
+
const updatedDef = { ...def, decorations };
|
|
70
|
+
fs.writeFileSync(defPath, `${JSON.stringify(updatedDef, null, 2)}\n`);
|
|
71
|
+
saveResolve();
|
|
72
|
+
});
|
|
73
|
+
// Set dpr BEFORE injecting script
|
|
74
|
+
const dpr = config.screenshot.defaultViewport.deviceScaleFactor ?? 2;
|
|
75
|
+
await page.evaluate((d) => {
|
|
76
|
+
window.__kagemusha_dpr = d;
|
|
77
|
+
}, dpr);
|
|
78
|
+
// Inject editor script and wait for it to fully load
|
|
79
|
+
const editorScript = loadEditorScript();
|
|
80
|
+
await page.evaluate(editorScript);
|
|
81
|
+
// Load existing annotations (script is now loaded)
|
|
82
|
+
if (def.decorations?.length) {
|
|
83
|
+
await page.evaluate((decs) => {
|
|
84
|
+
window.__kagemusha_loadAnnotations(decs);
|
|
85
|
+
}, def.decorations);
|
|
86
|
+
}
|
|
87
|
+
console.log(chalk.blue("šØ Editor ready. Draw annotations, then click Save.\n"));
|
|
88
|
+
// Wait for save or browser close
|
|
89
|
+
try {
|
|
90
|
+
await savePromise;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
console.log(chalk.yellow("\nā Editor closed without saving.\n"));
|
|
94
|
+
await browser.close().catch(() => { });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
await browser.close();
|
|
98
|
+
console.log(chalk.bold.green(`\nā
Saved ${savedCount} annotation(s) to ${defPath}\n`));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAA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B,OAAO,CAAC,GAAG,CACV,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,UAAU,qBAAqB,OAAO,IAAI,CAAC,CACzE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAmQjD"}
|
package/dist/commands/init.js
CHANGED
|
@@ -90,22 +90,20 @@ export async function initCommand() {
|
|
|
90
90
|
outputDir = dir;
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
cdnBucket = s3Answers.cdnBucket;
|
|
108
|
-
cdnBaseUrl = s3Answers.cdnBaseUrl;
|
|
93
|
+
const { bucket } = await inquirer.prompt({
|
|
94
|
+
type: "input",
|
|
95
|
+
name: "bucket",
|
|
96
|
+
message: "S3 bucket name:",
|
|
97
|
+
default: "kagemusha-screenshots",
|
|
98
|
+
});
|
|
99
|
+
cdnBucket = bucket;
|
|
100
|
+
const { url } = await inquirer.prompt({
|
|
101
|
+
type: "input",
|
|
102
|
+
name: "url",
|
|
103
|
+
message: "S3 public URL base:",
|
|
104
|
+
default: `https://${bucket}.s3.ap-northeast-1.amazonaws.com`,
|
|
105
|
+
});
|
|
106
|
+
cdnBaseUrl = url;
|
|
109
107
|
}
|
|
110
108
|
// Build config
|
|
111
109
|
const config = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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Q,EAAE,EAAE,CAAC;SACrB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,IAAI,MAAM,CACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Kagemusha Annotation Editor</title>
|
|
6
|
+
<style>
|
|
7
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
8
|
+
body { background: #1a1a2e; font-family: -apple-system, BlinkMacSystemFont, sans-serif; overflow: hidden; }
|
|
9
|
+
|
|
10
|
+
.toolbar {
|
|
11
|
+
position: fixed; top: 0; left: 0; right: 0; z-index: 100;
|
|
12
|
+
background: #16213e; padding: 8px 16px; display: flex; align-items: center; gap: 12px;
|
|
13
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
14
|
+
}
|
|
15
|
+
.toolbar button {
|
|
16
|
+
padding: 6px 14px; border: 1px solid #444; border-radius: 6px;
|
|
17
|
+
background: #1a1a2e; color: #fff; font-size: 13px; cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
.toolbar button:hover { background: #2a2a4e; }
|
|
20
|
+
.toolbar button.active { background: #6366f1; border-color: #6366f1; }
|
|
21
|
+
.toolbar .separator { width: 1px; height: 24px; background: #444; }
|
|
22
|
+
.toolbar .title { color: #888; font-size: 13px; margin-right: 8px; }
|
|
23
|
+
.toolbar .save-btn { background: #22c55e; border-color: #22c55e; font-weight: 600; margin-left: auto; }
|
|
24
|
+
.toolbar .save-btn:hover { background: #16a34a; }
|
|
25
|
+
|
|
26
|
+
.canvas-area {
|
|
27
|
+
margin-top: 48px; display: flex; justify-content: center; align-items: flex-start;
|
|
28
|
+
padding: 20px; height: calc(100vh - 48px); overflow: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.editor-container {
|
|
32
|
+
position: relative; cursor: crosshair;
|
|
33
|
+
}
|
|
34
|
+
.editor-container img { display: block; width: 100%; height: auto; }
|
|
35
|
+
|
|
36
|
+
.annotation { position: absolute; }
|
|
37
|
+
.annotation.selected { outline: 2px dashed #6366f1; outline-offset: 2px; }
|
|
38
|
+
|
|
39
|
+
.label-input {
|
|
40
|
+
background: none; border: none; color: inherit; font: inherit;
|
|
41
|
+
width: 100%; outline: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.hint {
|
|
45
|
+
position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
|
|
46
|
+
color: #666; font-size: 12px;
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
|
|
52
|
+
<div class="toolbar">
|
|
53
|
+
<span class="title">š„· Annotation Editor</span>
|
|
54
|
+
<button id="tool-rect" class="active" onclick="setTool('rect')">ā Rectangle</button>
|
|
55
|
+
<button id="tool-arrow" onclick="setTool('arrow')">ā Arrow</button>
|
|
56
|
+
<button id="tool-label" onclick="setTool('label')">T Label</button>
|
|
57
|
+
<div class="separator"></div>
|
|
58
|
+
<button onclick="deleteSelected()">š Delete</button>
|
|
59
|
+
<button class="save-btn" onclick="save()">š¾ Save</button>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="canvas-area">
|
|
63
|
+
<div class="editor-container" id="editor">
|
|
64
|
+
<img id="screenshot" />
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="hint">Click and drag to add annotations. Click to select. Press Delete to remove.</div>
|
|
69
|
+
|
|
70
|
+
<script>
|
|
71
|
+
let tool = 'rect';
|
|
72
|
+
let annotations = [];
|
|
73
|
+
let selectedId = null;
|
|
74
|
+
let dragState = null;
|
|
75
|
+
let nextId = 1;
|
|
76
|
+
|
|
77
|
+
const editor = document.getElementById('editor');
|
|
78
|
+
const img = document.getElementById('screenshot');
|
|
79
|
+
|
|
80
|
+
// Mouse position relative to the editor container (in CSS px, matches display)
|
|
81
|
+
function getPos(e) {
|
|
82
|
+
const r = editor.getBoundingClientRect();
|
|
83
|
+
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Ratio to convert display px ā image natural px (for saving)
|
|
87
|
+
function getScale() {
|
|
88
|
+
return img.naturalWidth / editor.getBoundingClientRect().width;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
window.initEditor = (screenshotDataUrl, existingDecorations) => {
|
|
92
|
+
img.src = screenshotDataUrl;
|
|
93
|
+
img.onload = () => {
|
|
94
|
+
// Set editor width to fit window
|
|
95
|
+
const maxW = window.innerWidth - 80;
|
|
96
|
+
const maxH = window.innerHeight - 108;
|
|
97
|
+
const ratio = img.naturalWidth / img.naturalHeight;
|
|
98
|
+
let w = maxW;
|
|
99
|
+
if (w / ratio > maxH) w = maxH * ratio;
|
|
100
|
+
editor.style.width = w + 'px';
|
|
101
|
+
|
|
102
|
+
if (existingDecorations) {
|
|
103
|
+
existingDecorations.forEach(d => addFromDecoration(d));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
function setTool(t) {
|
|
109
|
+
tool = t;
|
|
110
|
+
document.querySelectorAll('.toolbar button').forEach(b => b.classList.remove('active'));
|
|
111
|
+
document.getElementById('tool-' + t)?.classList.add('active');
|
|
112
|
+
deselectAll();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function deselectAll() {
|
|
116
|
+
selectedId = null;
|
|
117
|
+
document.querySelectorAll('.annotation').forEach(el => el.classList.remove('selected'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function selectEl(el) {
|
|
121
|
+
deselectAll();
|
|
122
|
+
selectedId = parseInt(el.dataset.id);
|
|
123
|
+
el.classList.add('selected');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function deleteSelected() {
|
|
127
|
+
if (!selectedId) return;
|
|
128
|
+
const el = document.querySelector(`[data-id="${selectedId}"]`);
|
|
129
|
+
if (el) el.remove();
|
|
130
|
+
annotations = annotations.filter(a => a.id !== selectedId);
|
|
131
|
+
selectedId = null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
document.addEventListener('keydown', e => {
|
|
135
|
+
if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
136
|
+
if (document.activeElement.classList?.contains('label-input')) return;
|
|
137
|
+
deleteSelected();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// --- CREATE ---
|
|
142
|
+
editor.addEventListener('mousedown', e => {
|
|
143
|
+
if (e.target.closest('.annotation')) return;
|
|
144
|
+
const p = getPos(e);
|
|
145
|
+
deselectAll();
|
|
146
|
+
|
|
147
|
+
if (tool === 'rect') {
|
|
148
|
+
const id = nextId++;
|
|
149
|
+
const el = makeRect(id, p.x, p.y, 0, 0);
|
|
150
|
+
editor.appendChild(el);
|
|
151
|
+
dragState = { type: 'create-rect', id, el, sx: p.x, sy: p.y };
|
|
152
|
+
} else if (tool === 'arrow') {
|
|
153
|
+
const id = nextId++;
|
|
154
|
+
const el = makeArrow(id, p.x, p.y, p.x, p.y);
|
|
155
|
+
editor.appendChild(el);
|
|
156
|
+
dragState = { type: 'create-arrow', id, el, sx: p.x, sy: p.y };
|
|
157
|
+
} else if (tool === 'label') {
|
|
158
|
+
const id = nextId++;
|
|
159
|
+
annotations.push({ id, type: 'label', x: p.x, y: p.y, text: 'Label' });
|
|
160
|
+
const el = makeLabel(id, p.x, p.y, 'Label');
|
|
161
|
+
editor.appendChild(el);
|
|
162
|
+
selectEl(el);
|
|
163
|
+
el.querySelector('.label-input').focus();
|
|
164
|
+
el.querySelector('.label-input').select();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
document.addEventListener('mousemove', e => {
|
|
169
|
+
if (!dragState) return;
|
|
170
|
+
const p = getPos(e);
|
|
171
|
+
|
|
172
|
+
if (dragState.type === 'create-rect') {
|
|
173
|
+
const el = dragState.el;
|
|
174
|
+
const w = p.x - dragState.sx;
|
|
175
|
+
const h = p.y - dragState.sy;
|
|
176
|
+
el.style.left = (w > 0 ? dragState.sx : p.x) + 'px';
|
|
177
|
+
el.style.top = (h > 0 ? dragState.sy : p.y) + 'px';
|
|
178
|
+
el.style.width = Math.abs(w) + 'px';
|
|
179
|
+
el.style.height = Math.abs(h) + 'px';
|
|
180
|
+
} else if (dragState.type === 'create-arrow') {
|
|
181
|
+
updateArrow(dragState.el, dragState.sx, dragState.sy, p.x, p.y);
|
|
182
|
+
} else if (dragState.type === 'move') {
|
|
183
|
+
const a = annotations.find(a => a.id === dragState.id);
|
|
184
|
+
if (!a) return;
|
|
185
|
+
a.x = p.x - dragState.ox;
|
|
186
|
+
a.y = p.y - dragState.oy;
|
|
187
|
+
dragState.el.style.left = a.x + 'px';
|
|
188
|
+
dragState.el.style.top = a.y + 'px';
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
document.addEventListener('mouseup', e => {
|
|
193
|
+
if (!dragState) return;
|
|
194
|
+
const p = getPos(e);
|
|
195
|
+
|
|
196
|
+
if (dragState.type === 'create-rect') {
|
|
197
|
+
const w = Math.abs(p.x - dragState.sx);
|
|
198
|
+
const h = Math.abs(p.y - dragState.sy);
|
|
199
|
+
if (w < 5 && h < 5) { dragState.el.remove(); }
|
|
200
|
+
else {
|
|
201
|
+
const a = { id: dragState.id, type: 'rect', x: Math.min(dragState.sx, p.x), y: Math.min(dragState.sy, p.y), width: w, height: h };
|
|
202
|
+
annotations.push(a);
|
|
203
|
+
selectEl(dragState.el);
|
|
204
|
+
}
|
|
205
|
+
} else if (dragState.type === 'create-arrow') {
|
|
206
|
+
const dist = Math.hypot(p.x - dragState.sx, p.y - dragState.sy);
|
|
207
|
+
if (dist < 5) { dragState.el.remove(); }
|
|
208
|
+
else {
|
|
209
|
+
annotations.push({ id: dragState.id, type: 'arrow', fromX: dragState.sx, fromY: dragState.sy, toX: p.x, toY: p.y });
|
|
210
|
+
selectEl(dragState.el);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
dragState = null;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// --- ELEMENTS ---
|
|
217
|
+
function makeRect(id, x, y, w, h) {
|
|
218
|
+
const el = document.createElement('div');
|
|
219
|
+
el.className = 'annotation'; el.dataset.id = id;
|
|
220
|
+
el.style.cssText = `left:${x}px;top:${y}px;width:${w}px;height:${h}px;border:2px solid #FF0000;border-radius:4px;`;
|
|
221
|
+
el.addEventListener('mousedown', e => {
|
|
222
|
+
e.stopPropagation();
|
|
223
|
+
selectEl(el);
|
|
224
|
+
const a = annotations.find(a => a.id === parseInt(el.dataset.id));
|
|
225
|
+
if (a) {
|
|
226
|
+
const pp = getPos(e);
|
|
227
|
+
dragState = { type: 'move', id: a.id, el, ox: pp.x - a.x, oy: pp.y - a.y };
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return el;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function makeArrow(id, x1, y1, x2, y2) {
|
|
234
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
235
|
+
svg.classList.add('annotation'); svg.dataset.id = id;
|
|
236
|
+
svg.style.cssText = 'position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;';
|
|
237
|
+
svg.innerHTML = `
|
|
238
|
+
<defs><marker id="ah-${id}" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto" fill="#FF0000">
|
|
239
|
+
<polygon points="0 0, 10 3.5, 0 7"/></marker></defs>
|
|
240
|
+
<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="#FF0000" stroke-width="2" marker-end="url(#ah-${id})" style="pointer-events:stroke;cursor:pointer;" />`;
|
|
241
|
+
svg.querySelector('line').addEventListener('mousedown', e => {
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
selectEl(svg);
|
|
244
|
+
});
|
|
245
|
+
return svg;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function updateArrow(svg, x1, y1, x2, y2) {
|
|
249
|
+
const line = svg.querySelector('line');
|
|
250
|
+
line.setAttribute('x1', x1); line.setAttribute('y1', y1);
|
|
251
|
+
line.setAttribute('x2', x2); line.setAttribute('y2', y2);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function makeLabel(id, x, y, text) {
|
|
255
|
+
const el = document.createElement('div');
|
|
256
|
+
el.className = 'annotation'; el.dataset.id = id;
|
|
257
|
+
el.style.cssText = `left:${x}px;top:${y}px;padding:4px 8px;background:#fff;border:1px solid #FF0000;border-radius:4px;color:#FF0000;font-size:14px;min-width:40px;`;
|
|
258
|
+
el.innerHTML = `<input class="label-input" value="${text}" style="color:#FF0000;font-size:14px;" />`;
|
|
259
|
+
el.querySelector('.label-input').addEventListener('input', e => {
|
|
260
|
+
const a = annotations.find(a => a.id === parseInt(el.dataset.id));
|
|
261
|
+
if (a) a.text = e.target.value;
|
|
262
|
+
});
|
|
263
|
+
el.addEventListener('mousedown', e => {
|
|
264
|
+
if (e.target.classList.contains('label-input')) return;
|
|
265
|
+
e.stopPropagation();
|
|
266
|
+
selectEl(el);
|
|
267
|
+
const a = annotations.find(a => a.id === parseInt(el.dataset.id));
|
|
268
|
+
if (a) {
|
|
269
|
+
const pp = getPos(e);
|
|
270
|
+
dragState = { type: 'move', id: a.id, el, ox: pp.x - a.x, oy: pp.y - a.y };
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return el;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// --- LOAD EXISTING ---
|
|
277
|
+
function addFromDecoration(d) {
|
|
278
|
+
const id = nextId++;
|
|
279
|
+
const s = getScale();
|
|
280
|
+
if (d.type === 'rect' && d.target && 'x' in d.target) {
|
|
281
|
+
const a = { id, type: 'rect', x: d.target.x/s, y: d.target.y/s, width: d.target.width/s, height: d.target.height/s };
|
|
282
|
+
annotations.push(a);
|
|
283
|
+
editor.appendChild(makeRect(id, a.x, a.y, a.width, a.height));
|
|
284
|
+
} else if (d.type === 'arrow' && 'x' in d.from && 'x' in d.to) {
|
|
285
|
+
const a = { id, type: 'arrow', fromX: d.from.x/s, fromY: d.from.y/s, toX: d.to.x/s, toY: d.to.y/s };
|
|
286
|
+
annotations.push(a);
|
|
287
|
+
editor.appendChild(makeArrow(id, a.fromX, a.fromY, a.toX, a.toY));
|
|
288
|
+
} else if (d.type === 'label' && 'x' in d.position) {
|
|
289
|
+
const a = { id, type: 'label', x: d.position.x/s, y: d.position.y/s, text: d.text };
|
|
290
|
+
annotations.push(a);
|
|
291
|
+
editor.appendChild(makeLabel(id, a.x, a.y, a.text));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// --- SAVE ---
|
|
296
|
+
function save() {
|
|
297
|
+
const s = getScale();
|
|
298
|
+
const decorations = annotations.map(a => {
|
|
299
|
+
if (a.type === 'rect') {
|
|
300
|
+
return { type: 'rect', target: { x: Math.round(a.x*s), y: Math.round(a.y*s), width: Math.round(a.width*s), height: Math.round(a.height*s) }, style: { color: '#FF0000', strokeWidth: 2 } };
|
|
301
|
+
} else if (a.type === 'arrow') {
|
|
302
|
+
return { type: 'arrow', from: { x: Math.round(a.fromX*s), y: Math.round(a.fromY*s) }, to: { x: Math.round(a.toX*s), y: Math.round(a.toY*s) }, style: { color: '#FF0000', strokeWidth: 2 } };
|
|
303
|
+
} else if (a.type === 'label') {
|
|
304
|
+
return { type: 'label', text: a.text, position: { x: Math.round(a.x*s), y: Math.round(a.y*s) }, style: { fontSize: 14, color: '#FF0000', background: '#FFFFFF' } };
|
|
305
|
+
}
|
|
306
|
+
}).filter(Boolean);
|
|
307
|
+
|
|
308
|
+
window.__SAVED_DECORATIONS__ = decorations;
|
|
309
|
+
document.title = 'SAVED';
|
|
310
|
+
}
|
|
311
|
+
</script>
|
|
312
|
+
</body>
|
|
313
|
+
</html>
|