@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.8 → 1.0.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/LcdpUeditor.d.ts +10 -4
- package/es/LcdpUeditor.d.ts.map +1 -0
- package/es/LcdpUeditor.js +77 -11
- package/es/ToolBottomBar/FormatModal/index.d.ts +9 -0
- package/es/ToolBottomBar/FormatModal/index.d.ts.map +1 -0
- package/es/ToolBottomBar/FormatModal/index.js +543 -0
- package/es/ToolBottomBar/FormatModal/index.less +276 -0
- package/es/ToolBottomBar/ProgressModal/index.d.ts +10 -0
- package/es/ToolBottomBar/ProgressModal/index.d.ts.map +1 -0
- package/es/ToolBottomBar/ProgressModal/index.js +53 -0
- package/es/ToolBottomBar/ProgressModal/index.less +16 -0
- package/es/ToolBottomBar/index.d.ts +33 -0
- package/es/ToolBottomBar/index.d.ts.map +1 -0
- package/es/ToolBottomBar/index.js +296 -0
- package/es/ToolBottomBar/index.less +75 -0
- package/es/const.d.ts.map +1 -0
- package/es/icon/ExportPDF.d.ts +3 -0
- package/es/icon/ExportPDF.d.ts.map +1 -0
- package/es/icon/ExportPDF.js +24 -0
- package/es/icon/TextCopy.d.ts +3 -0
- package/es/icon/TextCopy.d.ts.map +1 -0
- package/es/icon/TextCopy.js +25 -0
- package/es/icon/TextFileIcon.d.ts +3 -0
- package/es/icon/TextFileIcon.d.ts.map +1 -0
- package/es/icon/TextFileIcon.js +26 -0
- package/es/icon/TextIcon.d.ts +3 -0
- package/es/icon/TextIcon.d.ts.map +1 -0
- package/es/icon/TextIcon.js +28 -0
- package/es/index.d.ts.map +1 -0
- package/es/tools/UeditorResourceLoader.d.ts.map +1 -0
- package/es/tools/exportPDF.d.ts +27 -0
- package/es/tools/exportPDF.d.ts.map +1 -0
- package/es/tools/exportPDF.js +146 -0
- package/es/tools/filterHtmlNode.d.ts.map +1 -0
- package/es/tools/generateStylesFromSettings.d.ts +38 -0
- package/es/tools/generateStylesFromSettings.d.ts.map +1 -0
- package/es/tools/generateStylesFromSettings.js +24 -0
- package/es/tools/loadScript.d.ts.map +1 -0
- package/es/type.d.ts +21 -0
- package/es/type.d.ts.map +1 -0
- package/lib/LcdpUeditor.d.ts +10 -4
- package/lib/LcdpUeditor.js +62 -8
- package/lib/ToolBottomBar/FormatModal/index.d.ts +9 -0
- package/lib/ToolBottomBar/FormatModal/index.js +261 -0
- package/lib/ToolBottomBar/FormatModal/index.less +276 -0
- package/lib/ToolBottomBar/ProgressModal/index.d.ts +10 -0
- package/lib/ToolBottomBar/ProgressModal/index.js +73 -0
- package/lib/ToolBottomBar/ProgressModal/index.less +16 -0
- package/lib/ToolBottomBar/index.d.ts +33 -0
- package/lib/ToolBottomBar/index.js +235 -0
- package/lib/ToolBottomBar/index.less +75 -0
- package/lib/icon/ExportPDF.d.ts +3 -0
- package/lib/icon/ExportPDF.js +57 -0
- package/lib/icon/TextCopy.d.ts +3 -0
- package/lib/icon/TextCopy.js +39 -0
- package/lib/icon/TextFileIcon.d.ts +3 -0
- package/lib/icon/TextFileIcon.js +39 -0
- package/lib/icon/TextIcon.d.ts +3 -0
- package/lib/icon/TextIcon.js +39 -0
- package/lib/tools/exportPDF.d.ts +27 -0
- package/lib/tools/exportPDF.js +95 -0
- package/lib/tools/generateStylesFromSettings.d.ts +38 -0
- package/lib/tools/generateStylesFromSettings.js +77 -0
- package/lib/type.d.ts +21 -0
- package/package.json +8 -3
- package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
- package/ueditor-resource/dialogs/attachment/attachment.html +3 -3
- package/ueditor-resource/dialogs/attachment/attachment.js +1 -1
- package/ueditor-resource/dialogs/audio/audio.js +1 -1
- package/ueditor-resource/dialogs/background/background.html +2 -2
- package/ueditor-resource/dialogs/background/background.js +1 -1
- package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
- package/ueditor-resource/dialogs/contentimport/contentimport.js +1 -1
- package/ueditor-resource/dialogs/emotion/emotion.html +2 -2
- package/ueditor-resource/dialogs/emotion/emotion.js +1 -1
- package/ueditor-resource/dialogs/formula/formula.html +4 -4
- package/ueditor-resource/dialogs/formula/formula.js +1 -1
- package/ueditor-resource/dialogs/help/help.html +2 -2
- package/ueditor-resource/dialogs/help/help.js +1 -1
- package/ueditor-resource/dialogs/image/image.js +1 -1
- package/ueditor-resource/dialogs/insertframe/insertframe.html +1 -1
- package/ueditor-resource/dialogs/internal.js +1 -1
- package/ueditor-resource/dialogs/preview/preview.html +2 -2
- package/ueditor-resource/dialogs/scrawl/scrawl.html +2 -2
- package/ueditor-resource/dialogs/scrawl/scrawl.js +1 -1
- package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
- package/ueditor-resource/dialogs/searchreplace/searchreplace.js +1 -1
- package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
- package/ueditor-resource/dialogs/spechars/spechars.js +1 -1
- package/ueditor-resource/dialogs/table/edittable.html +2 -2
- package/ueditor-resource/dialogs/table/edittable.js +1 -1
- package/ueditor-resource/dialogs/table/edittd.html +1 -1
- package/ueditor-resource/dialogs/table/edittip.html +1 -1
- package/ueditor-resource/dialogs/template/template.html +2 -2
- package/ueditor-resource/dialogs/template/template.js +1 -1
- package/ueditor-resource/dialogs/video/video.js +1 -1
- package/ueditor-resource/dialogs/wordimage/wordimage.html +4 -4
- package/ueditor-resource/dialogs/wordimage/wordimage.js +1 -1
- package/ueditor-resource/plugins/browser-image-compression.js +9 -0
- package/ueditor-resource/plugins/demo/demo.js +3 -1
- package/ueditor-resource/themes/default/css/ueditor.css +1 -1
- package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3 -3
- package/ueditor-resource/third-party/clipboard/clipboard.js +1 -1
- package/ueditor-resource/third-party/codemirror/codemirror.js +3 -2
- package/ueditor-resource/third-party/jquery-3.5.1.js +3 -3
- package/ueditor-resource/third-party/jquery-3.5.1_1.js +3 -3
- package/ueditor-resource/ueditor.all.js +22 -19
- package/ueditor-resource/ueditor.config.js +1 -1
- package/ueditor-resource/ueditor.parse.js +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将HTML内容转换为PDF文档流
|
|
3
|
+
* @param htmlElement HTML元素
|
|
4
|
+
* @param options 配置选项
|
|
5
|
+
* @returns PDF文档的Blob对象
|
|
6
|
+
*/
|
|
7
|
+
export declare const html2pdf: (htmlElement: HTMLElement, options?: {
|
|
8
|
+
filename?: string;
|
|
9
|
+
margin?: number;
|
|
10
|
+
image?: {
|
|
11
|
+
type?: 'jpeg' | 'png';
|
|
12
|
+
quality?: number;
|
|
13
|
+
};
|
|
14
|
+
jsPDF?: {
|
|
15
|
+
orientation?: 'portrait' | 'landscape';
|
|
16
|
+
unit?: 'pt' | 'mm' | 'cm' | 'in';
|
|
17
|
+
format?: 'a4' | 'a3' | 'a5' | 'a0';
|
|
18
|
+
};
|
|
19
|
+
}, onProgress?: ((progress: number, title: string) => void) | undefined) => Promise<Blob>;
|
|
20
|
+
/**
|
|
21
|
+
* 将HTML元素转换为PDF文档流并下载
|
|
22
|
+
* @param dom HTML元素
|
|
23
|
+
* @param pageWidth 页面宽度
|
|
24
|
+
* @param fileName 文件名
|
|
25
|
+
* @returns 下载的PDF文件
|
|
26
|
+
*/
|
|
27
|
+
export declare const domloadPdf: (dom: HTMLElement, pageWidth: 'a4' | 'a3' | 'a5' | 'a0', fileName?: string, onProgress?: ((progress: number, title: string) => void) | undefined) => Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/tools/exportPDF.ts
|
|
30
|
+
var exportPDF_exports = {};
|
|
31
|
+
__export(exportPDF_exports, {
|
|
32
|
+
domloadPdf: () => domloadPdf,
|
|
33
|
+
html2pdf: () => html2pdf
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(exportPDF_exports);
|
|
36
|
+
var html2pdf = async (htmlElement, options = {}, onProgress) => {
|
|
37
|
+
var _a, _b, _c, _d, _e;
|
|
38
|
+
const { jsPDF: JS_PDF } = await import(
|
|
39
|
+
/* webpackChunkName: "jspdf" */
|
|
40
|
+
"jspdf"
|
|
41
|
+
);
|
|
42
|
+
const pdf = new JS_PDF({
|
|
43
|
+
orientation: ((_a = options.jsPDF) == null ? void 0 : _a.orientation) || "portrait",
|
|
44
|
+
unit: ((_b = options.jsPDF) == null ? void 0 : _b.unit) || "pt",
|
|
45
|
+
format: ((_c = options.jsPDF) == null ? void 0 : _c.format) || "a4"
|
|
46
|
+
});
|
|
47
|
+
const { default: html2canvas } = await import("html2canvas");
|
|
48
|
+
onProgress == null ? void 0 : onProgress(20, "渲染页面内容...");
|
|
49
|
+
const canvas = await html2canvas(htmlElement, {
|
|
50
|
+
scale: 2,
|
|
51
|
+
// 提高清晰度
|
|
52
|
+
useCORS: true,
|
|
53
|
+
// 允许跨域图片
|
|
54
|
+
logging: false
|
|
55
|
+
});
|
|
56
|
+
const imageType = ((_d = options.image) == null ? void 0 : _d.type) || "jpeg";
|
|
57
|
+
const imageQuality = ((_e = options.image) == null ? void 0 : _e.quality) || 1;
|
|
58
|
+
const imgData = canvas.toDataURL(`image/${imageType}`, imageQuality);
|
|
59
|
+
const margin = options.margin || 20;
|
|
60
|
+
const pdfWidth = pdf.internal.pageSize.getWidth();
|
|
61
|
+
const pdfHeight = pdf.internal.pageSize.getHeight();
|
|
62
|
+
const imgWidth = pdfWidth - margin * 2;
|
|
63
|
+
const imgHeight = canvas.height * imgWidth / canvas.width;
|
|
64
|
+
let heightLeft = imgHeight;
|
|
65
|
+
let position = margin;
|
|
66
|
+
const pageHeight = pdfHeight - margin * 2;
|
|
67
|
+
pdf.addImage(imgData, imageType.toUpperCase(), margin, position, imgWidth, imgHeight);
|
|
68
|
+
heightLeft -= pageHeight;
|
|
69
|
+
while (heightLeft >= 0) {
|
|
70
|
+
position = heightLeft - imgHeight;
|
|
71
|
+
pdf.addPage();
|
|
72
|
+
pdf.addImage(imgData, imageType.toUpperCase(), margin, position, imgWidth, imgHeight);
|
|
73
|
+
heightLeft -= pageHeight;
|
|
74
|
+
}
|
|
75
|
+
onProgress == null ? void 0 : onProgress(50, "转换HTML内容...");
|
|
76
|
+
return pdf.output("blob");
|
|
77
|
+
};
|
|
78
|
+
var domloadPdf = async (dom, pageWidth, fileName = "未命名", onProgress) => {
|
|
79
|
+
const { saveAs } = await import("file-saver");
|
|
80
|
+
onProgress == null ? void 0 : onProgress(5, "初始化...");
|
|
81
|
+
const blob = await html2pdf(dom, {
|
|
82
|
+
jsPDF: {
|
|
83
|
+
orientation: "portrait",
|
|
84
|
+
unit: "pt",
|
|
85
|
+
format: pageWidth
|
|
86
|
+
}
|
|
87
|
+
}, onProgress);
|
|
88
|
+
onProgress == null ? void 0 : onProgress(80, "生成PDF...");
|
|
89
|
+
return saveAs(blob, `${fileName}.pdf`);
|
|
90
|
+
};
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
domloadPdf,
|
|
94
|
+
html2pdf
|
|
95
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface HeadingStyle extends TextStyle {
|
|
2
|
+
marginTop: string;
|
|
3
|
+
marginBottom: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TextStyle {
|
|
6
|
+
fontSize: string;
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
fontWeight: string;
|
|
9
|
+
lineHeight: string;
|
|
10
|
+
color: string;
|
|
11
|
+
}
|
|
12
|
+
interface ListStyle extends TextStyle {
|
|
13
|
+
paddingLeft: string;
|
|
14
|
+
marginTop: string;
|
|
15
|
+
marginBottom: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FormatSettings {
|
|
18
|
+
headings: {
|
|
19
|
+
h1: HeadingStyle;
|
|
20
|
+
h2: HeadingStyle;
|
|
21
|
+
h3: HeadingStyle;
|
|
22
|
+
h4: HeadingStyle;
|
|
23
|
+
h5: HeadingStyle;
|
|
24
|
+
h6: HeadingStyle;
|
|
25
|
+
};
|
|
26
|
+
paragraph: TextStyle;
|
|
27
|
+
lists: {
|
|
28
|
+
ul: ListStyle;
|
|
29
|
+
ol: ListStyle;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 生成CSS样式内容
|
|
34
|
+
* @param settings 格式设置
|
|
35
|
+
* @returns CSS样式字符串
|
|
36
|
+
*/
|
|
37
|
+
export declare const generateStylesFromSettings: (settings: FormatSettings) => string;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/tools/generateStylesFromSettings.ts
|
|
20
|
+
var generateStylesFromSettings_exports = {};
|
|
21
|
+
__export(generateStylesFromSettings_exports, {
|
|
22
|
+
generateStylesFromSettings: () => generateStylesFromSettings
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(generateStylesFromSettings_exports);
|
|
25
|
+
var generateStylesFromSettings = (settings) => {
|
|
26
|
+
let css = "";
|
|
27
|
+
Object.entries(settings.headings).forEach(([heading, style]) => {
|
|
28
|
+
css += `
|
|
29
|
+
${heading} {
|
|
30
|
+
font-family: ${style.fontFamily};
|
|
31
|
+
font-size: ${style.fontSize};
|
|
32
|
+
font-weight: ${style.fontWeight};
|
|
33
|
+
line-height: ${style.lineHeight};
|
|
34
|
+
color: ${style.color};
|
|
35
|
+
margin-top: ${style.marginTop};
|
|
36
|
+
margin-bottom: ${style.marginBottom};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
css += `
|
|
41
|
+
p {
|
|
42
|
+
font-family: ${settings.paragraph.fontFamily};
|
|
43
|
+
font-size: ${settings.paragraph.fontSize};
|
|
44
|
+
font-weight: ${settings.paragraph.fontWeight};
|
|
45
|
+
line-height: ${settings.paragraph.lineHeight};
|
|
46
|
+
color: ${settings.paragraph.color};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
css += `
|
|
50
|
+
ul {
|
|
51
|
+
font-family: ${settings.lists.ul.fontFamily};
|
|
52
|
+
font-size: ${settings.lists.ul.fontSize};
|
|
53
|
+
font-weight: ${settings.lists.ul.fontWeight};
|
|
54
|
+
line-height: ${settings.lists.ul.lineHeight};
|
|
55
|
+
color: ${settings.lists.ul.color};
|
|
56
|
+
padding-left: ${settings.lists.ul.paddingLeft};
|
|
57
|
+
margin-top: ${settings.lists.ul.marginTop};
|
|
58
|
+
margin-bottom: ${settings.lists.ul.marginBottom};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ol {
|
|
62
|
+
font-family: ${settings.lists.ol.fontFamily};
|
|
63
|
+
font-size: ${settings.lists.ol.fontSize};
|
|
64
|
+
font-weight: ${settings.lists.ol.fontWeight};
|
|
65
|
+
line-height: ${settings.lists.ol.lineHeight};
|
|
66
|
+
color: ${settings.lists.ol.color};
|
|
67
|
+
padding-left: ${settings.lists.ol.paddingLeft};
|
|
68
|
+
margin-top: ${settings.lists.ol.marginTop};
|
|
69
|
+
margin-bottom: ${settings.lists.ol.marginBottom};
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
return css;
|
|
73
|
+
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
generateStylesFromSettings
|
|
77
|
+
});
|
package/lib/type.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { FormatSettings } from './tools/generateStylesFromSettings';
|
|
2
3
|
interface IUeditorStype extends React.CSSProperties {
|
|
3
4
|
toolbarColor?: string;
|
|
4
5
|
}
|
|
@@ -68,6 +69,10 @@ export interface ILcdpUeditorProps {
|
|
|
68
69
|
*/
|
|
69
70
|
videoAllowFiles?: string[];
|
|
70
71
|
maximumWords?: number;
|
|
72
|
+
/**
|
|
73
|
+
* 导出文件名
|
|
74
|
+
*/
|
|
75
|
+
exportFileName?: string;
|
|
71
76
|
};
|
|
72
77
|
toolbars?: string[][];
|
|
73
78
|
/**
|
|
@@ -100,6 +105,22 @@ export interface ILcdpUeditorProps {
|
|
|
100
105
|
* @param val 编辑器内容
|
|
101
106
|
*/
|
|
102
107
|
onChange?(val: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* 样式前缀
|
|
110
|
+
*/
|
|
111
|
+
prefixCls?: string;
|
|
112
|
+
/**
|
|
113
|
+
* 格式设置变化
|
|
114
|
+
*/
|
|
115
|
+
onFormatChange?(val: FormatSettings): void;
|
|
116
|
+
/**
|
|
117
|
+
* 默认格式设置
|
|
118
|
+
*/
|
|
119
|
+
defaultFormatSetting?: FormatSettings;
|
|
120
|
+
/**
|
|
121
|
+
* 底部功能类型
|
|
122
|
+
*/
|
|
123
|
+
bottomTypes?: Array<'chineseCount' | 'charCount' | 'pageWidth' | 'formatSetting' | 'exportPdf' | 'fullScreen' | 'copy'>;
|
|
103
124
|
}
|
|
104
125
|
export interface ILcdpUeditorInst {
|
|
105
126
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/lcdp-ueditor-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -18,14 +18,19 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/lodash": "^4.14.180",
|
|
21
|
-
"father": "^4.1.9"
|
|
21
|
+
"father": "^4.1.9",
|
|
22
|
+
"@types/file-saver": "^2.0.5"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"react": "^16.12.0 || ^17.0.0",
|
|
25
26
|
"lodash": "^4.0.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@babel/runtime": "7.23.2"
|
|
29
|
+
"@babel/runtime": "7.23.2",
|
|
30
|
+
"jspdf": "^2.5.1",
|
|
31
|
+
"file-saver": "^2.0.5",
|
|
32
|
+
"antd": "4.24.13",
|
|
33
|
+
"html2canvas": "^1.4.1"
|
|
29
34
|
},
|
|
30
35
|
"publishConfig": {
|
|
31
36
|
"access": "public",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<div class="content">
|
|
38
38
|
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value=""/>
|
|
39
39
|
</div>
|
|
40
|
-
<script type="text/javascript" src="../internal.js?
|
|
40
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
41
41
|
<script type="text/javascript">
|
|
42
42
|
var anchorInput = $G('anchorName'),
|
|
43
43
|
node = editor.selection.getRange().getClosedNode();
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<title>ueditor图片对话框</title>
|
|
6
|
-
<script type="text/javascript" src="../internal.js?
|
|
6
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
7
7
|
|
|
8
8
|
<!-- jquery -->
|
|
9
|
-
<script type="text/javascript" src="../../third-party/jquery-3.5.1.js?
|
|
9
|
+
<script type="text/javascript" src="../../third-party/jquery-3.5.1.js?cdb3992e"></script>
|
|
10
10
|
|
|
11
11
|
<!-- webuploader -->
|
|
12
12
|
<script src="../../third-party/webuploader/webuploader.js?5e398948"></script>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
|
58
|
-
<script type="text/javascript" src="attachment.js?
|
|
58
|
+
<script type="text/javascript" src="attachment.js?5f0b87d6"></script>
|
|
59
59
|
|
|
60
60
|
</body>
|
|
61
61
|
</html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
!function(){function initTabs(){$G("tabhead").querySelector('[data-content-id="online"]').style.display="none";for(var a=$G("tabhead").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(a){var b=a.target||a.srcElement;setTabFocus(b.getAttribute("data-content-id"))});setTabFocus("upload")}function setTabFocus(a){if(a){var b,c,d=$G("tabhead").children;for(b=0;b<d.length;b++)c=d[b].getAttribute("data-content-id"),c==a?(domUtils.addClass(d[b],"focus"),domUtils.addClass($G(c),"focus")):(domUtils.removeClasses(d[b],"focus"),domUtils.removeClasses($G(c),"focus"));switch(a){case"upload":uploadFile=uploadFile||new UploadFile("queueList");break;case"online":onlineFile=onlineFile||new OnlineFile("fileList")}}}function initButtons(){dialog.onok=function(){for(var a,b=[],c=$G("tabhead").children,d=0;d<c.length;d++)if(domUtils.hasClass(c[d],"focus")){a=c[d].getAttribute("data-content-id");break}switch(a){case"upload":b=uploadFile.getInsertList();var e=uploadFile.getQueueCount();if(e)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,e)+"</span>"),!1;break;case"online":b=onlineFile.getInsertList()}editor.execCommand("insertfile",b)}}function UploadFile(a){this.$wrap=a.constructor==String?$("#"+a):$(a),this.init()}function OnlineFile(a){this.container=utils.isString(a)?document.getElementById(a):a,this.init()}var uploadFile,onlineFile;window.onload=function(){initTabs(),initButtons()},UploadFile.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function a(a){var b=h('<li id="'+a.id+'"><p class="title">'+a.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),c=h('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo(b),d=b.find("p.progress span"),e=b.find("p.imgWrap"),g=h('<p class="error"></p>').hide().appendTo(b),i=function(a){switch(a){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}g.text(text).show()};"invalid"===a.getStatus()?i(a.statusText):(e.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+a.ext.toLowerCase()+"|")==-1?e.empty().addClass("notimage").append('<i class="file-preview file-type-'+a.ext.toLowerCase()+'"></i><span class="file-title" title="'+a.name+'">'+a.name+"</span>"):browser.ie&&browser.version<=7?e.text(lang.uploadNoPreview):f.makeThumb(a,function(a,b){if(a||!b)e.text(lang.uploadNoPreview);else{var c=h('<img src="'+b+'">');e.empty().append(c),c.on("error",function(){e.text(lang.uploadNoPreview)})}},t,u),w[a.id]=[a.size,0],a.rotation=0,a.ext&&A.indexOf(a.ext.toLowerCase())!=-1||(i("not_allow_type"),f.removeFile(a))),a.on("statuschange",function(e,f){"progress"===f?d.hide().width(0):"queued"===f&&(b.off("mouseenter mouseleave"),c.remove()),"error"===e||"invalid"===e?(i(a.statusText),w[a.id][1]=1):"interrupt"===e?i("interrupt"):"queued"===e?w[a.id][1]=0:"progress"===e&&(g.hide(),d.css("display","block")),b.removeClass("state-"+f).addClass("state-"+e)}),b.on("mouseenter",function(){c.stop().animate({height:30})}),b.on("mouseleave",function(){c.stop().animate({height:0})}),c.on("click","span",function(){var b,c=h(this).index();switch(c){case 0:return void f.removeFile(a);case 1:a.rotation+=90;break;case 2:a.rotation-=90}x?(b="rotate("+a.rotation+"deg)",e.css({"-webkit-transform":b,"-mos-transform":b,"-o-transform":b,transform:b})):e.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(a.rotation/90%4+4)%4+")")}),b.insertBefore(n)}function b(a){var b=h("#"+a.id);delete w[a.id],c(),b.off().find(".file-panel").off().end().remove()}function c(){var a,b=0,c=0,d=p.children();h.each(w,function(a,d){c+=d[0],b+=d[0]*d[1]}),a=c?b/c:0,d.eq(0).text(Math.round(100*a)+"%"),d.eq(1).css("width",Math.round(100*a)+"%"),e()}function d(a,b){if(a!=v){var c=f.getStats();switch(m.removeClass("state-"+v),m.addClass("state-"+a),a){case"pedding":j.addClass("element-invisible"),k.addClass("element-invisible"),o.removeClass("element-invisible"),p.hide(),l.hide(),f.refresh();break;case"ready":o.addClass("element-invisible"),j.removeClass("element-invisible"),k.removeClass("element-invisible"),p.hide(),l.show(),m.text(lang.uploadStart),f.refresh();break;case"uploading":p.show(),l.hide(),m.text(lang.uploadPause);break;case"paused":p.show(),l.hide(),m.text(lang.uploadContinue);break;case"confirm":if(p.show(),l.hide(),m.text(lang.uploadStart),c=f.getStats(),c.successNum&&!c.uploadFailNum)return void d("finish");break;case"finish":p.hide(),l.show(),c.uploadFailNum?m.text(lang.uploadRetry):m.text(lang.uploadStart)}v=a,e()}g.getQueueCount()?m.removeClass("disabled"):m.addClass("disabled")}function e(){var a,b="";"ready"===v?b=lang.updateStatusReady.replace("_",q).replace("_KB",WebUploader.formatSize(r)):"confirm"===v?(a=f.getStats(),a.uploadFailNum&&(b=lang.updateStatusConfirm.replace("_",a.successNum).replace("_",a.successNum))):(a=f.getStats(),b=lang.updateStatusFinish.replace("_",q).replace("_KB",WebUploader.formatSize(r)).replace("_",a.successNum),a.uploadFailNum&&(b+=lang.updateStatusError.replace("_",a.uploadFailNum))),l.html(b)}var f,g=this,h=jQuery,i=g.$wrap,j=i.find(".filelist"),k=i.find(".statusBar"),l=k.find(".info"),m=i.find(".uploadBtn"),n=(i.find(".filePickerBtn"),i.find(".filePickerBlock")),o=i.find(".placeholder"),p=k.find(".progress").hide(),q=0,r=0,s=window.devicePixelRatio||1,t=113*s,u=113*s,v="",w={},x=function(){var a=document.createElement("p").style,b="transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"OTransition"in a;return a=null,b}(),y=editor.getActionUrl(editor.getOpt("fileActionName")),z=editor.getOpt("fileMaxSize"),A=(editor.getOpt("fileAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return m.hide(),WebUploader.Uploader.support()?(!editor.getOpt("fileActionName"),f=g.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:y,fileVal:editor.getOpt("fileFieldName"),duplicate:!0,fileSingleSizeLimit:z,headers:editor.getOpt("serverHeaders")||{},compress:!1}),f.addButton({id:"#filePickerBlock"}),f.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),d("pedding"),f.on("beforeFileQueued",function(a){return!!(a.ext&&A.indexOf(a.ext.toLowerCase())!=-1&&a.size<=z)}),f.on("fileQueued",function(b){b.ext&&A.indexOf(b.ext.toLowerCase())!=-1&&b.size<=z&&(q++,r+=b.size),1===q&&(o.addClass("element-invisible"),k.show()),a(b);var c=editor.getOpt("uploadFunction");"function"==typeof c&&("ready"===v?d("uploading"):(d("ready"),d("uploading")),b.setStatus("progress"),f.trigger("uploadProgress",b,0),c(b.source.source).then(function(a){f.trigger("uploadProgress",b,1),b.setStatus("complete"),d("finish"),f.trigger("uploadSuccess",b,a),f.trigger("uploadComplete",b)}))}),f.on("fileDequeued",function(a){a.ext&&A.indexOf(a.ext.toLowerCase())!=-1&&a.size<=z&&(q--,r-=a.size),b(a),c()}),f.on("filesQueued",function(a){f.isInProgress()||"pedding"!=v&&"finish"!=v&&"confirm"!=v&&"ready"!=v||d("ready"),c()}),f.on("all",function(a,b){switch(a){case"uploadFinished":d("confirm",b);break;case"startUpload":var c=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",e=utils.formatUrl(y+(y.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+c);f.option("server",e),d("uploading",b);break;case"stopUpload":d("paused",b)}}),f.on("uploadBeforeSend",function(a,b,c){y.toLowerCase().indexOf("jsp")!=-1&&(c.X_Requested_With="XMLHttpRequest")}),f.on("uploadProgress",function(a,b){var d=h("#"+a.id),e=d.find(".progress span");e.css("width",100*b+"%"),w[a.id][1]=b,c()}),f.on("uploadSuccess",function(a,b){var c=h("#"+a.id);try{"SUCCESS"==b.state?(g.fileList.push(b),c.append('<span class="success"></span>'),editor.fireEvent("uploadsuccess",{res:b,type:"file"})):c.find(".error").text(b.state).show()}catch(d){c.find(".error").text(lang.errorServerUpload).show()}}),f.on("uploadError",function(a,b){}),f.on("error",function(b,c){"Q_TYPE_DENIED"!=b&&"F_EXCEED_SIZE"!=b||a(c)}),f.on("uploadComplete",function(a,b){}),m.on("click",function(){return!h(this).hasClass("disabled")&&void("ready"===v?f.upload():"paused"===v?f.upload():"uploading"===v&&f.stop())}),m.addClass("state-"+v),void c()):void h("#filePickerReady").after(h("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var a,b,c,d=0,e=this.uploader.getFiles();for(b=0;a=e[b++];)c=a.getStatus(),"queued"!=c&&"uploading"!=c&&"progress"!=c||d++;return d},getInsertList:function(){var a,b,c,d=[],e=editor.getOpt("fileUrlPrefix");for(a=0;a<this.fileList.length;a++)c=this.fileList[a],b=c.url,d.push({title:c.original||b.substr(b.lastIndexOf("/")+1),url:e+b});return d}},OnlineFile.prototype={init:function(){this.initContainer(),this.initEvents(),this.initData()},initContainer:function(){this.container.innerHTML="",this.list=document.createElement("ul"),this.clearFloat=document.createElement("li"),domUtils.addClass(this.list,"list"),domUtils.addClass(this.clearFloat,"clearFloat"),this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var a=this;domUtils.on($G("fileList"),"scroll",function(b){var c=this;c.scrollHeight-(c.offsetHeight+c.scrollTop)<10&&a.getFileData()}),domUtils.on(this.list,"click",function(a){var b=a.target||a.srcElement,c=b.parentNode;"li"==c.tagName.toLowerCase()&&(domUtils.hasClass(c,"selected")?domUtils.removeClasses(c,"selected"):domUtils.addClass(c,"selected"))})},initData:function(){this.state=0,this.listSize=editor.getOpt("fileManagerListSize"),this.listIndex=0,this.listEnd=!1,this.getFileData()},getFileData:function(){var _this=this;_this.listEnd||this.isLoadingData||(this.isLoadingData=!0,ajax.request(editor.getActionUrl(editor.getOpt("fileManagerActionName")),{timeout:1e5,data:utils.extend({start:this.listIndex,size:this.listSize},editor.queryCommandValue("serverparam")),headers:editor.options.serverHeaders||{},method:"get",onsuccess:function(r){try{var json=eval("("+r.responseText+")");"SUCCESS"==json.state&&(_this.pushData(json.list),_this.listIndex=parseInt(json.start)+parseInt(json.list.length),_this.listIndex>=json.total&&(_this.listEnd=!0),_this.isLoadingData=!1)}catch(e){if(r.responseText.indexOf("ue_separate_ue")!=-1){var list=r.responseText.split(r.responseText);_this.pushData(list),_this.listIndex=parseInt(list.length),_this.listEnd=!0,_this.isLoadingData=!1}}},onerror:function(){_this.isLoadingData=!1}}))},pushData:function(a){var b,c,d,e,f,g=this,h=editor.getOpt("fileManagerUrlPrefix");for(b=0;b<a.length;b++)if(a[b]&&a[b].url){if(c=document.createElement("li"),f=document.createElement("span"),d=a[b].url.substr(a[b].url.lastIndexOf(".")+1),"png|jpg|jpeg|gif|bmp".indexOf(d)!=-1)e=document.createElement("img"),domUtils.on(e,"load",function(a){return function(){g.scale(a,a.parentNode.offsetWidth,a.parentNode.offsetHeight)}}(e)),e.width=113,e.setAttribute("src",h+a[b].url+(a[b].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36));else{var i=document.createElement("i"),j=document.createElement("span");j.innerHTML=a[b].original||a[b].url.substr(a[b].url.lastIndexOf("/")+1),e=document.createElement("div"),e.appendChild(i),e.appendChild(j),domUtils.addClass(e,"file-wrapper"),domUtils.addClass(j,"file-title"),domUtils.addClass(i,"file-type-"+d),domUtils.addClass(i,"file-preview")}domUtils.addClass(f,"icon"),c.setAttribute("data-url",h+a[b].url),a[b].original&&c.setAttribute("data-title",a[b].original),c.appendChild(e),c.appendChild(f),this.list.insertBefore(c,this.clearFloat)}},scale:function(a,b,c,d){var e=a.width,f=a.height;"justify"==d?e>=f?(a.width=b,a.height=c*f/e,a.style.marginLeft="-"+parseInt((a.width-b)/2)+"px"):(a.width=b*e/f,a.height=c,a.style.marginTop="-"+parseInt((a.height-c)/2)+"px"):e>=f?(a.width=b*e/f,a.height=c,a.style.marginLeft="-"+parseInt((a.width-b)/2)+"px"):(a.width=b,a.height=c*f/e,a.style.marginTop="-"+parseInt((a.height-c)/2)+"px")},getInsertList:function(){var a,b=this.list.children,c=[];for(a=0;a<b.length;a++)if(domUtils.hasClass(b[a],"selected")){var d=b[a].getAttribute("data-url"),e=b[a].getAttribute("data-title")||d.substr(d.lastIndexOf("/")+1);c.push({title:e,url:d})}return c}}}();
|
|
2
|
+
!function(){function initTabs(){$G("tabhead").querySelector('[data-content-id="online"]').style.display="none";for(var tabs=$G("tabhead").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){var target=e.target||e.srcElement;setTabFocus(target.getAttribute("data-content-id"))});setTabFocus("upload")}function setTabFocus(id){if(id){var i,bodyId,tabs=$G("tabhead").children;for(i=0;i<tabs.length;i++)bodyId=tabs[i].getAttribute("data-content-id"),bodyId==id?(domUtils.addClass(tabs[i],"focus"),domUtils.addClass($G(bodyId),"focus")):(domUtils.removeClasses(tabs[i],"focus"),domUtils.removeClasses($G(bodyId),"focus"));switch(id){case"upload":uploadFile=uploadFile||new UploadFile("queueList");break;case"online":onlineFile=onlineFile||new OnlineFile("fileList")}}}function initButtons(){dialog.onok=function(){for(var id,list=[],tabs=$G("tabhead").children,i=0;i<tabs.length;i++)if(domUtils.hasClass(tabs[i],"focus")){id=tabs[i].getAttribute("data-content-id");break}switch(id){case"upload":list=uploadFile.getInsertList();var count=uploadFile.getQueueCount();if(count)return $(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,count)+"</span>"),!1;break;case"online":list=onlineFile.getInsertList()}editor.execCommand("insertfile",list)}}function UploadFile(target){this.$wrap=target.constructor==String?$("#"+target):$(target),this.init()}function OnlineFile(target){this.container=utils.isString(target)?document.getElementById(target):target,this.init()}var uploadFile,onlineFile;window.onload=function(){initTabs(),initButtons()},UploadFile.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function addFile(file){var $li=$('<li id="'+file.id+'"><p class="title">'+file.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),$btns=$('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo($li),$prgress=$li.find("p.progress span"),$wrap=$li.find("p.imgWrap"),$info=$('<p class="error"></p>').hide().appendTo($li),showError=function(code){switch(code){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}$info.text(text).show()};"invalid"===file.getStatus()?showError(file.statusText):($wrap.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+file.ext.toLowerCase()+"|")==-1?$wrap.empty().addClass("notimage").append('<i class="file-preview file-type-'+file.ext.toLowerCase()+'"></i><span class="file-title" title="'+file.name+'">'+file.name+"</span>"):browser.ie&&browser.version<=7?$wrap.text(lang.uploadNoPreview):uploader.makeThumb(file,function(error,src){if(error||!src)$wrap.text(lang.uploadNoPreview);else{var $img=$('<img src="'+src+'">');$wrap.empty().append($img),$img.on("error",function(){$wrap.text(lang.uploadNoPreview)})}},thumbnailWidth,thumbnailHeight),percentages[file.id]=[file.size,0],file.rotation=0,file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1||(showError("not_allow_type"),uploader.removeFile(file))),file.on("statuschange",function(cur,prev){"progress"===prev?$prgress.hide().width(0):"queued"===prev&&($li.off("mouseenter mouseleave"),$btns.remove()),"error"===cur||"invalid"===cur?(showError(file.statusText),percentages[file.id][1]=1):"interrupt"===cur?showError("interrupt"):"queued"===cur?percentages[file.id][1]=0:"progress"===cur&&($info.hide(),$prgress.css("display","block")),$li.removeClass("state-"+prev).addClass("state-"+cur)}),$li.on("mouseenter",function(){$btns.stop().animate({height:30})}),$li.on("mouseleave",function(){$btns.stop().animate({height:0})}),$btns.on("click","span",function(){var deg,index=$(this).index();switch(index){case 0:return void uploader.removeFile(file);case 1:file.rotation+=90;break;case 2:file.rotation-=90}supportTransition?(deg="rotate("+file.rotation+"deg)",$wrap.css({"-webkit-transform":deg,"-mos-transform":deg,"-o-transform":deg,transform:deg})):$wrap.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(file.rotation/90%4+4)%4+")")}),$li.insertBefore($filePickerBlock)}function removeFile(file){var $li=$("#"+file.id);delete percentages[file.id],updateTotalProgress(),$li.off().find(".file-panel").off().end().remove()}function updateTotalProgress(){var percent,loaded=0,total=0,spans=$progress.children();$.each(percentages,function(k,v){total+=v[0],loaded+=v[0]*v[1]}),percent=total?loaded/total:0,spans.eq(0).text(Math.round(100*percent)+"%"),spans.eq(1).css("width",Math.round(100*percent)+"%"),updateStatus()}function setState(val,files){if(val!=state){var stats=uploader.getStats();switch($upload.removeClass("state-"+state),$upload.addClass("state-"+val),val){case"pedding":$queue.addClass("element-invisible"),$statusBar.addClass("element-invisible"),$placeHolder.removeClass("element-invisible"),$progress.hide(),$info.hide(),uploader.refresh();break;case"ready":$placeHolder.addClass("element-invisible"),$queue.removeClass("element-invisible"),$statusBar.removeClass("element-invisible"),$progress.hide(),$info.show(),$upload.text(lang.uploadStart),uploader.refresh();break;case"uploading":$progress.show(),$info.hide(),$upload.text(lang.uploadPause);break;case"paused":$progress.show(),$info.hide(),$upload.text(lang.uploadContinue);break;case"confirm":if($progress.show(),$info.hide(),$upload.text(lang.uploadStart),stats=uploader.getStats(),stats.successNum&&!stats.uploadFailNum)return void setState("finish");break;case"finish":$progress.hide(),$info.show(),stats.uploadFailNum?$upload.text(lang.uploadRetry):$upload.text(lang.uploadStart)}state=val,updateStatus()}_this.getQueueCount()?$upload.removeClass("disabled"):$upload.addClass("disabled")}function updateStatus(){var stats,text="";"ready"===state?text=lang.updateStatusReady.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)):"confirm"===state?(stats=uploader.getStats(),stats.uploadFailNum&&(text=lang.updateStatusConfirm.replace("_",stats.successNum).replace("_",stats.successNum))):(stats=uploader.getStats(),text=lang.updateStatusFinish.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)).replace("_",stats.successNum),stats.uploadFailNum&&(text+=lang.updateStatusError.replace("_",stats.uploadFailNum))),$info.html(text)}var uploader,_this=this,$=jQuery,$wrap=_this.$wrap,$queue=$wrap.find(".filelist"),$statusBar=$wrap.find(".statusBar"),$info=$statusBar.find(".info"),$upload=$wrap.find(".uploadBtn"),$filePickerBlock=($wrap.find(".filePickerBtn"),$wrap.find(".filePickerBlock")),$placeHolder=$wrap.find(".placeholder"),$progress=$statusBar.find(".progress").hide(),fileCount=0,fileSize=0,ratio=window.devicePixelRatio||1,thumbnailWidth=113*ratio,thumbnailHeight=113*ratio,state="",percentages={},supportTransition=function(){var s=document.createElement("p").style,r="transition"in s||"WebkitTransition"in s||"MozTransition"in s||"msTransition"in s||"OTransition"in s;return s=null,r}(),actionUrl=editor.getActionUrl(editor.getOpt("fileActionName")),fileMaxSize=editor.getOpt("fileMaxSize"),acceptExtensions=(editor.getOpt("fileAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return $upload.hide(),WebUploader.Uploader.support()?(!editor.getOpt("fileActionName"),uploader=_this.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:actionUrl,fileVal:editor.getOpt("fileFieldName"),duplicate:!0,fileSingleSizeLimit:fileMaxSize,headers:editor.getOpt("serverHeaders")||{},compress:!1}),uploader.addButton({id:"#filePickerBlock"}),uploader.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),setState("pedding"),uploader.on("beforeFileQueued",function(file){return!!(file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1&&file.size<=fileMaxSize)}),uploader.on("fileQueued",function(file){file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1&&file.size<=fileMaxSize&&(fileCount++,fileSize+=file.size),1===fileCount&&($placeHolder.addClass("element-invisible"),$statusBar.show()),addFile(file);var uploadFunc=editor.getOpt("uploadFunction");"function"==typeof uploadFunc&&("ready"===state?setState("uploading"):(setState("ready"),setState("uploading")),file.setStatus("progress"),uploader.trigger("uploadProgress",file,0),uploadFunc(file.source.source).then(function(response){uploader.trigger("uploadProgress",file,1),file.setStatus("complete"),setState("finish"),uploader.trigger("uploadSuccess",file,response),uploader.trigger("uploadComplete",file)}))}),uploader.on("fileDequeued",function(file){file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1&&file.size<=fileMaxSize&&(fileCount--,fileSize-=file.size),removeFile(file),updateTotalProgress()}),uploader.on("filesQueued",function(file){uploader.isInProgress()||"pedding"!=state&&"finish"!=state&&"confirm"!=state&&"ready"!=state||setState("ready"),updateTotalProgress()}),uploader.on("all",function(type,files){switch(type){case"uploadFinished":setState("confirm",files);break;case"startUpload":var params=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",url=utils.formatUrl(actionUrl+(actionUrl.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+params);uploader.option("server",url),setState("uploading",files);break;case"stopUpload":setState("paused",files)}}),uploader.on("uploadBeforeSend",function(file,data,header){actionUrl.toLowerCase().indexOf("jsp")!=-1&&(header.X_Requested_With="XMLHttpRequest")}),uploader.on("uploadProgress",function(file,percentage){var $li=$("#"+file.id),$percent=$li.find(".progress span");$percent.css("width",100*percentage+"%"),percentages[file.id][1]=percentage,updateTotalProgress()}),uploader.on("uploadSuccess",function(file,json){var $file=$("#"+file.id);try{"SUCCESS"==json.state?(_this.fileList.push(json),$file.append('<span class="success"></span>'),editor.fireEvent("uploadsuccess",{res:json,type:"file"})):$file.find(".error").text(json.state).show()}catch(e){$file.find(".error").text(lang.errorServerUpload).show()}}),uploader.on("uploadError",function(file,code){}),uploader.on("error",function(code,file){"Q_TYPE_DENIED"!=code&&"F_EXCEED_SIZE"!=code||addFile(file)}),uploader.on("uploadComplete",function(file,ret){}),$upload.on("click",function(){return!$(this).hasClass("disabled")&&void("ready"===state?uploader.upload():"paused"===state?uploader.upload():"uploading"===state&&uploader.stop())}),$upload.addClass("state-"+state),void updateTotalProgress()):void $("#filePickerReady").after($("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var file,i,status,readyFile=0,files=this.uploader.getFiles();for(i=0;file=files[i++];)status=file.getStatus(),"queued"!=status&&"uploading"!=status&&"progress"!=status||readyFile++;return readyFile},getInsertList:function(){var i,link,data,list=[],prefix=editor.getOpt("fileUrlPrefix");for(i=0;i<this.fileList.length;i++)data=this.fileList[i],link=data.url,list.push({title:data.original||link.substr(link.lastIndexOf("/")+1),url:prefix+link});return list}},OnlineFile.prototype={init:function(){this.initContainer(),this.initEvents(),this.initData()},initContainer:function(){this.container.innerHTML="",this.list=document.createElement("ul"),this.clearFloat=document.createElement("li"),domUtils.addClass(this.list,"list"),domUtils.addClass(this.clearFloat,"clearFloat"),this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var _this=this;domUtils.on($G("fileList"),"scroll",function(e){var panel=this;panel.scrollHeight-(panel.offsetHeight+panel.scrollTop)<10&&_this.getFileData()}),domUtils.on(this.list,"click",function(e){var target=e.target||e.srcElement,li=target.parentNode;"li"==li.tagName.toLowerCase()&&(domUtils.hasClass(li,"selected")?domUtils.removeClasses(li,"selected"):domUtils.addClass(li,"selected"))})},initData:function(){this.state=0,this.listSize=editor.getOpt("fileManagerListSize"),this.listIndex=0,this.listEnd=!1,this.getFileData()},getFileData:function(){var _this=this;_this.listEnd||this.isLoadingData||(this.isLoadingData=!0,ajax.request(editor.getActionUrl(editor.getOpt("fileManagerActionName")),{timeout:1e5,data:utils.extend({start:this.listIndex,size:this.listSize},editor.queryCommandValue("serverparam")),headers:editor.options.serverHeaders||{},method:"get",onsuccess:function(r){try{var json=eval("("+r.responseText+")");"SUCCESS"==json.state&&(_this.pushData(json.list),_this.listIndex=parseInt(json.start)+parseInt(json.list.length),_this.listIndex>=json.total&&(_this.listEnd=!0),_this.isLoadingData=!1)}catch(e){if(r.responseText.indexOf("ue_separate_ue")!=-1){var list=r.responseText.split(r.responseText);_this.pushData(list),_this.listIndex=parseInt(list.length),_this.listEnd=!0,_this.isLoadingData=!1}}},onerror:function(){_this.isLoadingData=!1}}))},pushData:function(list){var i,item,filetype,preview,icon,_this=this,urlPrefix=editor.getOpt("fileManagerUrlPrefix");for(i=0;i<list.length;i++)if(list[i]&&list[i].url){if(item=document.createElement("li"),icon=document.createElement("span"),filetype=list[i].url.substr(list[i].url.lastIndexOf(".")+1),"png|jpg|jpeg|gif|bmp".indexOf(filetype)!=-1)preview=document.createElement("img"),domUtils.on(preview,"load",function(image){return function(){_this.scale(image,image.parentNode.offsetWidth,image.parentNode.offsetHeight)}}(preview)),preview.width=113,preview.setAttribute("src",urlPrefix+list[i].url+(list[i].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36));else{var ic=document.createElement("i"),textSpan=document.createElement("span");textSpan.innerHTML=list[i].original||list[i].url.substr(list[i].url.lastIndexOf("/")+1),preview=document.createElement("div"),preview.appendChild(ic),preview.appendChild(textSpan),domUtils.addClass(preview,"file-wrapper"),domUtils.addClass(textSpan,"file-title"),domUtils.addClass(ic,"file-type-"+filetype),domUtils.addClass(ic,"file-preview")}domUtils.addClass(icon,"icon"),item.setAttribute("data-url",urlPrefix+list[i].url),list[i].original&&item.setAttribute("data-title",list[i].original),item.appendChild(preview),item.appendChild(icon),this.list.insertBefore(item,this.clearFloat)}},scale:function(img,w,h,type){var ow=img.width,oh=img.height;"justify"==type?ow>=oh?(img.width=w,img.height=h*oh/ow,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w*ow/oh,img.height=h,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px"):ow>=oh?(img.width=w*ow/oh,img.height=h,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w,img.height=h*oh/ow,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px")},getInsertList:function(){var i,lis=this.list.children,list=[];for(i=0;i<lis.length;i++)if(domUtils.hasClass(lis[i],"selected")){var url=lis[i].getAttribute("data-url"),title=lis[i].getAttribute("data-title")||url.substr(url.lastIndexOf("/")+1);list.push({title:title,url:url})}return list}}}();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
!function(){function a(){for(var a=$G("tabHeads").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(b){var c,d,e=b.target||b.srcElement;for(c=0;c<a.length;c++)d=a[c].getAttribute("data-content-id"),a[c]==e?(domUtils.addClass(a[c],"focus"),domUtils.addClass($G(d),"focus")):(domUtils.removeClasses(a[c],"focus"),domUtils.removeClasses($G(d),"focus"))});r.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),r.selectCallback&&($G("audioSelect").style.display="inline-block",domUtils.on($G("audioSelect"),"click",function(a){r.selectCallback(editor,function(a){a&&($G("audioUrl").value=a.path,k(a.path))})}))}function b(){g(["audioFloat","upload_alignment"]),i($G("audioUrl")),c(),function(){var a,b=editor.selection.getRange().getClosedNode();if(b&&b.className){var c="edui-faked-audio"==b.className,e=b.className.indexOf("edui-upload-audio")!=-1;if(c||e){$G("audioUrl").value=a=b.getAttribute("_url");var f=domUtils.getComputedStyle(b,"float"),g=domUtils.getComputedStyle(b.parentNode,"text-align");d("center"===g?"center":f)}e&&(q=!0)}k(a)}()}function c(){dialog.onok=function(){$G("preview").innerHTML="";var a=f("tabHeads","tabSrc");switch(a){case"audio":return e();case"upload":return l()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function d(a){for(var b,c=$G("audioFloat").children,d=0;b=c[d++];)b.getAttribute("name")==a?"focus"!=b.className&&(b.className="focus"):"focus"==b.className&&(b.className="")}function e(){var a=$G("audioUrl").value;f("audioFloat","name");return!!a&&void editor.execCommand("insertaudio",{url:a},q?"upload":null)}function f(a,b){for(var c,d,e=$G(a).children,f=0;d=e[f++];)if("focus"==d.className){c=d.getAttribute(b);break}return c}function g(a){for(var b,c=0;b=a[c++];){var d=$G(b),e={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var f in e){var g=document.createElement("div");g.setAttribute("name",f),"none"==f?(g.className="focus",g.style.cssText="background-image:url(icon/"+f+"-active.png);"):g.style.cssText="background-image:url(icon/"+f+".png);",g.setAttribute("title",e[f]),d.appendChild(g)}h(b)}}function h(a){for(var b,c=$G(a).children,d=0;b=c[d++];)domUtils.on(b,"click",function(){for(var a,b=0;a=c[b++];)a.className="",a.style.cssText="background-image:url(icon/"+a.getAttribute("name")+".png);",a.removeAttribute&&a.removeAttribute("class");this.className="focus",this.style.cssText="background-image:url(icon/"+this.getAttribute("name")+"-active.png);"})}function i(a){browser.ie?a.onpropertychange=function(){k(this.value)}:a.addEventListener("input",function(){k(this.value)},!1)}function j(a,b){b=b||{};var c=["<audio",b.id?' id="'+b.id+'"':"",b.cls?' class="'+b.cls+'"':""," controls >",'<source src="'+a+'" type="audio/mpeg" />',"</audio>"];return c.join("")}function k(a){a&&($G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;"><div style="text-align:center;flex-grow:1;">'+j(a)+"</div></div>")}function l(){var a=[],b=editor.getOpt("audioUrlPrefix"),c=f("upload_alignment","name")||"none";for(var d in p){var e=p[d];a.push({url:b+e.url,align:c})}var g=o.getQueueCount();return g?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,g)+"</span>"),!1):void editor.execCommand("insertaudio",a,"upload")}function m(){o=new n("queueList")}function n(a){this.$wrap=a.constructor==String?$("#"+a):$(a),this.init()}var o,p=[],q=!1,r={};window.onload=function(){r=editor.getOpt("audioConfig"),$focus($G("audioUrl")),a(),b(),m()},n.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function a(a){var b=h('<li id="'+a.id+'"><p class="title">'+a.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),c=h('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo(b),d=b.find("p.progress span"),e=b.find("p.imgWrap"),g=h('<p class="error"></p>').hide().appendTo(b),i=function(a){switch(a){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}g.text(text).show()};"invalid"===a.getStatus()?i(a.statusText):(e.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+a.ext.toLowerCase()+"|")==-1?e.empty().addClass("notimage").append('<i class="file-preview file-type-'+a.ext.toLowerCase()+'"></i><span class="file-title">'+a.name+"</span>"):browser.ie&&browser.version<=7?e.text(lang.uploadNoPreview):f.makeThumb(a,function(a,b){if(a||!b||/^data:/.test(b)&&browser.ie&&browser.version<=7)e.text(lang.uploadNoPreview);else{var c=h('<img src="'+b+'">');e.empty().append(c),c.on("error",function(){e.text(lang.uploadNoPreview)})}},u,v),x[a.id]=[a.size,0],a.rotation=0,a.ext&&B.indexOf(a.ext.toLowerCase())!=-1||(i("not_allow_type"),f.removeFile(a))),a.on("statuschange",function(e,f){"progress"===f?d.hide().width(0):"queued"===f&&(b.off("mouseenter mouseleave"),c.remove()),"error"===e||"invalid"===e?(i(a.statusText),x[a.id][1]=1):"interrupt"===e?i("interrupt"):"queued"===e?x[a.id][1]=0:"progress"===e&&(g.hide(),d.css("display","block")),b.removeClass("state-"+f).addClass("state-"+e)}),b.on("mouseenter",function(){c.stop().animate({height:30})}),b.on("mouseleave",function(){c.stop().animate({height:0})}),c.on("click","span",function(){var b,c=h(this).index();switch(c){case 0:return void f.removeFile(a);case 1:a.rotation+=90;break;case 2:a.rotation-=90}y?(b="rotate("+a.rotation+"deg)",e.css({"-webkit-transform":b,"-mos-transform":b,"-o-transform":b,transform:b})):e.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(a.rotation/90%4+4)%4+")")}),b.insertBefore(n)}function b(a){var b=h("#"+a.id);delete x[a.id],c(),b.off().find(".file-panel").off().end().remove()}function c(){var a,b=0,c=0,d=q.children();h.each(x,function(a,d){c+=d[0],b+=d[0]*d[1]}),a=c?b/c:0,d.eq(0).text(Math.round(100*a)+"%"),d.eq(1).css("width",Math.round(100*a)+"%"),e()}function d(a,b){if(a!=w){var c=f.getStats();switch(m.removeClass("state-"+w),m.addClass("state-"+a),a){case"pedding":j.addClass("element-invisible"),k.addClass("element-invisible"),o.removeClass("element-invisible"),q.hide(),l.hide(),f.refresh();break;case"ready":o.addClass("element-invisible"),j.removeClass("element-invisible"),k.removeClass("element-invisible"),q.hide(),l.show(),m.text(lang.uploadStart),f.refresh();break;case"uploading":q.show(),l.hide(),m.text(lang.uploadPause);break;case"paused":q.show(),l.hide(),m.text(lang.uploadContinue);break;case"confirm":if(q.show(),l.hide(),m.text(lang.uploadStart),c=f.getStats(),c.successNum&&!c.uploadFailNum)return void d("finish");break;case"finish":q.hide(),l.show(),c.uploadFailNum?m.text(lang.uploadRetry):m.text(lang.uploadStart)}w=a,e()}g.getQueueCount()?m.removeClass("disabled"):m.addClass("disabled")}function e(){var a,b="";"ready"===w?b=lang.updateStatusReady.replace("_",r).replace("_KB",WebUploader.formatSize(s)):"confirm"===w?(a=f.getStats(),a.uploadFailNum&&(b=lang.updateStatusConfirm.replace("_",a.successNum).replace("_",a.successNum))):(a=f.getStats(),b=lang.updateStatusFinish.replace("_",r).replace("_KB",WebUploader.formatSize(s)).replace("_",a.successNum),a.uploadFailNum&&(b+=lang.updateStatusError.replace("_",a.uploadFailNum))),l.html(b)}var f,g=this,h=jQuery,i=g.$wrap,j=i.find(".filelist"),k=i.find(".statusBar"),l=k.find(".info"),m=i.find(".uploadBtn"),n=(i.find(".filePickerBtn"),i.find(".filePickerBlock")),o=i.find(".placeholder"),q=k.find(".progress").hide(),r=0,s=0,t=window.devicePixelRatio||1,u=113*t,v=113*t,w="",x={},y=function(){var a=document.createElement("p").style,b="transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"OTransition"in a;return a=null,b}(),z=editor.getActionUrl(editor.getOpt("audioActionName")),A=editor.getOpt("audioMaxSize"),B=(editor.getOpt("audioAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return m.hide(),WebUploader.Uploader.support()?editor.getOpt("audioActionName")?(f=g.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:z,fileVal:editor.getOpt("audioFieldName"),duplicate:!0,fileSingleSizeLimit:A,headers:editor.getOpt("serverHeaders")||{},compress:!1}),f.addButton({id:"#filePickerBlock"}),f.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),d("pedding"),f.on("beforeFileQueued",function(a){return!(!a.ext||B.indexOf(a.ext.toLowerCase())==-1)}),f.on("fileQueued",function(b){r++,s+=b.size,1===r&&(o.addClass("element-invisible"),k.show()),a(b);const c=editor.getOpt("uploadFunction");"function"==typeof c&&("ready"===w?d("uploading"):"pedding"===w&&(d("ready"),d("uploading")),b.setStatus("progress"),f.trigger("uploadProgress",b,0),c(b.source.source).then(function(a){f.trigger("uploadProgress",b,1),b.setStatus("complete"),d("finish"),f.trigger("uploadSuccess",b,a),f.trigger("uploadComplete",b)}))}),f.on("fileDequeued",function(a){r--,s-=a.size,b(a),c()}),f.on("filesQueued",function(a){f.isInProgress()||"pedding"!=w&&"finish"!=w&&"confirm"!=w&&"ready"!=w||d("ready"),c()}),f.on("all",function(a,b){switch(a){case"uploadFinished":d("confirm",b);break;case"startUpload":var c=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",e=utils.formatUrl(z+(z.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+c);f.option("server",e),d("uploading",b);break;case"stopUpload":d("paused",b)}}),f.on("uploadBeforeSend",function(a,b,c){z.toLowerCase().indexOf("jsp")!=-1&&(c.X_Requested_With="XMLHttpRequest")}),f.on("uploadProgress",function(a,b){var d=h("#"+a.id),e=d.find(".progress span");e.css("width",100*b+"%"),x[a.id][1]=b,c()}),f.on("uploadSuccess",function(a,b){var c=h("#"+a.id);try{"SUCCESS"==b.state?(p.push({url:b.url,type:b.type,original:b.original}),c.append('<span class="success"></span>')):c.find(".error").text(b.state).show()}catch(d){c.find(".error").text(lang.errorServerUpload).show()}}),f.on("uploadError",function(a,b){}),f.on("error",function(b,c){"Q_TYPE_DENIED"!=b&&"F_EXCEED_SIZE"!=b||a(c)}),f.on("uploadComplete",function(a,b){}),m.on("click",function(){return!h(this).hasClass("disabled")&&void("ready"===w?f.upload():"paused"===w?f.upload():"uploading"===w&&f.stop())}),m.addClass("state-"+w),void c()):void h("#filePickerReady").after(h("<div>").html(lang.errorLoadConfig)).hide():void h("#filePickerReady").after(h("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var a,b,c,d=0,e=this.uploader.getFiles();for(b=0;a=e[b++];)c=a.getStatus(),"queued"!=c&&"uploading"!=c&&"progress"!=c||d++;return d},refresh:function(){this.uploader.refresh()}}}();
|
|
2
|
+
!function(){function initTabs(){for(var tabs=$G("tabHeads").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){var j,bodyId,target=e.target||e.srcElement;for(j=0;j<tabs.length;j++)bodyId=tabs[j].getAttribute("data-content-id"),tabs[j]==target?(domUtils.addClass(tabs[j],"focus"),domUtils.addClass($G(bodyId),"focus")):(domUtils.removeClasses(tabs[j],"focus"),domUtils.removeClasses($G(bodyId),"focus"))});editorOpt.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),editorOpt.selectCallback&&($G("audioSelect").style.display="inline-block",domUtils.on($G("audioSelect"),"click",function(e){editorOpt.selectCallback(editor,function(info){info&&($G("audioUrl").value=info.path,createPreview(info.path))})}))}function initAudio(){createAlignButton(["audioFloat","upload_alignment"]),addUrlChangeListener($G("audioUrl")),addOkListener(),function(){var url,img=editor.selection.getRange().getClosedNode();if(img&&img.className){var hasFakedClass="edui-faked-audio"==img.className,hasUploadClass=img.className.indexOf("edui-upload-audio")!=-1;if(hasFakedClass||hasUploadClass){$G("audioUrl").value=url=img.getAttribute("_url");var align=domUtils.getComputedStyle(img,"float"),parentAlign=domUtils.getComputedStyle(img.parentNode,"text-align");updateAlignButton("center"===parentAlign?"center":align)}hasUploadClass&&(isModifyUploadaudio=!0)}createPreview(url)}()}function addOkListener(){dialog.onok=function(){$G("preview").innerHTML="";var currentTab=findFocus("tabHeads","tabSrc");switch(currentTab){case"audio":return insertSingle();case"upload":return insertUpload()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function updateAlignButton(align){for(var ci,aligns=$G("audioFloat").children,i=0;ci=aligns[i++];)ci.getAttribute("name")==align?"focus"!=ci.className&&(ci.className="focus"):"focus"==ci.className&&(ci.className="")}function insertSingle(){var url=$G("audioUrl").value;findFocus("audioFloat","name");return!!url&&void editor.execCommand("insertaudio",{url:url},isModifyUploadaudio?"upload":null)}function findFocus(id,returnProperty){for(var property,ci,tabs=$G(id).children,i=0;ci=tabs[i++];)if("focus"==ci.className){property=ci.getAttribute(returnProperty);break}return property}function createAlignButton(ids){for(var ci,i=0;ci=ids[i++];){var floatContainer=$G(ci),nameMaps={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var j in nameMaps){var div=document.createElement("div");div.setAttribute("name",j),"none"==j?(div.className="focus",div.style.cssText="background-image:url(icon/"+j+"-active.png);"):div.style.cssText="background-image:url(icon/"+j+".png);",div.setAttribute("title",nameMaps[j]),floatContainer.appendChild(div)}switchSelect(ci)}}function switchSelect(selectParentId){for(var ci,selects=$G(selectParentId).children,i=0;ci=selects[i++];)domUtils.on(ci,"click",function(){for(var cj,j=0;cj=selects[j++];)cj.className="",cj.style.cssText="background-image:url(icon/"+cj.getAttribute("name")+".png);",cj.removeAttribute&&cj.removeAttribute("class");this.className="focus",this.style.cssText="background-image:url(icon/"+this.getAttribute("name")+"-active.png);"})}function addUrlChangeListener(url){browser.ie?url.onpropertychange=function(){createPreview(this.value)}:url.addEventListener("input",function(){createPreview(this.value)},!1)}function createAudioHtml(url,param){param=param||{};var str=["<audio",param.id?' id="'+param.id+'"':"",param.cls?' class="'+param.cls+'"':""," controls >",'<source src="'+url+'" type="audio/mpeg" />',"</audio>"];return str.join("")}function createPreview(url){url&&($G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;"><div style="text-align:center;flex-grow:1;">'+createAudioHtml(url)+"</div></div>")}function insertUpload(){var audioObjs=[],uploadDir=editor.getOpt("audioUrlPrefix"),align=findFocus("upload_alignment","name")||"none";for(var key in uploadaudioList){var file=uploadaudioList[key];audioObjs.push({url:uploadDir+file.url,align:align})}var count=uploadFile.getQueueCount();return count?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,count)+"</span>"),!1):void editor.execCommand("insertaudio",audioObjs,"upload")}function initUpload(){uploadFile=new UploadFile("queueList")}function UploadFile(target){this.$wrap=target.constructor==String?$("#"+target):$(target),this.init()}var uploadFile,uploadaudioList=[],isModifyUploadaudio=!1,editorOpt={};window.onload=function(){editorOpt=editor.getOpt("audioConfig"),$focus($G("audioUrl")),initTabs(),initAudio(),initUpload()},UploadFile.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function addFile(file){var $li=$('<li id="'+file.id+'"><p class="title">'+file.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),$btns=$('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo($li),$prgress=$li.find("p.progress span"),$wrap=$li.find("p.imgWrap"),$info=$('<p class="error"></p>').hide().appendTo($li),showError=function(code){switch(code){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}$info.text(text).show()};"invalid"===file.getStatus()?showError(file.statusText):($wrap.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+file.ext.toLowerCase()+"|")==-1?$wrap.empty().addClass("notimage").append('<i class="file-preview file-type-'+file.ext.toLowerCase()+'"></i><span class="file-title">'+file.name+"</span>"):browser.ie&&browser.version<=7?$wrap.text(lang.uploadNoPreview):uploader.makeThumb(file,function(error,src){if(error||!src||/^data:/.test(src)&&browser.ie&&browser.version<=7)$wrap.text(lang.uploadNoPreview);else{var $img=$('<img src="'+src+'">');$wrap.empty().append($img),$img.on("error",function(){$wrap.text(lang.uploadNoPreview)})}},thumbnailWidth,thumbnailHeight),percentages[file.id]=[file.size,0],file.rotation=0,file.ext&&acceptExtensions.indexOf(file.ext.toLowerCase())!=-1||(showError("not_allow_type"),uploader.removeFile(file))),file.on("statuschange",function(cur,prev){"progress"===prev?$prgress.hide().width(0):"queued"===prev&&($li.off("mouseenter mouseleave"),$btns.remove()),"error"===cur||"invalid"===cur?(showError(file.statusText),percentages[file.id][1]=1):"interrupt"===cur?showError("interrupt"):"queued"===cur?percentages[file.id][1]=0:"progress"===cur&&($info.hide(),$prgress.css("display","block")),$li.removeClass("state-"+prev).addClass("state-"+cur)}),$li.on("mouseenter",function(){$btns.stop().animate({height:30})}),$li.on("mouseleave",function(){$btns.stop().animate({height:0})}),$btns.on("click","span",function(){var deg,index=$(this).index();switch(index){case 0:return void uploader.removeFile(file);case 1:file.rotation+=90;break;case 2:file.rotation-=90}supportTransition?(deg="rotate("+file.rotation+"deg)",$wrap.css({"-webkit-transform":deg,"-mos-transform":deg,"-o-transform":deg,transform:deg})):$wrap.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(file.rotation/90%4+4)%4+")")}),$li.insertBefore($filePickerBlock)}function removeFile(file){var $li=$("#"+file.id);delete percentages[file.id],updateTotalProgress(),$li.off().find(".file-panel").off().end().remove()}function updateTotalProgress(){var percent,loaded=0,total=0,spans=$progress.children();$.each(percentages,function(k,v){total+=v[0],loaded+=v[0]*v[1]}),percent=total?loaded/total:0,spans.eq(0).text(Math.round(100*percent)+"%"),spans.eq(1).css("width",Math.round(100*percent)+"%"),updateStatus()}function setState(val,files){if(val!=state){var stats=uploader.getStats();switch($upload.removeClass("state-"+state),$upload.addClass("state-"+val),val){case"pedding":$queue.addClass("element-invisible"),$statusBar.addClass("element-invisible"),$placeHolder.removeClass("element-invisible"),$progress.hide(),$info.hide(),uploader.refresh();break;case"ready":$placeHolder.addClass("element-invisible"),$queue.removeClass("element-invisible"),$statusBar.removeClass("element-invisible"),$progress.hide(),$info.show(),$upload.text(lang.uploadStart),uploader.refresh();break;case"uploading":$progress.show(),$info.hide(),$upload.text(lang.uploadPause);break;case"paused":$progress.show(),$info.hide(),$upload.text(lang.uploadContinue);break;case"confirm":if($progress.show(),$info.hide(),$upload.text(lang.uploadStart),stats=uploader.getStats(),stats.successNum&&!stats.uploadFailNum)return void setState("finish");break;case"finish":$progress.hide(),$info.show(),stats.uploadFailNum?$upload.text(lang.uploadRetry):$upload.text(lang.uploadStart)}state=val,updateStatus()}_this.getQueueCount()?$upload.removeClass("disabled"):$upload.addClass("disabled")}function updateStatus(){var stats,text="";"ready"===state?text=lang.updateStatusReady.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)):"confirm"===state?(stats=uploader.getStats(),stats.uploadFailNum&&(text=lang.updateStatusConfirm.replace("_",stats.successNum).replace("_",stats.successNum))):(stats=uploader.getStats(),text=lang.updateStatusFinish.replace("_",fileCount).replace("_KB",WebUploader.formatSize(fileSize)).replace("_",stats.successNum),stats.uploadFailNum&&(text+=lang.updateStatusError.replace("_",stats.uploadFailNum))),$info.html(text)}var uploader,_this=this,$=jQuery,$wrap=_this.$wrap,$queue=$wrap.find(".filelist"),$statusBar=$wrap.find(".statusBar"),$info=$statusBar.find(".info"),$upload=$wrap.find(".uploadBtn"),$filePickerBlock=($wrap.find(".filePickerBtn"),$wrap.find(".filePickerBlock")),$placeHolder=$wrap.find(".placeholder"),$progress=$statusBar.find(".progress").hide(),fileCount=0,fileSize=0,ratio=window.devicePixelRatio||1,thumbnailWidth=113*ratio,thumbnailHeight=113*ratio,state="",percentages={},supportTransition=function(){var s=document.createElement("p").style,r="transition"in s||"WebkitTransition"in s||"MozTransition"in s||"msTransition"in s||"OTransition"in s;return s=null,r}(),actionUrl=editor.getActionUrl(editor.getOpt("audioActionName")),fileMaxSize=editor.getOpt("audioMaxSize"),acceptExtensions=(editor.getOpt("audioAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return $upload.hide(),WebUploader.Uploader.support()?editor.getOpt("audioActionName")?(uploader=_this.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:actionUrl,fileVal:editor.getOpt("audioFieldName"),duplicate:!0,fileSingleSizeLimit:fileMaxSize,headers:editor.getOpt("serverHeaders")||{},compress:!1}),uploader.addButton({id:"#filePickerBlock"}),uploader.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),setState("pedding"),uploader.on("beforeFileQueued",function(file){return!(!file.ext||acceptExtensions.indexOf(file.ext.toLowerCase())==-1)}),uploader.on("fileQueued",function(file){fileCount++,fileSize+=file.size,1===fileCount&&($placeHolder.addClass("element-invisible"),$statusBar.show()),addFile(file);const uploadFunc=editor.getOpt("uploadFunction");"function"==typeof uploadFunc&&("ready"===state?setState("uploading"):"pedding"===state&&(setState("ready"),setState("uploading")),file.setStatus("progress"),uploader.trigger("uploadProgress",file,0),uploadFunc(file.source.source).then(function(response){uploader.trigger("uploadProgress",file,1),file.setStatus("complete"),setState("finish"),uploader.trigger("uploadSuccess",file,response),uploader.trigger("uploadComplete",file)}))}),uploader.on("fileDequeued",function(file){fileCount--,fileSize-=file.size,removeFile(file),updateTotalProgress()}),uploader.on("filesQueued",function(file){uploader.isInProgress()||"pedding"!=state&&"finish"!=state&&"confirm"!=state&&"ready"!=state||setState("ready"),updateTotalProgress()}),uploader.on("all",function(type,files){switch(type){case"uploadFinished":setState("confirm",files);break;case"startUpload":var params=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",url=utils.formatUrl(actionUrl+(actionUrl.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+params);uploader.option("server",url),setState("uploading",files);break;case"stopUpload":setState("paused",files)}}),uploader.on("uploadBeforeSend",function(file,data,header){actionUrl.toLowerCase().indexOf("jsp")!=-1&&(header.X_Requested_With="XMLHttpRequest")}),uploader.on("uploadProgress",function(file,percentage){var $li=$("#"+file.id),$percent=$li.find(".progress span");$percent.css("width",100*percentage+"%"),percentages[file.id][1]=percentage,updateTotalProgress()}),uploader.on("uploadSuccess",function(file,json){var $file=$("#"+file.id);try{"SUCCESS"==json.state?(uploadaudioList.push({url:json.url,type:json.type,original:json.original}),$file.append('<span class="success"></span>')):$file.find(".error").text(json.state).show()}catch(e){$file.find(".error").text(lang.errorServerUpload).show()}}),uploader.on("uploadError",function(file,code){}),uploader.on("error",function(code,file){"Q_TYPE_DENIED"!=code&&"F_EXCEED_SIZE"!=code||addFile(file)}),uploader.on("uploadComplete",function(file,ret){}),$upload.on("click",function(){return!$(this).hasClass("disabled")&&void("ready"===state?uploader.upload():"paused"===state?uploader.upload():"uploading"===state&&uploader.stop())}),$upload.addClass("state-"+state),void updateTotalProgress()):void $("#filePickerReady").after($("<div>").html(lang.errorLoadConfig)).hide():void $("#filePickerReady").after($("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var file,i,status,readyFile=0,files=this.uploader.getFiles();for(i=0;file=files[i++];)status=file.getStatus(),"queued"!=status&&"uploading"!=status&&"progress"!=status||readyFile++;return readyFile},refresh:function(){this.uploader.refresh()}}}();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
5
|
-
<script type="text/javascript" src="../internal.js?
|
|
5
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
6
6
|
<link rel="stylesheet" type="text/css" href="background.css?982ee6c2">
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
56
56
|
</div>
|
|
57
|
-
<script type="text/javascript" src="background.js?
|
|
57
|
+
<script type="text/javascript" src="background.js?8ab58061"></script>
|
|
58
58
|
</body>
|
|
59
59
|
</html>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
!function(){function initTabs(){for(var
|
|
2
|
+
!function(){function initTabs(){for(var tabs=$G("tabHeads").children,i=0;i<tabs.length;i++)domUtils.on(tabs[i],"click",function(e){for(var target=e.target||e.srcElement,j=0;j<tabs.length;j++)if(tabs[j]==target){tabs[j].className="focus";var contentId=tabs[j].getAttribute("data-content-id");$G(contentId).style.display="block"}else tabs[j].className="",$G(tabs[j].getAttribute("data-content-id")).style.display="none"})}function initColorSelector(){var obj=editor.queryCommandValue("background");if(obj){var color=obj["background-color"],repeat=obj["background-repeat"]||"repeat",image=obj["background-image"]||"",position=obj["background-position"]||"center center",pos=position.split(" "),x=parseInt(pos[0])||0,y=parseInt(pos[1])||0;"no-repeat"==repeat&&(x||y)&&(repeat="self"),image=image.match(/url[\s]*\(([^\)]*)\)/),image=image?image[1]:"",updateFormState("colored",color,image,repeat,x,y)}else updateFormState();var updateHandler=function(){updateFormState(),updateBackground()};domUtils.on($G("nocolorRadio"),"click",updateBackground),domUtils.on($G("coloredRadio"),"click",updateHandler),domUtils.on($G("url"),"keyup",function(){$G("url").value&&"none"==$G("alignment").style.display&&utils.each($G("repeatType").children,function(item){item.selected="repeat"==item.getAttribute("value")&&"selected"}),updateHandler()}),domUtils.on($G("repeatType"),"change",updateHandler),domUtils.on($G("x"),"keyup",updateBackground),domUtils.on($G("y"),"keyup",updateBackground),initColorPicker()}function initColorPicker(){var me=editor,cp=$G("colorPicker"),popup=new UE.ui.Popup({content:new UE.ui.ColorPicker({noColorText:me.getLang("clearColor"),editor:me,onpickcolor:function(t,color){updateFormState("colored",color),updateBackground(),UE.ui.Popup.postHide()},onpicknocolor:function(t,color){updateFormState("colored","transparent"),updateBackground(),UE.ui.Popup.postHide()}}),editor:me,onhide:function(){}});domUtils.on(cp,"click",function(){popup.showAnchor(this)}),domUtils.on(document,"mousedown",function(evt){var el=evt.target||evt.srcElement;UE.ui.Popup.postHide(el)}),domUtils.on(window,"scroll",function(){UE.ui.Popup.postHide()})}function updateFormState(radio,color,url,align,x,y){var nocolorRadio=$G("nocolorRadio"),coloredRadio=$G("coloredRadio");if(radio&&(nocolorRadio.checked="colored"!=radio&&"checked",coloredRadio.checked="colored"==radio&&"checked"),color&&domUtils.setStyle($G("colorPicker"),"background-color",color),url&&/^\//.test(url)){var a=document.createElement("a");a.href=url,browser.ie&&(a.href=a.href),url=browser.ie?a.href:a.protocol+"//"+a.host+a.pathname+a.search+a.hash}(url||""===url)&&($G("url").value=url),align&&utils.each($G("repeatType").children,function(item){item.selected=align==item.getAttribute("value")&&"selected"}),(x||y)&&($G("x").value=parseInt(x)||0,$G("y").value=parseInt(y)||0),$G("alignment").style.display=coloredRadio.checked&&$G("url").value?"":"none",$G("custom").style.display=coloredRadio.checked&&$G("url").value&&"self"==$G("repeatType").value?"":"none"}function updateBackground(){if($G("coloredRadio").checked){var color=domUtils.getStyle($G("colorPicker"),"background-color"),bgimg=$G("url").value,align=$G("repeatType").value,backgroundObj={"background-repeat":"no-repeat","background-position":"center center"};color&&(backgroundObj["background-color"]=color),bgimg&&(backgroundObj["background-image"]="url("+bgimg+")"),"self"==align?backgroundObj["background-position"]=$G("x").value+"px "+$G("y").value+"px":"repeat-x"!=align&&"repeat-y"!=align&&"repeat"!=align||(backgroundObj["background-repeat"]=align),editor.execCommand("background",backgroundObj)}else editor.execCommand("background",null)}function OnlineImage(target){this.container=utils.isString(target)?document.getElementById(target):target,this.init()}var onlineImage,backupStyle=editor.queryCommandValue("background");window.onload=function(){initTabs(),initColorSelector()},OnlineImage.prototype={init:function(){this.reset(),this.initEvents()},initContainer:function(){this.container.innerHTML="",this.list=document.createElement("ul"),this.clearFloat=document.createElement("li"),domUtils.addClass(this.list,"list"),domUtils.addClass(this.clearFloat,"clearFloat"),this.list.id="imageListUl",this.list.appendChild(this.clearFloat),this.container.appendChild(this.list)},initEvents:function(){var _this=this;domUtils.on($G("imageList"),"scroll",function(e){var panel=this;panel.scrollHeight-(panel.offsetHeight+panel.scrollTop)<10&&_this.getImageData()}),domUtils.on(this.container,"click",function(e){var target=e.target||e.srcElement,li=target.parentNode,nodes=$G("imageListUl").childNodes;if("li"==li.tagName.toLowerCase()){updateFormState("nocolor",null,"");for(var node,i=0;node=nodes[i++];)node!=li||domUtils.hasClass(node,"selected")?domUtils.removeClasses(node,"selected"):(domUtils.addClass(node,"selected"),updateFormState("colored",null,li.firstChild.getAttribute("_src"),"repeat"));updateBackground()}})},initData:function(){this.state=0,this.listSize=editor.getOpt("imageManagerListSize"),this.listIndex=0,this.listEnd=!1,this.getImageData()},reset:function(){this.initContainer(),this.initData()},getImageData:function(){var _this=this;if(!_this.listEnd&&!this.isLoadingData){this.isLoadingData=!0;var url=editor.getActionUrl(editor.getOpt("imageManagerActionName")),isJsonp=utils.isCrossDomainUrl(url);ajax.request(url,{timeout:1e5,dataType:isJsonp?"jsonp":"",data:utils.extend({start:this.listIndex,size:this.listSize},editor.queryCommandValue("serverparam")),headers:editor.options.serverHeaders||{},method:"get",onsuccess:function(r){try{var json=isJsonp?r:eval("("+r.responseText+")");"SUCCESS"==json.state&&(_this.pushData(json.list),_this.listIndex=parseInt(json.start)+parseInt(json.list.length),_this.listIndex>=json.total&&(_this.listEnd=!0),_this.isLoadingData=!1)}catch(e){if(r.responseText.indexOf("ue_separate_ue")!=-1){var list=r.responseText.split(r.responseText);_this.pushData(list),_this.listIndex=parseInt(list.length),_this.listEnd=!0,_this.isLoadingData=!1}}},onerror:function(){_this.isLoadingData=!1}})}},pushData:function(list){var i,item,img,icon,_this=this,urlPrefix=editor.getOpt("imageManagerUrlPrefix");for(i=0;i<list.length;i++)list[i]&&list[i].url&&(item=document.createElement("li"),img=document.createElement("img"),icon=document.createElement("span"),domUtils.on(img,"load",function(image){return function(){_this.scale(image,image.parentNode.offsetWidth,image.parentNode.offsetHeight)}}(img)),img.width=113,img.setAttribute("src",urlPrefix+list[i].url+(list[i].url.indexOf("?")==-1?"?noCache=":"&noCache=")+(+new Date).toString(36)),img.setAttribute("_src",urlPrefix+list[i].url),domUtils.addClass(icon,"icon"),item.appendChild(img),item.appendChild(icon),this.list.insertBefore(item,this.clearFloat))},scale:function(img,w,h,type){var ow=img.width,oh=img.height;"justify"==type?ow>=oh?(img.width=w,img.height=h*oh/ow,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w*ow/oh,img.height=h,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px"):ow>=oh?(img.width=w*ow/oh,img.height=h,img.style.marginLeft="-"+parseInt((img.width-w)/2)+"px"):(img.width=w,img.height=h*oh/ow,img.style.marginTop="-"+parseInt((img.height-h)/2)+"px")},getInsertList:function(){var i,lis=this.list.children,list=[],align=getAlign();for(i=0;i<lis.length;i++)if(domUtils.hasClass(lis[i],"selected")){var img=lis[i].firstChild,src=img.getAttribute("_src");list.push({src:src,_src:src,floatStyle:align})}return list}},dialog.onok=function(){updateBackground(),editor.fireEvent("saveScene")},dialog.oncancel=function(){editor.execCommand("background",backupStyle)}}();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<head>
|
|
3
3
|
<title></title>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
5
|
-
<script type="text/javascript" src="../internal.js?
|
|
5
|
+
<script type="text/javascript" src="../internal.js?b983a808"></script>
|
|
6
6
|
<style type="text/css">
|
|
7
7
|
.wrapper {
|
|
8
8
|
width: 600px;
|
|
@@ -161,10 +161,10 @@
|
|
|
161
161
|
</div>
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
|
-
<script src="../../third-party/jquery-3.5.1.js?
|
|
164
|
+
<script src="../../third-party/jquery-3.5.1.js?cdb3992e"></script>
|
|
165
165
|
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
|
|
166
166
|
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
|
|
167
|
-
<script type="text/javascript" src="contentimport.js?
|
|
167
|
+
<script type="text/javascript" src="contentimport.js?e0504ca5"></script>
|
|
168
168
|
<script type="text/javascript">
|
|
169
169
|
utils.domReady(function () {
|
|
170
170
|
var options = {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! UEditorPlus v2.0.0*/
|
|
2
|
-
function processWord(
|
|
2
|
+
function processWord(file){$(".file-tip").html("正在转换Word文件,请稍后..."),$(".file-result").html("").hide();var reader=new FileReader;reader.onload=function(loadEvent){mammoth.convertToHtml({arrayBuffer:loadEvent.target.result}).then(function(result){$(".file-tip").html("转换成功"),contentImport.data.result=result.value,$(".file-result").html(result.value).show()},function(error){$(".file-tip").html("Word文件转换失败:"+error)})},reader.onerror=function(loadEvent){$(".file-tip").html("Word文件转换失败:"+loadEvent)},reader.readAsArrayBuffer(file)}function processMarkdown(markdown){var converter=new showdown.Converter,html=converter.makeHtml(markdown);$(".file-tip").html("转换成功"),contentImport.data.result=html,$(".file-result").html(html).show()}function processMarkdownFile(file){$(".file-tip").html("正在转换Markdown文件,请稍后..."),$(".file-result").html("").hide();var reader=new FileReader;reader.onload=function(loadEvent){processMarkdown(loadEvent.target.result)},reader.onerror=function(loadEvent){$(".file-tip").html("Markdown文件转换失败:"+loadEvent)},reader.readAsText(file,"UTF-8")}function addUploadButtonListener(){g("contentImport").addEventListener("change",function(){const file=this.files[0],fileName=file.name,fileExt=fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();switch(fileExt){case"docx":case"doc":processWord(file);break;case"md":processMarkdownFile(file);break;default:$(".file-tip").html("不支持的文件格式:"+fileExt)}}),g("fileInputConfirm").addEventListener("click",function(){processMarkdown(g("fileInputContent").value),$(".file-input").hide()})}function addOkListener(){dialog.onok=function(){return contentImport.data.result?(editor.fireEvent("saveScene"),editor.execCommand("inserthtml",contentImport.data.result),void editor.fireEvent("saveScene")):(alert("请先上传文件识别内容"),!1)},dialog.oncancel=function(){}}var contentImport={},g=$G;contentImport.data={result:null},contentImport.init=function(opt,callbacks){addUploadButtonListener(),addOkListener()};
|