Jelajahi Sumber

修正一键排版段落缩进

一键排版保留段落的 text-indent: 2em 和两端对齐,但不再向正文文本前插入两个全角空格。

再次排版时会清理段首已有空白,避免前台文章正文在模板缩进基础上看起来变成 4 字距离。

Validation:

- node --check WebRoot/apps/space/js/space.vue.subassembly.js
非繁 5 bulan lalu
induk
melakukan
395173416f
1 mengubah file dengan 3 tambahan dan 5 penghapusan
  1. 3 5
      WebRoot/apps/space/js/space.vue.subassembly.js

+ 3 - 5
WebRoot/apps/space/js/space.vue.subassembly.js

@@ -777,12 +777,10 @@ Vue.component('spaceEditor', {
 				return null;
 			};
 
-			var addFirstLineIndent = function (node) {
+			var trimFirstTextIndent = function (node) {
 				var textNode = findFirstTextNode(node);
 				if (textNode) {
-					textNode.nodeValue = "\u3000\u3000" + textNode.nodeValue.replace(/^[\s\u00a0\u3000]+/, "");
-				} else {
-					node.insertBefore(document.createTextNode("\u3000\u3000"), node.firstChild);
+					textNode.nodeValue = textNode.nodeValue.replace(/^[\s\u00a0\u3000]+/, "");
 				}
 			};
 
@@ -798,7 +796,7 @@ Vue.component('spaceEditor', {
 					textBlock.style.textAlign = "justify";
 					textBlock.style.textIndent = "2em";
 					textBlock.style.lineHeight = "1.8";
-					addFirstLineIndent(textBlock);
+					trimFirstTextIndent(textBlock);
 				}
 			}