Closed chenjiayu119 closed 2 months ago
An attempt to load the fonts from the indicated location (https://172.16.64.95:9002/docs/static/fonts) is made before your code gets executed. That location does not have the needed fonts. In order to prevent that error message, make sure the fonts are available at that location.
By setting the fontsDirectory
to null you are preventing the fonts from being loaded subsequently.
If you want to change the fonts directory, you should do so before the custom element is defined. Try something like this:
MathfieldElement.fontsDirectory = "https://my-host/my-fonts-directory;
customElements.whenDefined('math-field').then(() => {
const mathField = new MathfieldElement();
mfRef.current.appendChild(mathField);
});
I have tried following your method, but it still failed
useEffect(() => {
MathfieldElement.fontsDirectory = '';// 禁止加载字体(不起作用)
// 设置静态属性
customElements.whenDefined('math-field').then(() => {
const mathField = new MathfieldElement();
mfRef.current.appendChild(mathField);
mathliveConfig();
// 打开弹窗自动聚焦(位置在最后)
setTimeout(() => {
mfRef.current.executeCommand('moveToGroupEnd')
}, 100);
// 绑定点击事件,点击父级后进行聚焦
mfRef.current.parentElement.addEventListener('click', () => {
mfRef.current.focus();
});
// 自动聚焦
onFocus()
});
}, []);
Description
Steps to Reproduce
Actual Behavior
Expected Behavior
Environment
0.100.0
Operating System Windows10
Browser Chrome