@pixui-dev/pixui-richtext-helper 0.1.1-beta.3 → 0.1.1-beta.4
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.
|
@@ -212,7 +212,7 @@ var RichText_Refactor = /** @class */ (function () {
|
|
|
212
212
|
// 按旧实现顺序进行处理,但重构为独立函数划分
|
|
213
213
|
this.handleIndentClass($);
|
|
214
214
|
this.fixImgSizeUnit($);
|
|
215
|
-
this.handleLists(
|
|
215
|
+
this.handleLists($, (config === null || config === void 0 ? void 0 : config.lineHeightScale) || 1);
|
|
216
216
|
this.replaceBrWithPlaceholder($);
|
|
217
217
|
this.handleAnchorTag($);
|
|
218
218
|
this.wrapTextNodes($);
|
|
@@ -262,7 +262,8 @@ var RichText_Refactor = /** @class */ (function () {
|
|
|
262
262
|
});
|
|
263
263
|
};
|
|
264
264
|
/** 列表处理(将 ol/ul/li 替换为 div 结构) */
|
|
265
|
-
RichText_Refactor.handleLists = function (
|
|
265
|
+
RichText_Refactor.handleLists = function ($, lineHeightScale) {
|
|
266
|
+
if (lineHeightScale === void 0) { lineHeightScale = 1; }
|
|
266
267
|
var topLevelLists = [];
|
|
267
268
|
var collectListItems = function ($container, currentLevel) {
|
|
268
269
|
if (currentLevel === void 0) { currentLevel = 0; }
|
|
@@ -322,8 +323,15 @@ var RichText_Refactor = /** @class */ (function () {
|
|
|
322
323
|
topLevelLists.forEach(function (listInfo) {
|
|
323
324
|
var placeholder = listInfo.placeholder, items = listInfo.items;
|
|
324
325
|
var html = items
|
|
325
|
-
.map(function (it) {
|
|
326
|
-
|
|
326
|
+
.map(function (it, idx) {
|
|
327
|
+
// 所有列表项默认上下 0.5 * lineHeightScale rem
|
|
328
|
+
var marginTopVal = idx === 0 ? 1 * lineHeightScale : 0.5 * lineHeightScale;
|
|
329
|
+
var marginBottomVal = idx === items.length - 1 ? 1 * lineHeightScale : 0.5 * lineHeightScale;
|
|
330
|
+
var marginAdjust = ["margin-top: ".concat(marginTopVal, "rem"), "margin-bottom: ".concat(marginBottomVal, "rem")];
|
|
331
|
+
return ("<div style=\"".concat(mergeStyles.apply(void 0, __spreadArray(__spreadArray([it.style], marginAdjust, false), ["padding-left: ".concat(it.paddingLeft, "rem"), "flex-shrink: 0",
|
|
332
|
+
"width: 100%",
|
|
333
|
+
"flex-direction: row",
|
|
334
|
+
"display: flex"], false)), "\" data-list-item=\"true\">") +
|
|
327
335
|
"<text style=\"".concat(mergeStyles("flex-shrink: 0", "width: 100%", "line-height: 1", "display: flex", "flex-direction: row"), "\">") +
|
|
328
336
|
"<div style=\"".concat(mergeStyles("word-break: break-word", "flex-shrink: 0", "margin-right: 0.5rem"), "\">").concat(it.marker, "</div>") +
|
|
329
337
|
"<div style=\"".concat(mergeStyles("word-break: break-word", "flex-shrink: 0", "flex: 1"), "\">").concat(it.textContent, "</div>") +
|