Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display improvements to PNG Info tab #16415

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

MarcusNyne
Copy link
Contributor

Description

PNG Info tab text display currently looks like a big block of text, which makes it hard to find specific settings, and is a pain when you are trying to copy a setting. This improvement parses PNG Info settings and displays them in a format that makes it easier to read, and also allows a setting to be copied to the clipboard with a simple click.

Features

  • If there is a failure parsing, displays falls back to the old style (i.e. comfyui json)
  • High performance regex is used for parsing .. comparable performance to preexisting behavior
  • Values wrapped in quotes appear as orange, other values appear in blue
  • Colors tweaked for dark mode, so looks good in both modes
  • Click to copy .. displays CSS animation so the user knows something is happening
  • When (orange) text is copied, escaped newlines converted to newlines (i.e. adetailer prompt)
  • When an extension adds settings that are not in the expected format, non-standard settings displayed in plain text (i.e. dynamic prompt templates)

Code changes

  • Added a new module png_parser.py that contains the parsing logic, and regex expressions
    ** Non-standard settings identified by a newline outside of quotes, using dynamic prompts as a reference
  • Modified modules\extras.py run_pnginfo() to use parsing module, and convert plain text to HTML
    ** Utilized existing formatting methods when possible
    ** Introduced for formatting, copy to clipboard, and copy animations
    ** Preserved existing formatting when there is a parsing error
    ** No changes to plain text format returned by method
  • Formatting styles were added to end of style.css
    ** Uses existing CSS variables whenever possible
    ** Support for dark mode
    ** Uses @Keyframes animation
  • Added uiCopyElementText() to script.js
    ** Copies element text to clipboard
    ** Starts copy animation

Passed python and javascript linting. Passed test process.

Checklist:

Text on PNG Info tab is parsed and colorized in a way that makes it easier to read.  Parameter values can be copied by clicking on them.
- High performance regex used for parsing
- Normal values are displayed in blue, but string content is displayed in orange to improve readability (i.e. adetailer prompts)
- Clicking to copy uses a pointer cursor and a green color animation to show something is happening
- Color choices configured differently for dark mode in order to optimize readability
- Copying strings with \n automatically converts to newlines during copy operation
- Settings that don't follow normal conventions are not parsed, but displayed in the old style (i.e. dynamic prompt templates)
- If there are parsing issues (or exceptions), defaults to the old display mode
Lint run against python and javascript
@w-e-w
Copy link
Collaborator

w-e-w commented Aug 23, 2024

issue 1: unable to copy the raw unaltered infotext

with this PR if someone were to try and copy the entire infotext from HTML, it would introduce extra new lines that weren't therethere
sometimes the new lines are harmless but it can also cause certain syntax to break

you could try to make it so the HTML stylization does not alter the copy text
or it would be simpler to just add a button or something to copy the raw infotext

Issue 2: parsing breaks when no Negative prompt

with Negative prompt
image
no Negative prompt:
image

yes both screenshot is of this PR

@MarcusNyne
Copy link
Contributor Author

@w-e-w , thank you for taking the time to review my PR. I fixed the problem with no negative prompt. I like the idea of adding a way to copy text, but want to make sure I understand the problem you are describing. I copied the entire text manually and I think the newlines make the info text more readable, and so are beneficial. What do you mean by "it can also cause certain syntax to break"?

Thanks!

- Handled no negative prompt scenario
- Include new lines in positive/negative prompts
- Added links to the top to copy png info sections (all/positive/negative/settings)
@w-e-w
Copy link
Collaborator

w-e-w commented Aug 24, 2024

I copied the entire text manually and I think the newlines make the info text more readable, and so are beneficial. What do you mean by "it can also cause certain syntax to break"?

readable does not mean that it's "the same"

if someone has an extension that adds extra scripting functionality to prompts input, then for there syntex newline could have special meanings, so adding a extra newline could potentially break ther syntax or change the output

there are other use cases that are very sensitive to minor changes

@MarcusNyne
Copy link
Contributor Author

@w-e-w , I followed your suggestion and added some links to copy text. The "All" button copies text that should be identical to the previous manual copy. Please let me know if this works?

Thanks again!

@w-e-w
Copy link
Collaborator

w-e-w commented Aug 24, 2024

found a rather hilarious issue

2024-08-25.07_11_47_017.chrome.mp4

once the copy button is clicked, it flashes every time you switch to the tab

@MarcusNyne
Copy link
Contributor Author

@w-e-w thank you, that's a good catch. I'll see if I can fix it.

@MarcusNyne
Copy link
Contributor Author

@w-e-w fixed it! Thanks again. Really appreciate that you are finding these issues.

All to Copy
Positive to Prompt
@MarcusNyne
Copy link
Contributor Author

@w-e-w , renamed some of the quick links to make it more obvious what is going on. Finished with all changes, now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants