#148 and some cleaning

This commit is contained in:
Chris
2026-05-22 10:56:09 +10:00
parent 7b085ad8a9
commit 5d33fbc0e2
3 changed files with 30 additions and 5 deletions
+3 -1
View File
@@ -168,7 +168,9 @@ generated. Here's a trivial workflow:
![text workflow](images/text%20workflow.png)
Typing shortcuts. If you find you often use the same text in the `text` field, you can create shortcuts in the `tip` by enclosing them `{{ like this }}`
Typing shortcuts. If you find you often use the same text in the `text` field, you can create shortcuts in the `tip` by enclosing them `{{ like this }}`.
If you double-click in the text area, it will replace the contents with the text from the previous run (useful if you are tweaking the text for the same image)
---
+1 -1
View File
@@ -5,7 +5,7 @@
border: 1px solid black;
background-color: rgba(95, 158, 160, 0.713);
width: fit-content;
max-width: 450px;
/*max-width: 450px;*/
}
.cgfloat.hidden {
+26 -3
View File
@@ -32,6 +32,8 @@ const State = Object.freeze({
const default_audio_folder = 'extensions/cg-image-filter/audio/'
const default_audio_file = 'ding.mp3';
const stored_texts = {}
class Popup extends HTMLElement {
constructor() {
super()
@@ -86,6 +88,10 @@ class Popup extends HTMLElement {
this.text_edit = create('textarea', 'text_edit row', this.floating_window.body)
this.text_edit.id = 'text_edit'
this.text_edit.addEventListener('click', (e)=>{
if (e.detail==2) { this.text_edit.value = this.retrieve_text() }
})
this.picked = new Set()
@@ -99,6 +105,10 @@ class Popup extends HTMLElement {
this.render()
}
unique_id() { return `${app.graph.id}:${this.node?.id}` }
store_text(text) { stored_texts[this.unique_id()] = text }
retrieve_text() { return stored_texts[this.unique_id()] || "" }
toggleHide() {
this.hidden_by_toggle = !this.hidden_by_toggle
if (!this.hidden_by_toggle) this.layout()
@@ -188,8 +198,15 @@ class Popup extends HTMLElement {
msg.extras = []
Array.from(this.extras_row.children).forEach((e)=>{ msg.extras.push(e.value) })
}
if (this.state==State.FILTER || this.state==State.ZOOMED) msg.selection = Array.from(this.picked)
if (this.state==State.TEXT) msg.text = this.text_edit.value
if (this.state==State.FILTER || this.state==State.ZOOMED) {
msg.selection = Array.from(this.picked)
}
if (this.state==State.TEXT) {
msg.text = this.text_edit.value
this.store_text(msg.text)
}
this.last_response_sent = Date.now()
}
@@ -302,13 +319,19 @@ class Popup extends HTMLElement {
_handle_message(message, using_saved) {
const detail = message.detail
const uid = app.runningNodeId
if (!uid) {
Log.log("Workflow isn't running")
return
}
const the_node = this.find_node(uid)
const graph_id = message.detail.graph_id
if (detail.audiopath) this.audiopath = detail.audiopath
if (graph_id != app.graph.id) {
this._flash_tab(message.detail.graph_id)
this._flash_tab(graph_id)
Log.detail(`Message for different tab`)
return
}