3096230962 resizeHotkey: null,
3096330963 dragHotkey: null,
3096430964 connectionType: "curve",
30965- // line, curve, zigzag
30965+ // line, curve, step
3096630966 connectionStyle: "solid",
3096730967 // solid, dashed, dotted
3096830968 onePoint: false,
@@ -31704,15 +31704,16 @@
3170431704 pointA: null,
3170531705 pointB: null,
3170631706 type: "curve",
31707- // line, curve, zigzag
31707+ // line, curve, step
3170831708 container: null,
3170931709 // контейнер для SVG
3171031710 autoUpdate: true,
3171131711 // автоматичне оновлення при переміщенні блоків
3171231712 id: null,
3171331713 // унікальний ID для з'єднання
3171431714 deleteButton: false,
31715- arrow: false,
31715+ arrow: "none",
31716+ // none, end, start, both
3171631717 lineStyle: "solid",
3171731718 // solid, dashed, dotted
3171831719 onConnectorCreate: Metro2.noop,
3176731768 this.svgElement = sharedSvg;
3176831769 const shape = this._createShape(o2.id, o2.type, sharedSvg);
3176931770 const deleteBtn = this._createDeleteButton(sharedSvg, o2.id);
31770- if (o2.arrow) {
31771- const markerId = this._ensureArrowMarker(sharedSvg);
31772- shape.attr("marker-end", `url(#${markerId})`);
31773- }
31771+ this._applyArrows(shape, sharedSvg);
3177431772 this._applyLineStyle(shape, o2.lineStyle);
3177531773 this.connections.set(o2.id, {
3177631774 pointA: o2.pointA,
@@ -31857,46 +31855,52 @@
3185731855 }
3185831856 return svg;
3185931857 },
31858+ // Маркер-стрілка з вашого SVG, зменшений у 2 рази
3186031859 _ensureArrowMarker: (svg) => {
3186131860 const ns = "http://www.w3.org/2000/svg";
31862- const markerId = "connector-arrow";
31861+ const markerId = Hooks.useId( "connector-arrow") ;
3186331862 let defs = svg.find("defs");
3186431863 if (!defs.length) {
3186531864 const d4 = document.createElementNS(ns, "defs");
3186631865 svg[0].appendChild(d4);
3186731866 defs = $7(d4);
3186831867 }
31869- let marker = defs.find(`#${markerId}`);
31868+ const marker = defs.find(`#${markerId}`);
3187031869 if (!marker.length) {
3187131870 const m5 = document.createElementNS(ns, "marker");
3187231871 m5.setAttribute("id", markerId);
31873- m5.setAttribute("markerWidth", "6");
31874- m5.setAttribute("markerHeight", "6");
31875- m5.setAttribute("refX", "5");
31876- m5.setAttribute("refY", "3");
31877- m5.setAttribute("orient", "auto");
31878- m5.setAttribute("markerUnits", "strokeWidth");
31879- const line1 = document.createElementNS(ns, "line");
31880- line1.setAttribute("x1", "1");
31881- line1.setAttribute("y1", "1");
31882- line1.setAttribute("x2", "5");
31883- line1.setAttribute("y2", "3");
31884- line1.setAttribute("stroke", "context-stroke");
31885- line1.setAttribute("stroke-linecap", "round");
31886- const line2 = document.createElementNS(ns, "line");
31887- line2.setAttribute("x1", "1");
31888- line2.setAttribute("y1", "5");
31889- line2.setAttribute("x2", "5");
31890- line2.setAttribute("y2", "3");
31891- line2.setAttribute("stroke", "context-stroke");
31892- line2.setAttribute("stroke-linecap", "round");
31893- m5.appendChild(line1);
31894- m5.appendChild(line2);
31872+ m5.setAttribute("markerWidth", "12");
31873+ m5.setAttribute("markerHeight", "12");
31874+ m5.setAttribute("viewBox", "0 0 8 8");
31875+ m5.setAttribute("refX", "6");
31876+ m5.setAttribute("refY", "4");
31877+ m5.setAttribute("orient", "auto-start-reverse");
31878+ m5.setAttribute("markerUnits", "userSpaceOnUse");
31879+ const path = document.createElementNS(ns, "path");
31880+ path.setAttribute(
31881+ "d",
31882+ "M1,8 c-0.04,0-0.08-0.016-0.11-0.045 c-0.048-0.05-0.055-0.125-0.018-0.185 L3.45,4 L0.87,0.23 c-0.038-0.058-0.03-0.135,0.018-0.185 c0.048-0.05,0.125-0.06,0.185-0.026 L7.4,3.54 c0.046,0.026,0.075,0.076,0.075,0.13 s-0.029,0.103-0.075,0.13 L1.06,7.32 C0.96,7.38,0.93,7.96,1,8z"
31883+ );
31884+ path.setAttribute("fill", "var(--linked-block-line-color)");
31885+ path.setAttribute("stroke", "none");
31886+ m5.appendChild(path);
3189531887 defs[0].appendChild(m5);
31896- marker = $7(m5);
3189731888 }
3189831889 return markerId;
3189931890 },
31891+ _applyArrows: function(shape, svg) {
31892+ const o2 = this.options;
31893+ const value = o2.arrow === true ? "end" : o2.arrow || "none";
31894+ shape.removeAttr("marker-start").removeAttr("marker-end");
31895+ if (value === "none" || value === false) return;
31896+ const markerId = this._ensureArrowMarker(svg);
31897+ if (value === "start" || value === "both") {
31898+ shape.attr("marker-start", `url(#${markerId})`);
31899+ }
31900+ if (value === "end" || value === "both") {
31901+ shape.attr("marker-end", `url(#${markerId})`);
31902+ }
31903+ },
3190031904 _createShape: (id, type, svg) => {
3190131905 const ns = "http://www.w3.org/2000/svg";
3190231906 let el;
3206532069 const pathData = `M ${x1} ${y1} C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${x22} ${y22}`;
3206632070 path.attr("d", pathData);
3206732071 },
32068- _updateZigzag : function(pointA, pointB, shape) {
32072+ _updateStep : function(pointA, pointB, shape) {
3206932073 const point1 = $7(pointA);
3207032074 const point2 = $7(pointB);
3207132075 const parent1 = point1.parent();
3225632260 },
3225732261 // Публічні методи
3225832262 setType: function(type) {
32259- if (["line", "curve", "zigzag "].indexOf(type) === -1) {
32263+ if (["line", "curve", "step "].indexOf(type) === -1) {
3226032264 console.warn("Connector: \u043D\u0435\u0432\u0456\u0434\u043E\u043C\u0438\u0439 \u0442\u0438\u043F \u0437'\u0454\u0434\u043D\u0430\u043D\u043D\u044F:", type);
3226132265 return;
3226232266 }
3226732271 const oldShape = connection?.shape;
3226832272 const svg = connection?.svg || this.svgElement || this._getOrCreateSharedSVG(o2.container);
3226932273 const newShape = this._createShape(o2.id, type, svg);
32270- if (o2.arrow) {
32271- const markerId = this._ensureArrowMarker(svg);
32272- newShape.attr("marker-end", `url(#${markerId})`);
32273- }
32274+ this._applyArrows(newShape, svg);
3227432275 this._applyLineStyle(newShape, o2.lineStyle);
3227532276 if (oldShape?.length) {
3227632277 oldShape.remove();
3231132312 case "curve":
3231232313 this._updateCurve(connection.pointA, connection.pointB, connection.shape);
3231332314 break;
32314- case "zigzag ":
32315- this._updateZigzag (connection.pointA, connection.pointB, connection.shape);
32315+ case "step ":
32316+ this._updateStep (connection.pointA, connection.pointB, connection.shape);
3231632317 break;
3231732318 }
3231832319 this._positionDeleteButton(connection);
@@ -32334,13 +32335,30 @@
3233432335 this._applyLineStyle(connection.shape, o2.lineStyle);
3233532336 this.update();
3233632337 },
32338+ setArrow: function(value) {
32339+ const map = { true: "end", false: "none" };
32340+ const v5 = typeof value === "boolean" ? map[String(value)] : String(value || "none").toLowerCase();
32341+ if (!["none", "start", "end", "both"].includes(v5)) {
32342+ console.warn("Connector: \u043D\u0435\u0432\u0456\u0434\u043E\u043C\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0434\u043B\u044F arrow:", value);
32343+ return;
32344+ }
32345+ this.options.arrow = v5;
32346+ const connection = this.connections.get(this.options.id);
32347+ if (connection?.shape && connection?.svg) {
32348+ this._applyArrows(connection.shape, connection.svg);
32349+ this.update();
32350+ }
32351+ },
3233732352 changeAttribute: function(attr, newValue) {
3233832353 if (attr === "data-type") {
3233932354 this.setType(newValue);
3234032355 }
3234132356 if (attr === "data-line-style") {
3234232357 this.setLineStyle(newValue);
3234332358 }
32359+ if (attr === "data-arrow") {
32360+ this.setArrow(newValue);
32361+ }
3234432362 },
3234532363 destroy: function() {
3234632364 const o2 = this.options;
0 commit comments