add init settings

Addressing #7
pull/8/head
Haoming 2024-01-22 10:19:28 +08:00
parent 2f7cc76536
commit b7b9c07ca5
4 changed files with 35 additions and 14 deletions

View File

@ -24,11 +24,12 @@ Sometimes, when you type too fast or copy prompts from all over the places, you
- [x] Toggle between auto formatting and manual formatting
- In `Auto`: The process is ran whenever you press **Generate**
- In `Manual`: The process is only ran when you press the **Format** button
- [x] **[New]** Use `Shift + ScrollWheel` to quickly move the hovered tag *(determined by **commas**)* around the prompt
- [x] Use `Shift + ScrollWheel` to quickly move the hovered tag *(determined by **commas**)* around the prompt
- [x] **[New]** You can now toggle which features to enable/disable by default in `System` section of the **Settings** tab
## Note
1. Since the auto formatting is triggered at the same time as the generation,
the immediate image will not have its metadata updated unless you already did manual formatting beforehand.
1. Since the formatting in `Auto` mode is triggered at the same time as the generation,
the immediate image will not have its metadata updated (unless you already did manual formatting beforehand).
2. Some Extensions *(**eg.** [tagcomplete](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete))* listen to the text editing event,
meaning the formatting will cause them to trigger. You can disable updating the actual prompts in the **System** section of the **Settings** tab.
meaning the formatting will cause them to trigger. You can disable updating the actual prompts in the `System` section of the **Settings** tab.

View File

@ -24,10 +24,11 @@
- [x] 按下`Auto Format`以在手動與自動間切換
- `自動`: 每次按下 **生成 (Generate)** 時處裡
- `手動`: 手動按下 **Format** 時才處裡
- [x] **[New]** 使用`Shift + 滾輪`來橫移目前游標所在的單字 *(由**逗點**決定)*
- [x] 使用`Shift + 滾輪`來橫移目前游標所在的單字 *(由**逗點**決定)*
- [x] **[New]** 可以在 **Settings** 頁面的 `System` 區開啟/關閉某些預設功能
## 注意
1. 由於自動校正和生成是同時觸發,除非有用手動校正,不然當下所產的圖片之內部資料並不會被更新。
1. 由於`自動`校正和生成是同時觸發,除非有過`手動`校正,不然當下所產的第一章圖片之內部資料並不會被更新。
2. 有些擴充 *(如. [tagcomplete](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete))* 追蹤文字的編輯事件,意即文字校正會導致它們啟動。
你可以到 **Settings** **System** 頁面關閉咒語的自動編輯。
你可以到 **Settings** 頁面的 `System`關閉咒語的自動編輯。

View File

@ -76,6 +76,9 @@ class LeFormatter {
if (!remove)
return tag;
if (this.cachedCards == null)
this.cache_Cards();
// [start:end:step] OR <lora:name:str>
const chucks = tag.split(':').map(c => c.trim());
@ -282,14 +285,29 @@ class LeFormatter {
const config = gradioApp().getElementById('setting_pf_disableupdateinput').querySelector('input[type=checkbox]');
return !config.checked;
}
static defaultAuto() {
const config = gradioApp().getElementById('setting_pf_startinauto').querySelector('input[type=checkbox]');
return config.checked;
}
static defaultDedupe() {
const config = gradioApp().getElementById('setting_pf_startwithdedupe').querySelector('input[type=checkbox]');
return config.checked;
}
static defaultRemoveUnderscore() {
const config = gradioApp().getElementById('setting_pf_startwithrmudscr').querySelector('input[type=checkbox]');
return config.checked;
}
}
onUiLoaded(async () => {
const Modes = ['txt', 'img'];
var autoRun = true;
var dedupe = true;
var removeUnderscore = false;
var autoRun = LeFormatter.defaultAuto();
var dedupe = LeFormatter.defaultDedupe();
var removeUnderscore = LeFormatter.defaultRemoveUnderscore();
const manualBtn = LeFormatter.manualButton({
onClick: () => {
@ -298,7 +316,7 @@ onUiLoaded(async () => {
}
});
manualBtn.style.display = 'none';
manualBtn.style.display = autoRun ? 'none' : 'block';
const autoCB = LeFormatter.checkbox('Auto Format', autoRun, {
onChange: (checked) => {
@ -314,8 +332,6 @@ onUiLoaded(async () => {
const underlineCB = LeFormatter.checkbox('Remove Underscores', removeUnderscore, {
onChange: (checked) => {
removeUnderscore = checked;
if (LeFormatter.cachedCards == null)
LeFormatter.cache_Cards();
}
});

View File

@ -1,6 +1,9 @@
from modules import script_callbacks, shared
def on_ui_settings():
shared.opts.add_option("pf_disableupdateinput", shared.OptionInfo(False, "Prompt Format - Disable Update Input", section=("system", "System")))
shared.opts.add_option("pf_disableupdateinput", shared.OptionInfo(False, "Prompt Format - Disable Update Input", section=("system", "System")).info("Enable this if you have Extensions, such as [tagcomplete], that subscribe to text editing event."))
shared.opts.add_option("pf_startinauto", shared.OptionInfo(True, "Prompt Format - Start in Auto Mode", section=("system", "System")))
shared.opts.add_option("pf_startwithdedupe", shared.OptionInfo(True, "Prompt Format - Start with Remove Duplicates", section=("system", "System")))
shared.opts.add_option("pf_startwithrmudscr", shared.OptionInfo(False, "Prompt Format - Start with Remove Underscores", section=("system", "System")))
script_callbacks.on_ui_settings(on_ui_settings)