Update pages.html
Browse files- pages.html +87 -4
pages.html
CHANGED
|
@@ -1191,10 +1191,24 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
|
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1195 |
|
| 1196 |
|
| 1197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1198 |
<script type="text/javascript">
|
| 1199 |
var editor = grapesjs.init({
|
| 1200 |
container: '#gjs',
|
|
@@ -1315,8 +1329,6 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
|
|
| 1315 |
}
|
| 1316 |
}
|
| 1317 |
});
|
| 1318 |
-
</script>
|
| 1319 |
-
<script>
|
| 1320 |
|
| 1321 |
// Добавляем кнопку линейки в верхнюю панель инструментов с использованием SVG-иконки
|
| 1322 |
editor.Panels.addButton('options', {
|
|
@@ -1328,11 +1340,82 @@ z-index: 1000; /* Убедитесь, что кнопка находится п
|
|
| 1328 |
command: 'ruler-visibility', // Команда для переключения видимости линеек
|
| 1329 |
attributes: { title: 'Toggle Rulers' }
|
| 1330 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1331 |
</script>
|
| 1332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1333 |
<script type="text/javascript" src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/rus/rus.js"></script>
|
| 1334 |
|
| 1335 |
|
|
|
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
|
|
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
+
<style>
|
| 1195 |
+
/* Ваши стили */
|
| 1196 |
+
#grabbed-info {
|
| 1197 |
+
position: fixed;
|
| 1198 |
+
background-color: #fff;
|
| 1199 |
+
border: 1px solid #ccc;
|
| 1200 |
+
padding: 10px;
|
| 1201 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 1202 |
+
z-index: 1000;
|
| 1203 |
+
}
|
| 1204 |
+
</style>
|
| 1205 |
|
| 1206 |
|
| 1207 |
+
<div id="grabbed-info"></div>
|
| 1208 |
+
|
| 1209 |
+
|
| 1210 |
+
<script src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/per.js"></script>
|
| 1211 |
+
|
| 1212 |
<script type="text/javascript">
|
| 1213 |
var editor = grapesjs.init({
|
| 1214 |
container: '#gjs',
|
|
|
|
| 1329 |
}
|
| 1330 |
}
|
| 1331 |
});
|
|
|
|
|
|
|
| 1332 |
|
| 1333 |
// Добавляем кнопку линейки в верхнюю панель инструментов с использованием SVG-иконки
|
| 1334 |
editor.Panels.addButton('options', {
|
|
|
|
| 1340 |
command: 'ruler-visibility', // Команда для переключения видимости линеек
|
| 1341 |
attributes: { title: 'Toggle Rulers' }
|
| 1342 |
});
|
| 1343 |
+
|
| 1344 |
+
// Функция для обновления информации о положении элемента
|
| 1345 |
+
function updatePositionInfo(component) {
|
| 1346 |
+
const positionInfo = document.getElementById('position-info');
|
| 1347 |
+
if (component) {
|
| 1348 |
+
const { x, y, width, height } = component.getBoundingRect();
|
| 1349 |
+
const { width: canvasWidth, height: canvasHeight } = editor.Canvas.getCanvasElement().getBoundingClientRect();
|
| 1350 |
+
const xPercent = (x / canvasWidth * 100).toFixed(2);
|
| 1351 |
+
const yPercent = (y / canvasHeight * 100).toFixed(2);
|
| 1352 |
+
positionInfo.textContent = `Position: X: ${x}px (${xPercent}%), Y: ${y}px (${yPercent}%), Width: ${width}px, Height: ${height}px`;
|
| 1353 |
+
} else {
|
| 1354 |
+
positionInfo.textContent = 'Position: ';
|
| 1355 |
+
}
|
| 1356 |
+
}
|
| 1357 |
+
|
| 1358 |
+
// Подписываемся на события перетаскивания и выбора элемента
|
| 1359 |
+
editor.on('component:drag:start', (component) => {
|
| 1360 |
+
updatePositionInfo(component);
|
| 1361 |
+
});
|
| 1362 |
+
|
| 1363 |
+
editor.on('component:drag', (component) => {
|
| 1364 |
+
updatePositionInfo(component);
|
| 1365 |
+
});
|
| 1366 |
+
|
| 1367 |
+
editor.on('component:drag:stop', (component) => {
|
| 1368 |
+
updatePositionInfo(component);
|
| 1369 |
+
});
|
| 1370 |
+
|
| 1371 |
+
editor.on('component:selected', (component) => {
|
| 1372 |
+
updatePositionInfo(component);
|
| 1373 |
+
});
|
| 1374 |
+
|
| 1375 |
+
// Добавляем обработчики событий для перемещения элементов
|
| 1376 |
+
let isDragging = false;
|
| 1377 |
+
let offsetX = 0;
|
| 1378 |
+
let offsetY = 0;
|
| 1379 |
+
let selectedComponent: Component | null = null;
|
| 1380 |
+
|
| 1381 |
+
function startDrag(e: MouseEvent, component: Component) {
|
| 1382 |
+
isDragging = true;
|
| 1383 |
+
selectedComponent = component;
|
| 1384 |
+
const rect = component.getEl().getBoundingClientRect();
|
| 1385 |
+
offsetX = e.clientX - rect.left;
|
| 1386 |
+
offsetY = e.clientY - rect.top;
|
| 1387 |
+
document.addEventListener('mousemove', drag);
|
| 1388 |
+
document.addEventListener('mouseup', stopDrag);
|
| 1389 |
+
}
|
| 1390 |
+
|
| 1391 |
+
function drag(e: MouseEvent) {
|
| 1392 |
+
if (!isDragging || !selectedComponent) return;
|
| 1393 |
+
const newX = e.clientX - offsetX;
|
| 1394 |
+
const newY = e.clientY - offsetY;
|
| 1395 |
+
selectedComponent.set('position', { x: newX, y: newY });
|
| 1396 |
+
}
|
| 1397 |
+
|
| 1398 |
+
function stopDrag() {
|
| 1399 |
+
isDragging = false;
|
| 1400 |
+
selectedComponent = null;
|
| 1401 |
+
document.removeEventListener('mousemove', drag);
|
| 1402 |
+
document.removeEventListener('mouseup', stopDrag);
|
| 1403 |
+
}
|
| 1404 |
+
|
| 1405 |
+
editor.on('component:selected', (component: Component) => {
|
| 1406 |
+
component.getEl().addEventListener('mousedown', (e: MouseEvent) => startDrag(e, component));
|
| 1407 |
+
});
|
| 1408 |
</script>
|
| 1409 |
|
| 1410 |
+
|
| 1411 |
+
|
| 1412 |
+
|
| 1413 |
+
|
| 1414 |
+
|
| 1415 |
<script type="text/javascript" src="https://huggingface.co/spaces/DMTuit/psy_vk/resolve/main/js/rus/rus.js"></script>
|
| 1416 |
|
| 1417 |
|
| 1418 |
+
|
| 1419 |
|
| 1420 |
|
| 1421 |
|