Allow unlisten events in case of text edit

This commit is contained in:
barsdeveloper
2022-04-02 13:47:16 +02:00
parent e901932953
commit 6ffdcbccab
11 changed files with 1380 additions and 1403 deletions

File diff suppressed because one or more lines are too long

View File

@@ -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,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,YACA,cAEA,0CACI,WACA,YAGJ,gDACI,mBACA,mBACA,WCjHR,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"}
{"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

File diff suppressed because it is too large Load Diff

View File

@@ -4,10 +4,14 @@ export default class Configuration {
deleteNodesKeyboardKey = "Delete"
editTextEventName = {
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
expandGridSize = 400
focusEventName = {
begin: "blueprint-focus",
end: "blueprint-unfocus",
}
fontSize = "12px"
gridAxisLineColor = "black"
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)"
trackingMouseEventName = {
begin: "ueb-tracking-mouse-begin",
end: "ueb-tracking-mouse-end"
end: "ueb-tracking-mouse-end",
}
ModifierKeys = [
"Ctrl",
"Shift",
"Alt",
"Meta"
"Meta",
]
Keys = {
/* UE name: JS name */

View File

@@ -5,7 +5,6 @@ import MouseCreateLink from "../input/mouse/MouseCreateLink"
import PinTemplate from "../template/PinTemplate"
import ExecPinTemplate from "../template/ExecPinTemplate"
import StringPinTemplate from "../template/StringPinTemplate"
import KeyboardIgnoreSelectAll from "../input/keybaord/KeyboardIgnoreSelectAll"
/**
* @typedef {import("../entity/GuidEntity").default} GuidEntity
@@ -53,9 +52,6 @@ export default class PinElement extends IElement {
new MouseCreateLink(this.clickableElement, this.blueprint, {
moveEverywhere: true,
looseTarget: true
}),
new KeyboardIgnoreSelectAll(this, this.blueprint, {
consumeEvent: true
})
]
}

View File

@@ -6,30 +6,39 @@
export default class IContext {
/** @type {HTMLElement} */
target
#target
get target() {
return this.#target
}
/** @type {Blueprint} */
blueprint
#blueprint
get blueprint() {
return this.#blueprint
}
/** @type {Object} */
options
/**
* @param {HTMLElement} target
* @param {Blueprint} blueprint
* @param {Object} options
*/
constructor(target, blueprint, options) {
this.target = target
this.blueprint = blueprint
this.#target = target
this.#blueprint = blueprint
this.options = options
this.options.listenOnFocus = this.options?.listenOnFocus ?? false
this.options.unlistenOnTextEdit = this.options?.unlistenOnTextEdit ?? false
let self = this
this.listenHandler = _ => {
self.listenEvents()
this.listenHandler = _ => 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 = _ => {
self.unlistenEvents()
}
if (options?.listenOnFocus ?? false) {
this.blueprint.addEventListener("blueprint-focus", this.listenHandler)
this.blueprint.addEventListener("blueprint-unfocus", this.unlistenHandler)
}
if (options?.unlistenOnEditText ?? false) {
if (options?.unlistenOnTextEdit ?? false) {
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.begin, this.unlistenHandler)
this.blueprint.addEventListener(this.blueprint.settings.editTextEventName.end, this.listenHandler)
}
@@ -37,8 +46,8 @@ export default class IContext {
unlistenDOMElement() {
this.unlistenEvents()
this.blueprint.removeEventListener("blueprint-focus", this.listenHandler)
this.blueprint.removeEventListener("blueprint-unfocus", this.unlistenHandler)
this.blueprint.removeEventListener(this.blueprint.settings.focusEventName.begin, this.listenHandler)
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.end, this.listenHandler)
}

View File

@@ -5,10 +5,12 @@ import ObjectSerializer from "../../serialization/ObjectSerializer"
export default class Copy extends IContext {
/** @type {(e: ClipboardEvent) => void} */
#copyHandler
constructor(target, blueprint, options = {}) {
options.listenOnFocus = true
options.unlistenOnTextEdit = true
super(target, blueprint, options)
this.serializer = new ObjectSerializer()
let self = this

View File

@@ -6,10 +6,12 @@ import ObjectSerializer from "../../serialization/ObjectSerializer"
export default class Paste extends IContext {
/** @type {(e: ClipboardEvent) => void} */
#pasteHandle
constructor(target, blueprint, options = {}) {
options.listenOnFocus = true
options.unlistenOnTextEdit = true
super(target, blueprint, options)
this.serializer = new ObjectSerializer()
let self = this

View File

@@ -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() {
}
}

View File

@@ -20,8 +20,8 @@ export default class StringPinTemplate extends PinTemplate {
return html`
<span class="ueb-pin-input">
<span class="ueb-pin-input-content" role="textbox" contenteditable="true"
onfocus="_ => this.closest('ueb-blueprint').editText = true"
onfocusout="_ => this.closest('ueb-blueprint').editText = false"
onfocus="this.closest('ueb-blueprint')?.dispatchEditTextEvent(true)"
onfocusout="this.closest('ueb-blueprint')?.dispatchEditTextEvent(false)"
></span>
</span>
`

View File

@@ -100,6 +100,7 @@ ueb-pin.ueb-pin-fill .ueb-pin-icon-value::before {
max-width : 400px;
max-height: 16em;
background: none;
color : inherit;
cursor : text;
overflow : auto;