-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-placement-drag-manager.html
More file actions
200 lines (178 loc) · 7.21 KB
/
test-placement-drag-manager.html
File metadata and controls
200 lines (178 loc) · 7.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PlacementDragManager テスト</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: Arial, sans-serif;
background: #f0f0f0;
}
.container {
display: flex;
gap: 20px;
height: 80vh;
}
.palette {
width: 200px;
background: #fff;
border: 2px solid #ccc;
padding: 10px;
border-radius: 8px;
}
.palette h3 {
margin: 0 0 10px 0;
color: #333;
}
.plugin-item {
background: #4CAF50;
color: white;
padding: 8px;
margin: 5px 0;
border-radius: 4px;
cursor: grab;
user-select: none;
}
.plugin-item:active {
cursor: grabbing;
}
.canvas {
flex: 1;
background: #fff;
border: 2px dashed #ccc;
border-radius: 8px;
position: relative;
min-height: 400px;
}
.canvas.drag-over {
border-color: #4CAF50;
background: #f9fff9;
}
.status {
position: fixed;
top: 10px;
right: 10px;
background: #333;
color: white;
padding: 10px;
border-radius: 4px;
font-size: 12px;
max-width: 300px;
}
.plugin-instance {
position: absolute;
background: #2196F3;
color: white;
padding: 10px;
border-radius: 4px;
border: 1px solid #1976D2;
cursor: move;
}
</style>
</head>
<body>
<h1>🏗️ PlacementDragManager テスト</h1>
<div class="status" id="status">
初期化中...
</div>
<div class="container">
<div class="palette">
<h3>プラグインパレット</h3>
<div class="plugin-item" draggable="true" data-plugin-type="text-note">
📝 Text Note
</div>
<div class="plugin-item" draggable="true" data-plugin-type="button-send">
🔲 Button
</div>
<div class="plugin-item" draggable="true" data-plugin-type="input-text">
📄 Input Text
</div>
<div class="plugin-item" draggable="true" data-plugin-type="output-console">
🖥️ Console
</div>
</div>
<div class="canvas" id="canvas">
<!-- プラグインがここに配置される -->
</div>
</div>
<script type="module">
import { PlacementDragManager } from './charmflow_v3/js/ui-components/placement-drag-manager.js';
// 🎯 テスト用のシンプルなNyaCoreUI模擬
class MockNyaCoreUI {
constructor() {
this.pluginCount = 0;
}
createUIPlugin(pluginType, position) {
console.log(`🏗️ MockNyaCoreUI: Creating plugin ${pluginType} at`, position);
// DOM要素を作成してキャンバスに追加
const canvas = document.getElementById('canvas');
const pluginElement = document.createElement('div');
pluginElement.className = 'plugin-instance';
pluginElement.style.left = position.x + 'px';
pluginElement.style.top = position.y + 'px';
pluginElement.textContent = `${pluginType} #${++this.pluginCount}`;
pluginElement.id = `plugin-${this.pluginCount}`;
canvas.appendChild(pluginElement);
this.updateStatus(`✅ プラグイン作成成功: ${pluginType} at (${position.x}, ${position.y})`);
return pluginElement;
}
log(message) {
console.log('[MockNyaCoreUI]', message);
}
updateStatus(message) {
const status = document.getElementById('status');
status.textContent = message;
setTimeout(() => {
status.textContent = `PlacementDragManager テスト実行中... (プラグイン数: ${this.pluginCount})`;
}, 3000);
}
}
// 🚀 テスト実行
async function runTest() {
try {
const mockNyaCoreUI = new MockNyaCoreUI();
const canvas = document.getElementById('canvas');
// PlacementDragManagerを初期化
const placementDragManager = new PlacementDragManager(mockNyaCoreUI, canvas);
// パレットのドラッグイベントを設定
const paletteItems = document.querySelectorAll('.plugin-item');
paletteItems.forEach(item => {
item.addEventListener('dragstart', (e) => {
const pluginType = item.dataset.pluginType;
console.log(`🎨 Drag start: ${pluginType}`);
// データ転送を設定
e.dataTransfer.setData('text/plain', pluginType);
e.dataTransfer.setData('application/json', JSON.stringify({
type: pluginType,
timestamp: Date.now()
}));
mockNyaCoreUI.updateStatus(`🖱️ ドラッグ開始: ${pluginType}`);
});
});
// キャンバスの視覚的フィードバック
canvas.addEventListener('dragenter', (e) => {
e.preventDefault();
canvas.classList.add('drag-over');
});
canvas.addEventListener('dragleave', (e) => {
e.preventDefault();
canvas.classList.remove('drag-over');
});
// グローバル参照(デバッグ用)
window.placementDragManager = placementDragManager;
window.mockNyaCoreUI = mockNyaCoreUI;
mockNyaCoreUI.updateStatus('✅ PlacementDragManager 初期化完了 - ドラッグ&ドロップテスト可能');
console.log('✅ PlacementDragManager test setup completed');
} catch (error) {
console.error('❌ Test setup failed:', error);
document.getElementById('status').textContent = `❌ エラー: ${error.message}`;
}
}
// ページ読み込み後にテスト実行
runTest();
</script>
</body>
</html>