mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-22 14:17:30 +08:00
Link implementation wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import html from "./html"
|
||||
import sanitizeText from "./sanitizeText"
|
||||
import Template from "./Template"
|
||||
|
||||
/**
|
||||
@@ -25,7 +26,6 @@ export default class LinkTemplate extends Template {
|
||||
*/
|
||||
apply(link) {
|
||||
super.apply(link)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ export default class LinkTemplate extends Template {
|
||||
*/
|
||||
applySourceLocation(link, initialPosition) {
|
||||
// Set initial position
|
||||
link.style.setProperty("--ueb-link-from-x", sanitizeText(initialPosition[0]))
|
||||
link.style.setProperty("--ueb-link-from-y", sanitizeText(initialPosition[1]))
|
||||
link.style.setProperty("--ueb-from-x", sanitizeText(initialPosition[0]))
|
||||
link.style.setProperty("--ueb-from-y", sanitizeText(initialPosition[1]))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ export default class LinkTemplate extends Template {
|
||||
* @param {GraphLink} link Link element
|
||||
*/
|
||||
applyDestinationLocation(link, finalPosition) {
|
||||
link.style.setProperty("--ueb-link-to-x", sanitizeText(finalPosition[0]))
|
||||
link.style.setProperty("--ueb-link-to-y", sanitizeText(finalPosition[1]))
|
||||
link.style.setProperty("--ueb-to-x", sanitizeText(finalPosition[0]))
|
||||
link.style.setProperty("--ueb-to-y", sanitizeText(finalPosition[1]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Utility from "../Utility"
|
||||
import html from "./html"
|
||||
import sanitizeText from "./sanitizeText"
|
||||
import Template from "./Template"
|
||||
@@ -33,6 +34,18 @@ export default class PinTemplate extends Template {
|
||||
apply(pin) {
|
||||
super.apply(pin)
|
||||
pin.classList.add("ueb-node-" + pin.isInput() ? "input" : "output", "ueb-node-value-" + sanitizeText(pin.getType()))
|
||||
pin.clickableElement = pin.querySelector(".ueb-node-value-icon")
|
||||
pin.clickableElement = pin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {GraphPin} pin
|
||||
* @returns
|
||||
*/
|
||||
getLinkLocation(pin) {
|
||||
const rect = pin.querySelector(".ueb-node-value-icon").getBoundingClientRect()
|
||||
return Utility.convertLocation(
|
||||
[(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2],
|
||||
pin.blueprint.gridElement)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ export default class SelectorTemplate extends Template {
|
||||
*/
|
||||
apply(selector) {
|
||||
super.apply(selector)
|
||||
selector.classList.add("ueb-selector")
|
||||
this.applyFinishSelecting(selector)
|
||||
}
|
||||
|
||||
@@ -22,11 +21,11 @@ export default class SelectorTemplate extends Template {
|
||||
*/
|
||||
applyStartSelecting(selector, initialPosition) {
|
||||
// Set initial position
|
||||
selector.style.setProperty("--ueb-select-from-x", sanitizeText(initialPosition[0]))
|
||||
selector.style.setProperty("--ueb-select-from-y", sanitizeText(initialPosition[1]))
|
||||
selector.style.setProperty("--ueb-from-x", sanitizeText(initialPosition[0]))
|
||||
selector.style.setProperty("--ueb-from-y", sanitizeText(initialPosition[1]))
|
||||
// Final position coincide with the initial position, at the beginning of selection
|
||||
selector.style.setProperty("--ueb-select-to-x", sanitizeText(initialPosition[0]))
|
||||
selector.style.setProperty("--ueb-select-to-y", sanitizeText(initialPosition[1]))
|
||||
selector.style.setProperty("--ueb-to-x", sanitizeText(initialPosition[0]))
|
||||
selector.style.setProperty("--ueb-to-y", sanitizeText(initialPosition[1]))
|
||||
selector.dataset.selecting = "true"
|
||||
}
|
||||
|
||||
@@ -35,8 +34,8 @@ export default class SelectorTemplate extends Template {
|
||||
* @param {GraphSelector} selector Selector element
|
||||
*/
|
||||
applyDoSelecting(selector, finalPosition) {
|
||||
selector.style.setProperty("--ueb-select-to-x", sanitizeText(finalPosition[0]))
|
||||
selector.style.setProperty("--ueb-select-to-y", sanitizeText(finalPosition[1]))
|
||||
selector.style.setProperty("--ueb-to-x", sanitizeText(finalPosition[0]))
|
||||
selector.style.setProperty("--ueb-to-y", sanitizeText(finalPosition[1]))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
/**
|
||||
* This solves the sole purpose of providing compression capability for html inside template literals strings. Check rollup.config.js function minifyHTML()
|
||||
*/
|
||||
const html = String.raw
|
||||
export default html
|
||||
|
||||
Reference in New Issue
Block a user