not bad already
This commit is contained in:
@@ -17,8 +17,8 @@ Funkcjonalności aplikacji koncentrują się na tworzeniu i modyfikacji kształt
|
|||||||
- [x] 5. Przeciągnięcie kzstałtu po planszy
|
- [x] 5. Przeciągnięcie kzstałtu po planszy
|
||||||
- [x] 6. Usunięcie kształtu
|
- [x] 6. Usunięcie kształtu
|
||||||
- [x] 7. Zaznaczenie kształtu
|
- [x] 7. Zaznaczenie kształtu
|
||||||
- [ ] 8. Kopiowanie kształtu
|
- [x] 8. Kopiowanie kształtu
|
||||||
- [ ] 9. Wklejanie kształtu
|
- [x] 9. Wklejanie kształtu
|
||||||
- [ ] 10. Zmiana kolorów kształtów
|
- [ ] 10. Zmiana kolorów kształtów
|
||||||
- [ ] 11. Połączenie kształtów (strzałka ->)
|
- [ ] 11. Połączenie kształtów (strzałka ->)
|
||||||
- [ ] 12. Usunięcie kształtów
|
- [ ] 12. Usunięcie kształtów
|
||||||
|
|||||||
93
index.html
93
index.html
@@ -18,6 +18,12 @@
|
|||||||
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
||||||
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
||||||
</div>
|
</div>
|
||||||
|
<p>Akcje</p>
|
||||||
|
<div class="tools-wrapper toolbar-wrapper">
|
||||||
|
<button id="btn-delete">Usuń</button>
|
||||||
|
<button id="btn-copy">Kopiuj</button>
|
||||||
|
<button id="btn-paste">Wklej</button>
|
||||||
|
</div>
|
||||||
<p>Zoom</p>
|
<p>Zoom</p>
|
||||||
<div class="zoom-wrapper toolbar-wrapper">
|
<div class="zoom-wrapper toolbar-wrapper">
|
||||||
<button id="zoom-in">+</button>
|
<button id="zoom-in">+</button>
|
||||||
@@ -34,6 +40,8 @@
|
|||||||
<script>
|
<script>
|
||||||
let selectedElement = null;
|
let selectedElement = null;
|
||||||
let activeElementView = null;
|
let activeElementView = null;
|
||||||
|
let clipboard = null;
|
||||||
|
let zoomLevel = 1.0;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
//init paper - Start
|
//init paper - Start
|
||||||
@@ -202,6 +210,74 @@
|
|||||||
});
|
});
|
||||||
//init draggable - END
|
//init draggable - END
|
||||||
|
|
||||||
|
function updateStatus(message) {
|
||||||
|
$('#status').text(message + ' | Zoom: ' + Math.round(zoomLevel * 100) + '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getViewportCenter() {
|
||||||
|
const container = $('.canvas-container');
|
||||||
|
const scale = paper.scale();
|
||||||
|
const translate = paper.translate();
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: (container.width() / 2 - translate.tx) / scale.sx,
|
||||||
|
y: (container.height() / 2 - translate.ty) / scale.sy
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyShape() {
|
||||||
|
if (selectedElement) {
|
||||||
|
clipboard = selectedElement.clone();
|
||||||
|
updateStatus('Skopiowano element');
|
||||||
|
} else {
|
||||||
|
updateStatus('Brak zaznaczonego elementu');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pasteShape() {
|
||||||
|
if (clipboard) {
|
||||||
|
const center = getViewportCenter();
|
||||||
|
const pasted = clipboard.clone();
|
||||||
|
pasted.position(center.x + 20, center.y + 20);
|
||||||
|
graph.addCell(pasted);
|
||||||
|
|
||||||
|
const pastedView = pasted.findView(paper);
|
||||||
|
if (pastedView) {
|
||||||
|
pastedView.addTools(createToolsView());
|
||||||
|
pastedView.showTools();
|
||||||
|
|
||||||
|
if (activeElementView && activeElementView !== pastedView) {
|
||||||
|
activeElementView.hideTools();
|
||||||
|
}
|
||||||
|
activeElementView = pastedView;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedElement = pasted;
|
||||||
|
updateStatus('Wklejono element');
|
||||||
|
} else {
|
||||||
|
updateStatus('Brak elementu w schowku');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteShape() {
|
||||||
|
selectedElement.remove();
|
||||||
|
selectedElement = null;
|
||||||
|
updateStatus('Usunięto element');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#btn-delete').click(function() {
|
||||||
|
deleteShape()
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btn-copy').click(function() {
|
||||||
|
copyShape();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#btn-paste').click(function() {
|
||||||
|
pasteShape();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
paper.on('element:pointerclick', function (elementView) {
|
paper.on('element:pointerclick', function (elementView) {
|
||||||
if (activeElementView && activeElementView !== elementView) {
|
if (activeElementView && activeElementView !== elementView) {
|
||||||
activeElementView.hideTools();
|
activeElementView.hideTools();
|
||||||
@@ -261,11 +337,20 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('keydown', function (e) {
|
$(document).on('keydown', function (e) {
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'c') {
|
||||||
|
e.preventDefault();
|
||||||
|
copyShape();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'v') {
|
||||||
|
e.preventDefault();
|
||||||
|
pasteShape();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.key === 'Delete' && selectedElement) {
|
if (e.key === 'Delete' && selectedElement) {
|
||||||
// if (selectedElement.attributes.type === 'standard.TextBlock') {
|
deleteShape();
|
||||||
selectedElement.remove();
|
|
||||||
selectedElement = null;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//add text to text block - END
|
//add text to text block - END
|
||||||
|
|||||||
239
style.css
239
style.css
@@ -4,17 +4,78 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
background: #f5f5f5;
|
||||||
|
min-height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
background: #ffffff;
|
||||||
|
color: #333;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
|
||||||
|
position: absolute;
|
||||||
|
width: 280px;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 9;
|
||||||
|
overflow-y: auto;
|
||||||
|
border-right: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar p {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 2px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-wrapper {
|
||||||
|
background: #f9f9f9;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
.shape-wrapper {
|
.shape-wrapper {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
flex-wrap: wrap;
|
||||||
grid-template-rows: repeat(2, auto);
|
gap: 10px;
|
||||||
gap: 30px 10px;
|
padding: 12px;
|
||||||
padding-bottom: 40px;
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shape {
|
||||||
|
background: #fff;
|
||||||
|
border: 2px solid #d0d0d0;
|
||||||
|
cursor: grab;
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shape:hover {
|
||||||
|
border-color: #666;
|
||||||
|
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shape:active {
|
||||||
|
cursor: grabbing;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#shape-rectangle {
|
#shape-rectangle {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#shape-ellipse {
|
#shape-ellipse {
|
||||||
@@ -27,90 +88,168 @@
|
|||||||
height: 48px;
|
height: 48px;
|
||||||
width: 48px;
|
width: 48px;
|
||||||
transform: rotate(45deg) translateX(15px);
|
transform: rotate(45deg) translateX(15px);
|
||||||
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#shape-text {
|
#shape-text {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
border-style: dashed;
|
border-style: dashed;
|
||||||
color: #ffffff;
|
border-radius: 4px;
|
||||||
font-size: 14px;
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shape {
|
/* Tools wrapper */
|
||||||
background: transparent;
|
.tools-wrapper {
|
||||||
border: 1px solid white;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
|
||||||
background: #3498db;
|
|
||||||
color: white;
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 8px;
|
||||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
padding: 0;
|
||||||
position: absolute;
|
|
||||||
width: 300px;
|
|
||||||
left: 0px;
|
|
||||||
top: 0px;
|
|
||||||
height: 100vh;
|
|
||||||
z-index: 9;
|
|
||||||
border-top-right-radius: 30px;
|
|
||||||
border-bottom-right-radius: 30px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbar-wrapper {
|
.tools-wrapper button {
|
||||||
padding-bottom: 30px;
|
padding: 12px 16px;
|
||||||
padding: 20px;
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: 1px solid #d0d0d0;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s, border-color 0.2s;
|
||||||
|
background: #fff;
|
||||||
|
color: #333;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tools-wrapper button:hover {
|
||||||
|
background: #f5f5f5;
|
||||||
|
border-color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tools-wrapper button:active {
|
||||||
|
background: #e8e8e8;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-delete {
|
||||||
|
color: #d32f2f;
|
||||||
|
border-color: #d32f2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-delete:hover {
|
||||||
|
background: #ffebee;
|
||||||
|
border-color: #c62828;
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-copy {
|
||||||
|
color: #1976d2;
|
||||||
|
border-color: #1976d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-copy:hover {
|
||||||
|
background: #e3f2fd;
|
||||||
|
border-color: #1565c0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-paste {
|
||||||
|
color: #388e3c;
|
||||||
|
border-color: #388e3c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#btn-paste:hover {
|
||||||
|
background: #e8f5e9;
|
||||||
|
border-color: #2e7d32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Zoom wrapper */
|
||||||
.zoom-wrapper {
|
.zoom-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 15px;
|
gap: 12px;
|
||||||
padding: 10px 20px !important;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom-wrapper button {
|
.zoom-wrapper button {
|
||||||
background: white;
|
background: #fff;
|
||||||
color: #3498db;
|
color: #333;
|
||||||
border: none;
|
border: 1px solid #d0d0d0;
|
||||||
border-radius: 50%;
|
border-radius: 6px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
font-size: 24px;
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
transition: all 0.3s ease;
|
transition: background 0.2s, border-color 0.2s;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom-wrapper button:hover {
|
.zoom-wrapper button:hover {
|
||||||
background: #2980b9;
|
background: #f5f5f5;
|
||||||
color: white;
|
border-color: #999;
|
||||||
transform: scale(1.1);
|
|
||||||
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom-wrapper button:active {
|
.zoom-wrapper button:active {
|
||||||
transform: scale(0.95);
|
background: #e8e8e8;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fajny efekt przy najechaniu */
|
/* Canvas container */
|
||||||
.zoom-wrapper button i {
|
.canvas-container {
|
||||||
transition: transform 0.3s ease;
|
position: absolute;
|
||||||
|
left: 280px;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: #ffffff;
|
||||||
|
background-image:
|
||||||
|
linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
|
||||||
|
linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
|
||||||
|
background-size: 20px 20px;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom-wrapper button:hover i {
|
#paper {
|
||||||
transform: scale(1.2);
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollbar styling */
|
||||||
|
.toolbar::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar::-webkit-scrollbar-track {
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar::-webkit-scrollbar-thumb {
|
||||||
|
background: #d0d0d0;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.toolbar {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-container {
|
||||||
|
left: 0;
|
||||||
|
top: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user