Skip to content

Commit 3235af1

Browse files
committed
refactor: clean up, fix editor toolbar
1 parent 1b5a426 commit 3235af1

8 files changed

Lines changed: 31 additions & 78 deletions

File tree

LICENSE

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
The MIT License
2-
Copyright 2024 Yoshiya Hinosawa ( @kt3k )
32

4-
Permission is hereby granted, free of charge, to any person obtaining a copy
5-
of this software and associated documentation files (the "Software"), to deal
6-
in the Software without restriction, including without limitation the rights
7-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the Software is
9-
furnished to do so, subject to the following conditions:
3+
Copyright 2024-2026 Yoshiya Hinosawa ( @kt3k )
104

11-
The above copyright notice and this permission notice shall be included in
12-
all copies or substantial portions of the Software.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1314

1415
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20-
THE SOFTWARE.
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

editor/.vscode/launch.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

editor/.vscode/settings.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

editor/.vscode/tasks.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

editor/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

editor/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"tasks": {
1313
"compile": "deno task extension && deno task webview && deno task webview-style",
1414
"extension": "deno -A jsr:@kt3k/pack@0.1.14 extension.tsx -o out/extension.js --external vscode --format cjs",
15-
"webview": "deno -A jsr:@kt3k/pack@0.1.14 webview.tsx -o out/webview.js",
15+
"webview": "deno -A jsr:@kt3k/pack@0.1.14 editor.tsx -o out/editor.js",
1616
"webview-style": "deno -A npm:tailwindcss@3 -o out/style.css",
1717
"package": "deno task compile && deno -A --unstable-unsafe-proto npm:@vscode/vsce package",
1818
"update-package": "deno task package && code --install-extension vscode-bw-block-editor-0.4.0.vsix"
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class ToolManager {
215215
0,
216216
tool.type as any,
217217
tool.def,
218+
null,
218219
)
219220
}
220221

@@ -375,7 +376,7 @@ function createCanvasFromImageData(imageData: ImageData) {
375376
const canvas = ht.canvas({
376377
width: imageData.width,
377378
height: imageData.height,
378-
class: "absolute top-0 left-0",
379+
class: "absolute top-0 left-0 crisp-edges",
379380
})
380381
const ctx = canvas.getContext("2d")!
381382
ctx.putImageData(imageData, 0, 0)
@@ -395,7 +396,7 @@ async function CanvasLayers({ el }: Context) {
395396
cellsCanvas.style.left = SIDE_CANVAS_SIZE + "px"
396397
cellsCanvas.style.top = SIDE_CANVAS_SIZE + "px"
397398
cellsCanvas.style.position = "absolute"
398-
cellsCanvas.classList.add("field-cells-canvas")
399+
cellsCanvas.classList.add("field-cells-canvas", "crisp-edges")
399400
el.appendChild(cellsCanvas)
400401
block.renderAll()
401402
mount("field-cells-canvas", el)
@@ -404,7 +405,7 @@ async function CanvasLayers({ el }: Context) {
404405
width: CANVAS_SIZE,
405406
height: CANVAS_SIZE,
406407
style: `left: ${SIDE_CANVAS_SIZE}px; top: ${SIDE_CANVAS_SIZE}px;`,
407-
class: "absolute field-objects-canvas pointer-events-none",
408+
class: "absolute field-objects-canvas pointer-events-none crisp-edges",
408409
})
409410
el.appendChild(objectsCanvas)
410411
mount("field-objects-canvas", el)

editor/extension.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ function resolveCustomTextEditor(
3232
<meta charset="UTF-8" />
3333
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
3434
<link href={u("out/style.css")} rel="stylesheet" />
35+
<style>
36+
{`
37+
.crisp-edges {
38+
image-rendering: pixelated;
39+
image-rendering: crisp-edges;
40+
}
41+
`}
42+
</style>
3543
</head>
3644
<body class="key-handler p-0">
37-
<div class="canvas-layers relative mt-10 w-[calc(3360px+196px)]"></div>
38-
<div class="toolbox h-10 px-2 fixed left-0 top-0 flex items-center bg-neutral-900/50 w-[calc(100%-12rem)]">
45+
<div class="canvas-layers relative mt-20 w-[calc(3360px+196px)]"></div>
46+
<div class="toolbox px-2 fixed left-0 top-0 flex flex-wrap items-center bg-neutral-900/50 w-[calc(100%-12rem)]">
3947
<div class="ml-2 group relative">
4048
<span class="mode-indicator">dot</span>
4149
<span class="
@@ -71,7 +79,7 @@ function resolveCustomTextEditor(
7179
</div>
7280
</div>
7381
</div>
74-
<script src={u("out/webview.js")} type="module"></script>
82+
<script src={u("out/editor.js")} type="module"></script>
7583
</body>
7684
</html>
7785
)

0 commit comments

Comments
 (0)