This commit is contained in:
ChuXun
2026-01-04 17:58:44 +08:00
parent cf8f4c5c3a
commit ec3b5157fe
180 changed files with 4677 additions and 18032 deletions

View File

@@ -458,7 +458,7 @@ RichTextUitl.initMoreUEditor = function (json, callback, changecallback) {
}
if(this.options.placeholder){
isEmpty();
}
}
})
});
@@ -760,7 +760,7 @@ RichTextUitl.convertUrl = function (url) {
RichTextUitl.loadEditorProfile = function (userDefaultMediaPulgin, userImgPlugin) {
if(window.obj && window.obj.mirrorDomain && !RichTextUitl.prefix){
RichTextUitl.prefix = window.obj.mirrorDomain.noteDomain || window.obj.mirrorDomain.NoteDomainHttps;
}else if((typeof window.obj == "undefined" || typeof window.obj.mirrorDomain == "undefined") && (RichTextUitl.prefix || RichTextUitl.nowDomain.indexOf('chaoxing.com') > -1) && !RichTextUitl.intranetMode ){
}else if((typeof window.obj == "undefined" || typeof window.obj.mirrorDomain == "undefined") && (RichTextUitl.prefix || window.location.host.indexOf('chaoxing.com') == -1) && !RichTextUitl.intranetMode ){
//整个笔记服务镜像时调用接口获取镜像域名
$.ajax({
type:'get',
@@ -778,7 +778,8 @@ RichTextUitl.loadEditorProfile = function (userDefaultMediaPulgin, userImgPlugin
}
}
window.obj.mirrorDomain.isMirrorDeploy = res.data.isMirrorDeploy;
RichTextUitl.mirrorPhotoDomain = window.location.protocol + window.obj.mirrorDomain.photoDomain.replace('http:','').replace('https:','');
RichTextUitl.photoDomain = window.obj.mirrorDomain.photoDomain;
RichTextUitl.noteDomain = window.obj.mirrorDomain.NoteDomainHttps;
}
},
});
@@ -838,7 +839,13 @@ RichTextUitl.loadEditorProfile = function (userDefaultMediaPulgin, userImgPlugin
RichTextUitl.loadCssFile(prefix + 'third-party/webuploader/webuploader.css?_t=' + RichTextUitl.t);
// 支持markdown
RichTextUitl.loadJSFile(prefix + 'third-party/markdown/marked.min.js')
if(typeof Marked == 'undefined') {
RichTextUitl.loadJSFile(prefix + 'third-party/markdown/marked.min.js')
}
// 支持markdown公式,Map未被重写才渲染公式
if(RichTextUitl.needRenderMath && Map.toString() === 'function Map() { [native code] }'){
RichTextUitl.loadJSFile(prefix + 'third-party/markdown/tex-svg.min.js')
}
// 查看图片相关插件
if (!RichTextUitl.hasLoadViewer) {
@@ -889,7 +896,7 @@ RichTextUitl.loadEditorProfile = function (userDefaultMediaPulgin, userImgPlugin
RichTextUitl.loadDetailPageProfile = function (userDefaultMediaPulgin, loadAttachmentListener, isScreen, setBackground, userImgPlugin,json) {
if(window.obj && window.obj.mirrorDomain && !RichTextUitl.prefix){
RichTextUitl.prefix = window.obj.mirrorDomain.noteDomain || window.obj.mirrorDomain.NoteDomainHttps;
}else if((typeof window.obj == "undefined" || typeof window.obj.mirrorDomain == "undefined") && (RichTextUitl.prefix || RichTextUitl.nowDomain.indexOf('chaoxing.com') > -1) && !RichTextUitl.intranetMode ){
}else if((typeof window.obj == "undefined" || typeof window.obj.mirrorDomain == "undefined") && (RichTextUitl.prefix || window.location.host.indexOf('chaoxing.com') == -1) && !RichTextUitl.intranetMode ){
//整个笔记服务镜像时调用接口获取镜像域名
$.ajax({
type:'get',
@@ -907,6 +914,8 @@ RichTextUitl.loadDetailPageProfile = function (userDefaultMediaPulgin, loadAttac
}
}
window.obj.mirrorDomain.isMirrorDeploy = res.data.isMirrorDeploy;
RichTextUitl.noteDomain = window.obj.mirrorDomain.NoteDomainHttps;
RichTextUitl.photoDomain = window.obj.mirrorDomain.photoDomain;
}
},
});
@@ -991,6 +1000,10 @@ RichTextUitl.loadDetailPageProfile = function (userDefaultMediaPulgin, loadAttac
RichTextUitl.loadJSFile(prefix + '/js/common/yun.file.util.js');
}
}
// 支持markdown
if(RichTextUitl.needRenderMath && Map.toString() === 'function Map() { [native code] }'){
RichTextUitl.loadJSFile(prefix + '/plugin/ueditor/third-party/markdown/tex-svg.min.js')
}
// 加载音视频播放插件
// if (userDefaultMediaPulgin && !RichTextUitl.hasLoadMedia) {
// RichTextUitl.hasLoadMedia = true;
@@ -1247,6 +1260,9 @@ RichTextUitl.getCookie = function (str) {
}
}
if(str == 'browserLocale'){
return ''
}
//如果通过cookie取不到调接口获取
var item = '';
var url = (RichTextUitl.prefix || RichTextUitl.noteDomain || window.location.protocol + '//noteyd.chaoxing.com') + '/apis/getCookie?name='+str;
@@ -1423,17 +1439,23 @@ RichTextUitl.afterPageRendered = function (selector,json) {
});
RichTextUitl.loadImg(imgList,selector,json);
}
//渲染公式
RichTextUitl.renderLatex(selector)
//解决视频不能全屏的问题
$(selector).find('iframe').each(function (index, iframe) {
if (!iframe.getAttribute('allowfullscreen')) {
iframe.setAttribute('allowfullscreen', "true");
}
var attachment = RichTextUitl.b64DecodeUnicode(iframe.getAttribute('name'))
var src = iframe.getAttribute('src')
if (!src) return;
var attachment = RichTextUitl.b64DecodeUnicode(iframe.getAttribute('name'))
if(iframe.getAttribute('fileType') && RichTextUitl.attachMode == 'preview' && (iframe.getAttribute('fileType').indexOf('word') > -1 || iframe.getAttribute('fileType').indexOf('excel') > -1 || iframe.getAttribute('fileType').indexOf('pdf') > -1 || iframe.getAttribute('fileType').indexOf('ppt') > -1)){
//预览模式
src = RichTextUitl.convertUrl(window.location.protocol + '//previewyd.chaoxing.com/res/view/view.html?objectid=' +
attachment.att_clouddisk.fileId + '&fileName=' + encodeURIComponent(RichTextUitl.getCloudFileName(iframe.getAttribute('name'))));
if(RichTextUitl.useWpsPreview){ //使用wps预览的
iframeSrc += '&type=wps'
}
iframe.setAttribute('src', src);
iframe.setAttribute('preview', 'true');
}else if(iframe.getAttribute('fileType') && RichTextUitl.attachMode == 'text'){
@@ -1687,7 +1709,7 @@ RichTextUitl.updateAllIframeWidth = function (selector, width) {
}
//云盘附件加载完成后给附件内部发送消息
function iframeOnload(iframe){
function iframeOnload(iframe,body){
var attachment = RichTextUitl.b64DecodeUnicode(iframe.getAttribute('name'))
var allowDownload = true;
var nonsupportPreview = !RichTextUitl.showPreview(attachment,$(iframe)); // 部分镜像项目不支持预览
@@ -1706,6 +1728,13 @@ function iframeOnload(iframe){
//镜像附件,笔记是单位域名,预览是超星域名,不允许预览
nonsupportPreview = true;
}
//只有指定id内的附件用自定义预览解决分组任务中老师上传的文档不需要跳编辑学生的需要跳编辑但都会跳到编辑页的问题
var openPreview= '';
if(RichTextUitl.openPreview && document.getElementById(RichTextUitl.openPreview.id) && document.getElementById(RichTextUitl.openPreview.id).querySelector('iframe[cid="' + iframe.getAttribute('cid') + '"]') ) {
openPreview= RichTextUitl.openPreview;
}else if(RichTextUitl.openPreview && body && body.querySelector('iframe[cid="' + iframe.getAttribute('cid') + '"]')){
openPreview= RichTextUitl.openPreview;
}
iframe.contentWindow.postMessage(
{
'msgType': 'config',
@@ -1722,7 +1751,7 @@ function iframeOnload(iframe){
'mirrorPrefix': attach.mirrorPrefix || '',
'isGetVideoDataFromCenter': RichTextUitl.isGetVideoDataFromCenter,
'mirrorDomain': window.obj.mirrorDomain,
'openPreview':RichTextUitl.openPreview || '',
'openPreview': openPreview,
'unAllowOpenAttach':RichTextUitl.unAllowOpenAttach,
'unAllowOpenAttachTips':RichTextUitl.unAllowOpenAttachTips,
'useWpsPreview': RichTextUitl.useWpsPreview || '',
@@ -1744,6 +1773,7 @@ function videoOnload(iframe,selector){
'unAllowOpenAttachTips':RichTextUitl.unAllowOpenAttachTips,
'cloudUrl': RichTextUitl.cloudUrl || '',
'isHdVideo': window.obj.mirrorDomain && window.obj.mirrorDomain.isMirrorDeploy ? true : '',
'videoWidthMax': RichTextUitl.videoWidthMax ? selector.clientWidth || 0 : 0,
}
if(selector && selector.querySelector('iframe[module="insertVideo"]') == iframe){
message.isAutoPlayVideo = RichTextUitl.isAutoPlayVideo ? RichTextUitl.isAutoPlayVideo : '';
@@ -2524,9 +2554,9 @@ RichTextUitl.getCloudFileSuffix = function (name) {
*/
RichTextUitl.isPhone = function () {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var isHarmony = navigator.userAgent.indexOf('harmony') > -1
var isAndroid = u.indexOf('Android') > -1; //android终端
var isIOS = !!u.match(/(iPhone|iPad|iPod)/i); //ios终端
var isHarmony = navigator.userAgent.indexOf('harmony') > -1 && navigator.userAgent.indexOf('phone') > -1;
return isAndroid || isIOS || isHarmony;
}
@@ -2952,3 +2982,27 @@ RichTextUitl.createMoreTemplate = function (editorId, templateList) {
}
//渲染公式
RichTextUitl.renderLatex = function (dom){
if(!dom) return
if(typeof MathJax == 'undefined') return
// 查找所有需要渲染的元素
var mathElements = dom.querySelectorAll('span[data-latexstr]');
mathElements.forEach(el => {
const tex = decodeURIComponent(el.dataset.latexstr); // 解码
const display = el.tagName === 'latex_math_block';// 默认块级
el.textContent = '';// 清空旧内容
el.style.transform = '';
MathJax.tex2svgPromise(tex, { display: display })
.then(function(node) {
el.appendChild(node);
//超长公式需要缩小
var scale = el.clientWidth / node.offsetWidth; // 计算所需比例
if(scale < 1 && scale > 0){
el.style.transformOrigin = 'left center'; // 以左上角为基准
el.style.transform = `scale(${Math.min(scale, 1)})`; // ≤1 保证不放大
}
})
});
}