@mirrormedia/lilith-draft-editor 1.1.0-alpha.33 → 1.1.0-alpha.34
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.
|
@@ -7,14 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
10
|
var _apiDataInstance = _interopRequireDefault(require("./api-data-instance"));
|
|
13
11
|
|
|
14
12
|
var _entities = _interopRequireDefault(require("./entities"));
|
|
15
13
|
|
|
16
|
-
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
17
|
-
|
|
18
14
|
var _draftJs = require("draft-js");
|
|
19
15
|
|
|
20
16
|
var _draftConvert = require("draft-convert");
|
|
@@ -80,44 +76,25 @@ const processor = {
|
|
|
80
76
|
|
|
81
77
|
case _entities.default.TABLE.type:
|
|
82
78
|
{
|
|
83
|
-
var _content
|
|
79
|
+
var _content;
|
|
84
80
|
|
|
85
81
|
// About TABLE atomic block entity data structure,
|
|
86
82
|
// see `../views/editor/table.tsx` for more information.
|
|
87
83
|
content = entity === null || entity === void 0 ? void 0 : entity.data;
|
|
88
|
-
/** @type DraftEditor.TableEntity.TableStyles */
|
|
89
|
-
|
|
90
|
-
const tableStyles = (_content = content) === null || _content === void 0 ? void 0 : _content.tableStyles;
|
|
91
84
|
/** @type DraftEditor.TableEntity.TableData */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const cellStyle = tableStyles === null || tableStyles === void 0 ? void 0 : (_tableStyles$cells = tableStyles.cells) === null || _tableStyles$cells === void 0 ? void 0 : (_tableStyles$cells$rI = _tableStyles$cells[rIndex]) === null || _tableStyles$cells$rI === void 0 ? void 0 : _tableStyles$cells$rI[cIndex];
|
|
102
|
-
return /*#__PURE__*/_react.default.createElement("td", {
|
|
103
|
-
key: `col_${cIndex}`,
|
|
104
|
-
style: Object.assign({}, colStyle, cellStyle),
|
|
105
|
-
dangerouslySetInnerHTML: {
|
|
106
|
-
__html: (0, _draftConvert.convertToHTML)((0, _draftJs.convertFromRaw)(col))
|
|
107
|
-
}
|
|
108
|
-
});
|
|
85
|
+
// since apiData is now only for app,
|
|
86
|
+
// keep the rows data structure for app to style the table
|
|
87
|
+
|
|
88
|
+
const tableData = (_content = content) === null || _content === void 0 ? void 0 : _content.tableData;
|
|
89
|
+
const rows = tableData === null || tableData === void 0 ? void 0 : tableData.map(row => {
|
|
90
|
+
const cols = row === null || row === void 0 ? void 0 : row.map(col => {
|
|
91
|
+
return {
|
|
92
|
+
html: (0, _draftConvert.convertToHTML)((0, _draftJs.convertFromRaw)(col))
|
|
93
|
+
};
|
|
109
94
|
});
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, colsJsx);
|
|
114
|
-
}); // Use `React.renderToStsaticMarkup` to generate plain HTML string
|
|
115
|
-
|
|
116
|
-
const html = _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement("table", null, /*#__PURE__*/_react.default.createElement("tbody", null, rowsJsx)));
|
|
117
|
-
|
|
118
|
-
content = [{
|
|
119
|
-
html
|
|
120
|
-
}];
|
|
95
|
+
return cols;
|
|
96
|
+
});
|
|
97
|
+
content = rows;
|
|
121
98
|
break;
|
|
122
99
|
}
|
|
123
100
|
|