mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-06-11 04:53:13 +08:00
Allow unlisten events in case of text edit
This commit is contained in:
2
dist/css/ueb-style.css
vendored
2
dist/css/ueb-style.css
vendored
File diff suppressed because one or more lines are too long
2
dist/css/ueb-style.css.map
vendored
2
dist/css/ueb-style.css.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"sourceRoot":"","sources":["../../scss/style.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-link.scss","../../scss/ueb-type-color.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,iBACA,IACI,kGAIR,WACI,qBACA,mBACA,IACI,sGAIR,cACI,cACA,kBACA,8EACA,+BACA,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,aACA,0BACA,UAGJ,mBACI,iBACA,gBACA,eAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,oDACI,gBAGJ,UACI,kFACA,kBACA,eACA,gBACA,kEACA,mEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,oDACA,qBACA,gBAGJ,kDACI,gBAGJ,mDACI,eAGJ,qBAEI,eACA,6CAGJ,gBACI,eAGJ,gBACI,mBAGJ,gBACI,kBAGJ,gBACI,mBAGJ,gBACI,iBAGJ,gBACI,mBAGJ,gBACI,kBAGJ,iBACI,mBAGJ,iBACI,kBAGJ,iBACI,mBAGJ,iBACI,iBACA,uDAGJ,iBACI,mBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,iBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,sBACA,uDAGJ,kBACI,iBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,gEACI,8DACA,8DACA,8DACA,8DACA,oGACA,qGACA,kBACA,wCACA,yCACA,0CACA,4CAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQA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BACA,mGAGJ,gBAEI","file":"ueb-style.css"}
|
{"version":3,"sourceRoot":"","sources":["../../scss/style.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-link.scss","../../scss/ueb-type-color.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,iBACA,IACI,kGAIR,WACI,qBACA,mBACA,IACI,sGAIR,cACI,cACA,kBACA,8EACA,+BACA,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,aACA,0BACA,UAGJ,mBACI,iBACA,gBACA,eAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,oDACI,gBAGJ,UACI,kFACA,kBACA,eACA,gBACA,kEACA,mEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,oDACA,qBACA,gBAGJ,kDACI,gBAGJ,mDACI,eAGJ,qBAEI,eACA,6CAGJ,gBACI,eAGJ,gBACI,mBAGJ,gBACI,kBAGJ,gBACI,mBAGJ,gBACI,iBAGJ,gBACI,mBAGJ,gBACI,kBAGJ,iBACI,mBAGJ,iBACI,kBAGJ,iBACI,mBAGJ,iBACI,iBACA,uDAGJ,iBACI,mBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,iBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,sBACA,uDAGJ,kBACI,iBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,gEACI,8DACA,8DACA,8DACA,8DACA,oGACA,qGACA,kBACA,wCACA,yCACA,0CACA,4CAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQAWJ,oBAEI,wJAOJ,4BAGJ,gDACI,mBAIJ,eACI,mBC7TJ,SACI,cACA,kBACA,sGACA,qCACA,uDAGJ,wEACI,YAGJ,iBACI,YACA,YACA,+CAGJ,+BACI,iBACI,kNAIJ,oDACA,0CACA,sDACA,0BACA,oBAGJ,kBACI,kBACA,YACA,gCACA,qCACA,6BACA,gBAGJ,iBACI,kBACA,6DACA,gEACA,8EACA,aACA,gBACA,mBAGJ,eACI,iFACA,qBACA,mBAGJ,eACI,aACA,cACA,WACA,gBACA,mBAGJ,iBACI,kBACA,iBAGJ,kBACI,kBAGJ,iBACI,aAGJ,iDACI,cC9EJ,QACI,cACA,aACA,gBAEA,UACI,qBACA,sBAIR,wEACI,aAGJ,6EACI,qCACA,iBAGJ,0BACI,iBAGJ,mBACI,qBACA,wBAGJ,oBACI,qBACA,kBACA,UACA,WACA,wBACA,wBAGJ,4BACI,WACA,cACA,kBACA,MACA,QACA,SACA,OACA,sCACA,kBAGJ,iDACI,gCAGJ,2BACI,WACA,cACA,kBACA,qBACA,sBACA,QACA,SACA,kCACA,qCACA,4CAGJ,sBACI,qBACA,sBAGJ,4BACI,aAGJ,eACI,gBACA,yBACA,kBACA,oBACA,aAEA,4FAII,qBACA,aAIR,uBACI,cACA,aACA,YACA,mBACA,UACA,eACA,gBACA,gBACA,gBACA,cACA,YACA,cAEA,0CACI,WACA,YAGJ,gDACI,mBACA,mBACA,WClHR,SACI,kEAEA,uEACA,cACA,8CAKA,kBAGJ,aACI,iEACA,kBACA,MACA,OACA,WACA,YACA,eACA,8FACA,iBAGJ,kBACI,mBACA,4BACA,eAGJ,8DAEI,eACA,4BAGJ,iBACI,cACA,mBACA,kBACA,kDACA,qHAOA,sBACA,gBACA,kBACA,4EACA,+BACA,mBACA,gBCvDJ,KAGI,uBACA,6BAGJ,iBAEI,yBAGJ,eAEI,yBAGJ,eAEI,yBAGJ,aAEI,yBAGJ,cAEI,yBAGJ,gBAGI,yBAGJ,iBAEI,yBAGJ,gBAEI,yBACA,mGAGJ,gBAEI","file":"ueb-style.css"}
|
||||||
2689
dist/ueblueprint.js
vendored
2689
dist/ueblueprint.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -4,10 +4,14 @@ export default class Configuration {
|
|||||||
deleteNodesKeyboardKey = "Delete"
|
deleteNodesKeyboardKey = "Delete"
|
||||||
editTextEventName = {
|
editTextEventName = {
|
||||||
begin: "ueb-edit-text-begin",
|
begin: "ueb-edit-text-begin",
|
||||||
end: "ueb-edit-text-end"
|
end: "ueb-edit-text-end",
|
||||||
}
|
}
|
||||||
enableZoomIn = ["LeftControl", "RightControl"] // Button to enable more than 0 (1:1) zoom
|
enableZoomIn = ["LeftControl", "RightControl"] // Button to enable more than 0 (1:1) zoom
|
||||||
expandGridSize = 400
|
expandGridSize = 400
|
||||||
|
focusEventName = {
|
||||||
|
begin: "blueprint-focus",
|
||||||
|
end: "blueprint-unfocus",
|
||||||
|
}
|
||||||
fontSize = "12px"
|
fontSize = "12px"
|
||||||
gridAxisLineColor = "black"
|
gridAxisLineColor = "black"
|
||||||
gridExpandThreshold = 0.25 // remaining size factor threshold to cause an expansion event
|
gridExpandThreshold = 0.25 // remaining size factor threshold to cause an expansion event
|
||||||
@@ -39,13 +43,13 @@ export default class Configuration {
|
|||||||
selectAllKeyboardKey = "(bCtrl=True,Key=A)"
|
selectAllKeyboardKey = "(bCtrl=True,Key=A)"
|
||||||
trackingMouseEventName = {
|
trackingMouseEventName = {
|
||||||
begin: "ueb-tracking-mouse-begin",
|
begin: "ueb-tracking-mouse-begin",
|
||||||
end: "ueb-tracking-mouse-end"
|
end: "ueb-tracking-mouse-end",
|
||||||
}
|
}
|
||||||
ModifierKeys = [
|
ModifierKeys = [
|
||||||
"Ctrl",
|
"Ctrl",
|
||||||
"Shift",
|
"Shift",
|
||||||
"Alt",
|
"Alt",
|
||||||
"Meta"
|
"Meta",
|
||||||
]
|
]
|
||||||
Keys = {
|
Keys = {
|
||||||
/* UE name: JS name */
|
/* UE name: JS name */
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import MouseCreateLink from "../input/mouse/MouseCreateLink"
|
|||||||
import PinTemplate from "../template/PinTemplate"
|
import PinTemplate from "../template/PinTemplate"
|
||||||
import ExecPinTemplate from "../template/ExecPinTemplate"
|
import ExecPinTemplate from "../template/ExecPinTemplate"
|
||||||
import StringPinTemplate from "../template/StringPinTemplate"
|
import StringPinTemplate from "../template/StringPinTemplate"
|
||||||
import KeyboardIgnoreSelectAll from "../input/keybaord/KeyboardIgnoreSelectAll"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import("../entity/GuidEntity").default} GuidEntity
|
* @typedef {import("../entity/GuidEntity").default} GuidEntity
|
||||||
@@ -53,9 +52,6 @@ export default class PinElement extends IElement {
|
|||||||
new MouseCreateLink(this.clickableElement, this.blueprint, {
|
new MouseCreateLink(this.clickableElement, this.blueprint, {
|
||||||
moveEverywhere: true,
|
moveEverywhere: true,
|
||||||
looseTarget: true
|
looseTarget: true
|
||||||
}),
|
|
||||||
new KeyboardIgnoreSelectAll(this, this.blueprint, {
|
|
||||||
consumeEvent: true
|
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,30 +6,39 @@
|
|||||||
export default class IContext {
|
export default class IContext {
|
||||||
|
|
||||||
/** @type {HTMLElement} */
|
/** @type {HTMLElement} */
|
||||||
target
|
#target
|
||||||
|
get target() {
|
||||||
|
return this.#target
|
||||||
|
}
|
||||||
|
|
||||||
/** @type {Blueprint} */
|
/** @type {Blueprint} */
|
||||||
blueprint
|
#blueprint
|
||||||
|
get blueprint() {
|
||||||
|
return this.#blueprint
|
||||||
|
}
|
||||||
|
|
||||||
/** @type {Object} */
|
/** @type {Object} */
|
||||||
options
|
options
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {HTMLElement} target
|
||||||
|
* @param {Blueprint} blueprint
|
||||||
|
* @param {Object} options
|
||||||
|
*/
|
||||||
constructor(target, blueprint, options) {
|
constructor(target, blueprint, options) {
|
||||||
this.target = target
|
this.#target = target
|
||||||
this.blueprint = blueprint
|
this.#blueprint = blueprint
|
||||||
this.options = options
|
this.options = options
|
||||||
|
this.options.listenOnFocus = this.options?.listenOnFocus ?? false
|
||||||
|
this.options.unlistenOnTextEdit = this.options?.unlistenOnTextEdit ?? false
|
||||||
let self = this
|
let self = this
|
||||||
this.listenHandler = _ => {
|
this.listenHandler = _ => self.listenEvents()
|
||||||
self.listenEvents()
|
this.unlistenHandler = _ => self.unlistenEvents()
|
||||||
|
if (this.options.listenOnFocus) {
|
||||||
|
this.blueprint.addEventListener(this.blueprint.settings.focusEventName.begin, this.listenHandler)
|
||||||
|
this.blueprint.addEventListener(this.blueprint.settings.focusEventName.end, this.unlistenHandler)
|
||||||
}
|
}
|
||||||
this.unlistenHandler = _ => {
|
if (options?.unlistenOnTextEdit ?? false) {
|
||||||
self.unlistenEvents()
|
|
||||||
}
|
|
||||||
if (options?.listenOnFocus ?? false) {
|
|
||||||
this.blueprint.addEventListener("blueprint-focus", this.listenHandler)
|
|
||||||
this.blueprint.addEventListener("blueprint-unfocus", this.unlistenHandler)
|
|
||||||
}
|
|
||||||
if (options?.unlistenOnEditText ?? false) {
|
|
||||||
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
||||||
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
||||||
}
|
}
|
||||||
@@ -37,8 +46,8 @@ export default class IContext {
|
|||||||
|
|
||||||
unlistenDOMElement() {
|
unlistenDOMElement() {
|
||||||
this.unlistenEvents()
|
this.unlistenEvents()
|
||||||
this.blueprint.removeEventListener("blueprint-focus", this.listenHandler)
|
this.blueprint.removeEventListener(this.blueprint.settings.focusEventName.begin, this.listenHandler)
|
||||||
this.blueprint.removeEventListener("blueprint-unfocus", this.unlistenHandler)
|
this.blueprint.removeEventListener(this.blueprint.settings.focusEventName.end, this.unlistenHandler)
|
||||||
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
|
||||||
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
this.blueprint.removeEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import ObjectSerializer from "../../serialization/ObjectSerializer"
|
|||||||
|
|
||||||
export default class Copy extends IContext {
|
export default class Copy extends IContext {
|
||||||
|
|
||||||
|
/** @type {(e: ClipboardEvent) => void} */
|
||||||
#copyHandler
|
#copyHandler
|
||||||
|
|
||||||
constructor(target, blueprint, options = {}) {
|
constructor(target, blueprint, options = {}) {
|
||||||
options.listenOnFocus = true
|
options.listenOnFocus = true
|
||||||
|
options.unlistenOnTextEdit = true
|
||||||
super(target, blueprint, options)
|
super(target, blueprint, options)
|
||||||
this.serializer = new ObjectSerializer()
|
this.serializer = new ObjectSerializer()
|
||||||
let self = this
|
let self = this
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import ObjectSerializer from "../../serialization/ObjectSerializer"
|
|||||||
|
|
||||||
export default class Paste extends IContext {
|
export default class Paste extends IContext {
|
||||||
|
|
||||||
|
/** @type {(e: ClipboardEvent) => void} */
|
||||||
#pasteHandle
|
#pasteHandle
|
||||||
|
|
||||||
constructor(target, blueprint, options = {}) {
|
constructor(target, blueprint, options = {}) {
|
||||||
options.listenOnFocus = true
|
options.listenOnFocus = true
|
||||||
|
options.unlistenOnTextEdit = true
|
||||||
super(target, blueprint, options)
|
super(target, blueprint, options)
|
||||||
this.serializer = new ObjectSerializer()
|
this.serializer = new ObjectSerializer()
|
||||||
let self = this
|
let self = this
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
import KeyboardSelectAll from "./KeyboardSelectAll"
|
|
||||||
|
|
||||||
export default class KeyboardIgnoreSelectAll extends KeyboardSelectAll {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {HTMLElement} target
|
|
||||||
* @param {any} blueprint
|
|
||||||
* @param {Object} options
|
|
||||||
*/
|
|
||||||
constructor(target, blueprint, options = {}) {
|
|
||||||
options = {
|
|
||||||
...options,
|
|
||||||
activationKeys: blueprint.settings.selectAllKeyboardKey
|
|
||||||
}
|
|
||||||
super(target, blueprint, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
fire() {
|
|
||||||
}
|
|
||||||
|
|
||||||
unfire() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,8 +20,8 @@ export default class StringPinTemplate extends PinTemplate {
|
|||||||
return html`
|
return html`
|
||||||
<span class="ueb-pin-input">
|
<span class="ueb-pin-input">
|
||||||
<span class="ueb-pin-input-content" role="textbox" contenteditable="true"
|
<span class="ueb-pin-input-content" role="textbox" contenteditable="true"
|
||||||
onfocus="_ => this.closest('ueb-blueprint').editText = true"
|
onfocus="this.closest('ueb-blueprint')?.dispatchEditTextEvent(true)"
|
||||||
onfocusout="_ => this.closest('ueb-blueprint').editText = false"
|
onfocusout="this.closest('ueb-blueprint')?.dispatchEditTextEvent(false)"
|
||||||
></span>
|
></span>
|
||||||
</span>
|
</span>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ ueb-pin.ueb-pin-fill .ueb-pin-icon-value::before {
|
|||||||
max-width : 400px;
|
max-width : 400px;
|
||||||
max-height: 16em;
|
max-height: 16em;
|
||||||
background: none;
|
background: none;
|
||||||
|
color : inherit;
|
||||||
cursor : text;
|
cursor : text;
|
||||||
overflow : auto;
|
overflow : auto;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user