Tencent / wujie

极致的微前端框架
https://wujie-micro.github.io/doc/
Other
3.9k stars 554 forks source link

富文本tinymce在无界子服务环境中少了skin.min.css加载,单独运行可以自动加载。 #224

Open Guo-star opened 1 year ago

Guo-star commented 1 year ago

描述bug 富文本tinymce在无界子服务环境中少了skin.min.css加载,导致富文本不显示。单独运行可以自动加载。

如何复现 通过script加载tinymce.min.js,然后tinymce.init。对比子服务中和单独运行的服务发现少了skin.min.css

错误截图 image

IU-cwx commented 1 year ago

引入路径可能没写对.. 要使用绝对路径

cloydlau commented 1 year ago

可参考 https://github.com/cloydlau/faim#farichtext 的用法,经测试可正常在 wujie 中使用。

hamflx commented 1 year ago

这个问题是因为 tinymce 动态插入 link 标签的时候,是先 appendChildsetAttribute,代码见:https://sourcegraph.com/github.com/tinymce/tinymce/-/blob/modules/tinymce/src/core/main/ts/api/dom/StyleSheetLoader.ts?L148:7

然后 wujieappendChild 的处理方法内,忽略了 href 为空的情况,导致这个样式没有被加载,代码见:https://sourcegraph.com/github.com/Tencent/wujie/-/blob/packages/wujie-core/src/effect.ts?L182-218

解决方法很简单,直接改 node_modules/tinymce/tinymce.js,将如下代码:

addStyle(linkElem);
set$3(linkElem, 'href', urlWithSuffix);

改为:

set$3(linkElem, 'href', urlWithSuffix);
addStyle(linkElem);

也就是改一下两者的顺序。

hevgin commented 1 year ago

4.9.3版本在4337行,换下顺序就行

appendToHead(link); link.href = url;

hamflx commented 1 year ago

@yiludege 这个问题应该可以通过劫持 setAttribute 来解决,这个方案可行的话,我提个 pr?

yiludege commented 1 year ago

@yiludege 这个问题应该可以通过劫持 setAttribute 来解决,这个方案可行的话,我提个 pr?

pr is welcome!!

3DXT commented 8 months ago

代码更新了不?

@yiludege 这个问题应该可以通过劫持 setAttribute 来解决,这个方案可行的话,我提个 pr?

cereschen commented 1 month ago

可以选择手动加载主题css文件 这样可控性最好 两个文件

skin.min.css content.min.css