Coder Social home page Coder Social logo

Comments (3)

yankooliveira avatar yankooliveira commented on July 30, 2024

Back when I started developing the extension I asked around for better methods to address specific buttons/areas, but seems DOM hackery is the only way to go atm. That said, you're right, relying on strings is definitely not ideal!

Will add this to the list of things to investigate for a next version.

from sd-webui-photopea-embed.

FCJ1987 avatar FCJ1987 commented on July 30, 2024

My main language is Chinese, so I have been using [bilingual-localization] to display both Chinese and English.我的主要语言是中文,所以我一直使用[双语本地化]来显示中文和英文。

In the file photopea-bindings.js, at line 63, the [Inpaint selection] button get Inpaint tab using the following code:在文件 photopea-bindings.js 中,在第 63 行,[Inpaint 选择] 按钮使用以下代码获取 Inpaint 选项卡:

Array.from(allButtons).find(button => button.textContent === 'Inpaint upload ');

However, [bilingual-localization] changes the value of textContent to '修復上傳 Inpaint upload ', which causes [Inpaint selection] can't find the Inpaint tab and therefore not work correctly.但是,[双语本地化] 将 textContent 的值更改为 '修復上傳 Inpaint upload ',这会导致 [Inpaint 选择] 找不到 Inpaint 选项卡,因此无法正常工作。

In my own copy, I have modified it to:在我自己的副本中,我将其修改为:

Array.from(allButtons).find(button => button.textContent.endsWith('Inpaint upload '));

This works fine for me, but there might be other users who did not using bilingual-localization but the original localization feature of SD-WebUI.这对我来说很好用,但可能还有其他用户没有使用双语本地化,而是使用 SD-WebUI 的原始本地化功能。 This could result in the disappearance of the latter part of 'Inpaint upload ', leaving only the text in another language.这可能会导致“Inpaint 上传”的后半部分消失,只留下另一种语言的文本。 Using 'endsWith' might not be a solution for them.使用“endsWith”可能不是他们的解决方案。

Is there a more precise way to get Inpaint tab that avoids the localization break [Inpaint selection] functionality?有没有更精确的方法来获取 Inpaint 选项卡,以避免本地化中断 [Inpaint 选择] 功能?

朋友你好,这个已经是5月底的帖子了,不知道作者之后更新了解决方案没有,我是最近才开始使用photopea这个插件的,截止今天11-06为止问题仍然存在。我这边有几个问题想请教你一下,不知道方不方便。

1.如果是因为中文翻译导致出现这个问题的话,那把webui界面调回英文可以正常使用吗?我这边关闭了中文插件把webUI调成英文界面,inpaint selection还是无效。或者只是关闭插件重启还不够,必须卸载中文插件才行?

2.同样是中文界面,为什么inpaint upload被中文插件翻译成上传重绘蒙版会导致photopea的inpaint selection无效,但是img2img之类被翻译成图生图却不影响send to img2img的使用呢?

3.你的修改方法,把代码Array.from(allButtons).find(button => button.textContent === 'Inpaint upload ');改成Array.from(allButtons).find(button => button.textContent.endsWith('Inpaint upload '));意思是不是改成查找以“inpaint upload”结尾的按钮,那是不是意味着要使用的中文插件必须是中英文混排的“上传重绘蒙版inpaint upload”翻译方式,且必须以inpaint upload结尾才行?如果中文插件翻译之后按钮上只有中文的“上传重绘蒙版”的话,是否还是会无效?

4.我按你的修改方法修改了JS文件,inpaint selection还是无效。不知道您方不方便帮我检查下我的操作是否有问题,如果代码没有问题的话,是不是就是我上一个问题所说的,中文插件翻译后按钮上只有中文的“上传重绘蒙版”的关系,或者还有其他需要修改的地方?下面是我的修改截图:
image

5.基于问题4,我还尝试了将代码Array.from(allButtons).find(button => button.textContent === 'Inpaint upload ');改成Array.from(allButtons).find(button => button.textContent === '上传重绘蒙版'); 还是出错,点击inpaint selection(重绘选择区域)后弹出No selection in active document!的报错。哦顺便说下我的中文插件把photopea的按钮也汉化了,inpaint selection翻译成了“重绘选择区域”,这个不影响吧?
image

6.作者在末尾提到了#13的帖子,也提到了翻译破坏导致inpaint selection失效的问题,作者在#13那里提到了 #13 (comment) 的处理方式,似乎仍然是自己修改photopea-bindings.js文件中的相关代码?也就是说您的修改方法仍然是唯一的解决途径吗?

问题有点多,本人也不是编程行业从业者,问题内容对你来说可能太基础了些,非常抱歉打扰到你,但还是很诚恳的希望得到您的帮助。

from sd-webui-photopea-embed.

FCJ1987 avatar FCJ1987 commented on July 30, 2024

Back when I started developing the extension I asked around for better methods to address specific buttons/areas, but seems DOM hackery is the only way to go atm. That said, you're right, relying on strings is definitely not ideal!当我开始开发扩展时,我四处询问更好的方法来解决特定的按钮/区域,但似乎 DOM hackery 是 atm 的唯一方法。也就是说,你是对的,依靠字符串绝对不理想!

Will add this to the list of things to investigate for a next version.会将其添加到要为下一个版本调查的事项列表中。

As per the previous post, I changed the code from "Array.from(allButtons).find(button => button.textContent === 'Inpaint upload ')" to "Array.from(allButtons).find(button => button.textContent.endsWith('Inpaint upload '))". However, the issue still persists. Can you please help me check where I went wrong with my operation?

image

from sd-webui-photopea-embed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.