From 9ff340e303f2459452120c5db015a375048d1c62 Mon Sep 17 00:00:00 2001
From: xiao-fajia <1665375861@qq.com>
Date: Tue, 30 Jul 2024 19:42:09 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=AF=E8=87=AA=E5=AE=9A?=
=?UTF-8?q?=E4=B9=89=E8=A1=A8=E6=A0=BC=E5=AE=BD=E5=BA=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../UEditorPlus/dialogs/table/edittable.html | 11 ++-
.../UEditorPlus/dialogs/table/edittable.js | 22 +++++-
.../public/static/UEditorPlus/ueditor.all.js | 74 ++++++++++++++-----
3 files changed, 86 insertions(+), 21 deletions(-)
diff --git a/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.html b/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.html
index dbc6a4f..9218793 100644
--- a/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.html
+++ b/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.html
@@ -39,9 +39,16 @@
-
+
+
+
+
+
+
+
+
+
diff --git a/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.js b/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.js
index bb20953..fc5ad11 100644
--- a/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.js
+++ b/ruoyi-ui/public/static/UEditorPlus/dialogs/table/edittable.js
@@ -12,6 +12,8 @@
sorttable = $G("J_sorttable"),
autoSizeContent = $G("J_autoSizeContent"),
autoSizePage = $G("J_autoSizePage"),
+ setSizePage = $G("J_setSizePage"),//设置自定义宽度
+ setSizeText = $G("J_setText"),//设置自定义宽度
tone = $G("J_tone"),
me,
preview = $G("J_preview");
@@ -52,6 +54,7 @@
domUtils.on(sorttable, "click", me.sorttableHanler);
domUtils.on(autoSizeContent, "click", me.autoSizeContentHanler);
domUtils.on(autoSizePage, "click", me.autoSizePageHanler);
+ domUtils.on(setSizePage, "click", me.setSizePageHanler);//设置自定义宽度
domUtils.on(tone, "click", function () {
colorPop.showAnchor(tone);
@@ -157,6 +160,8 @@
autoSizeContentHanler: function () {
var example = $G("J_example");
example.removeAttribute("width");
+ var txtSize = $G("J_setText");
+ txtSize.style.display = "none";
},
autoSizePageHanler: function () {
var example = $G("J_example");
@@ -165,6 +170,18 @@
td.removeAttribute("width");
});
example.setAttribute('width', '100%');
+ var txtSize = $G("J_setText");
+ txtSize.style.display = "none";
+ },
+ setSizePageHanler: function () { //设置自定义宽度
+ var example = $G("J_example");
+ var txtSize = $G("J_setText");
+ txtSize.style.display = "block";
+ var tds = example.getElementsByTagName(example, "td");
+ utils.each(tds, function (td) {
+ td.removeAttribute("width");
+ });
+ example.setAttribute('width', txtSize.value);
},
updateSortSpan: function () {
var example = $G("J_example"),
@@ -230,7 +247,10 @@
editor.queryCommandState(cmds[1]) != -1 && editor.execCommand(cmds[1]);
}
}
-
+ //设置自定义宽度
+ if (setSizePage.checked) {
+ editor.execCommand("settablesize", setSizeText.value);
+ }
editor.execCommand("edittable", tone.value);
autoSizeContent.checked ? editor.execCommand('adaptbytext') : "";
autoSizePage.checked ? editor.execCommand("adaptbywindow") : "";
diff --git a/ruoyi-ui/public/static/UEditorPlus/ueditor.all.js b/ruoyi-ui/public/static/UEditorPlus/ueditor.all.js
index 96578c0..90cbf86 100644
--- a/ruoyi-ui/public/static/UEditorPlus/ueditor.all.js
+++ b/ruoyi-ui/public/static/UEditorPlus/ueditor.all.js
@@ -25528,25 +25528,50 @@ UE.plugins["audio"] = function () {
}
};
- UE.commands["adaptbytext"] = UE.commands["adaptbywindow"] = {
- queryCommandState: function () {
- return getTableItemsByRange(this).table ? 0 : -1;
- },
- execCommand: function (cmd) {
- var tableItems = getTableItemsByRange(this),
- table = tableItems.table;
- if (table) {
- if (cmd == "adaptbywindow") {
- resetTdWidth(table, this);
- } else {
- var cells = domUtils.getElementsByTagName(table, "td th");
- utils.each(cells, function (cell) {
- cell.removeAttribute("width");
- });
- table.removeAttribute("width");
- }
- }
+ // UE.commands["adaptbytext"] = UE.commands["adaptbywindow"] = {
+ // queryCommandState: function () {
+ // return getTableItemsByRange(this).table ? 0 : -1;
+ // },
+ // execCommand: function (cmd) {
+ // var tableItems = getTableItemsByRange(this),
+ // table = tableItems.table;
+ // if (table) {
+ // if (cmd == "adaptbywindow") {
+ // resetTdWidth(table, this);
+ // } else {
+ // var cells = domUtils.getElementsByTagName(table, "td th");
+ // utils.each(cells, function (cell) {
+ // cell.removeAttribute("width");
+ // });
+ // table.removeAttribute("width");
+ // }
+ // }
+ // }
+ // };
+
+ //修改表格属性 宽度设置
+ UE.commands["adaptbytext"] =
+ UE.commands["adaptbywindow"] = {
+ queryCommandState: function () {
+ return getTableItemsByRange(this).table ? 0 : -1
+ },
+ execCommand: function (cmd) {
+ var tableItems = getTableItemsByRange(this),
+ table = tableItems.table;
+ if (table) {
+ if (cmd == 'adaptbywindow') {
+ table.removeAttribute("width");
+ resetTdWidth(table, this);
+ } else {
+ var cells = domUtils.getElementsByTagName(table, "td th");
+ utils.each(cells, function (cell) {
+ cell.removeAttribute("width");
+ });
+ table.removeAttribute("width");
+ table.width = "100%";
+ }
}
+ }
};
//平均分配各列
@@ -25778,6 +25803,19 @@ UE.plugins["audio"] = function () {
}
}
};
+ //表格属性 宽度设置
+ UE.commands['settablesize'] = {
+ queryCommandState: function () {
+ return getTableItemsByRange(this).table ? 0 : -1
+ },
+ execCommand: function (cmd, width) {
+ var rng = this.selection.getRange(),
+ table = domUtils.findParentByTagName(rng.startContainer, 'table');
+ if (table) {
+ table.width = width;
+ }
+ }
+ };
//单元格属性
UE.commands["edittd"] = {
queryCommandState: function () {