react-markdown-table-ts 0.3.0 → 0.3.2
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/README.md +2 -2
- package/dist/index.cjs.js +152 -94
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +152 -94
- package/dist/index.esm.js.map +1 -1
- package/dist/src/index.d.ts +1 -15
- package/dist/src/index.js +20 -158
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +5 -11
- package/dist/src/utils.d.ts +28 -15
- package/dist/src/utils.js +57 -30
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validation.d.ts +8 -2
- package/dist/src/validation.js +36 -8
- package/dist/src/validation.js.map +1 -1
- package/dist/test/MarkdownTable.test.js +6 -6
- package/dist/test/MarkdownTable.test.js.map +1 -1
- package/dist/test/utils.test.js +231 -43
- package/dist/test/utils.test.js.map +1 -1
- package/dist/test/validation.test.js +17 -12
- package/dist/test/validation.test.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -34,10 +34,10 @@ npm install react-markdown-table-ts
|
|
34
34
|
|
35
35
|
| Prop | Type | Default | Description |
|
36
36
|
| :------------------: | :-------------------------------------------: | :---------: | :-----------------------------------------: |
|
37
|
-
| `data` | `string[][]` |
|
37
|
+
| `data` | `string[][]` | `null` | The table data as a 2D array of strings |
|
38
38
|
| `columnAlignments` | `('left' \| 'center' \| 'right' \| 'none')[]` | `[]` | Alignment for each column |
|
39
39
|
| `isCompact` | `boolean` | `false` | Use minimal column widths |
|
40
|
-
| `className` | `string` | `undefined` |
|
40
|
+
| `className` | `string` | `undefined` | CSS class for the `<pre>` tag |
|
41
41
|
| `hasTabs` | `boolean` | `false` | Add tabs between table columns |
|
42
42
|
| `canReplaceNewlines` | `boolean` | `false` | Replace newlines in cells with `<br>` tags |
|
43
43
|
| `onTableCreate` | `(markdownString: string) => void` | `undefined` | Callback to receive the Markdown string |
|
package/dist/index.cjs.js
CHANGED
@@ -8,52 +8,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
8
8
|
|
9
9
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
10
10
|
|
11
|
-
/******************************************************************************
|
12
|
-
Copyright (c) Microsoft Corporation.
|
13
|
-
|
14
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
15
|
-
purpose with or without fee is hereby granted.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
18
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
19
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
20
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
21
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
22
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
23
|
-
PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
***************************************************************************** */
|
25
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
26
|
-
|
27
|
-
var extendStatics = function(d, b) {
|
28
|
-
extendStatics = Object.setPrototypeOf ||
|
29
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
30
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
31
|
-
return extendStatics(d, b);
|
32
|
-
};
|
33
|
-
|
34
|
-
function __extends(d, b) {
|
35
|
-
if (typeof b !== "function" && b !== null)
|
36
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
37
|
-
extendStatics(d, b);
|
38
|
-
function __() { this.constructor = d; }
|
39
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
40
|
-
}
|
41
|
-
|
42
|
-
function __spreadArray(to, from, pack) {
|
43
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
44
|
-
if (ar || !(i in from)) {
|
45
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
46
|
-
ar[i] = from[i];
|
47
|
-
}
|
48
|
-
}
|
49
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
50
|
-
}
|
51
|
-
|
52
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
53
|
-
var e = new Error(message);
|
54
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
55
|
-
};
|
56
|
-
|
57
11
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
58
12
|
|
59
13
|
function getDefaultExportFromCjs (x) {
|
@@ -4057,42 +4011,106 @@ var Prism$1 = /*@__PURE__*/getDefaultExportFromCjs(prismExports);
|
|
4057
4011
|
|
4058
4012
|
}());
|
4059
4013
|
|
4060
|
-
|
4061
|
-
|
4014
|
+
/******************************************************************************
|
4015
|
+
Copyright (c) Microsoft Corporation.
|
4016
|
+
|
4017
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4018
|
+
purpose with or without fee is hereby granted.
|
4019
|
+
|
4020
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
4021
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
4022
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
4023
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
4024
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
4025
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
4026
|
+
PERFORMANCE OF THIS SOFTWARE.
|
4027
|
+
***************************************************************************** */
|
4028
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
4029
|
+
|
4030
|
+
var extendStatics = function(d, b) {
|
4031
|
+
extendStatics = Object.setPrototypeOf ||
|
4032
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4033
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
4034
|
+
return extendStatics(d, b);
|
4035
|
+
};
|
4036
|
+
|
4037
|
+
function __extends(d, b) {
|
4038
|
+
if (typeof b !== "function" && b !== null)
|
4039
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
4040
|
+
extendStatics(d, b);
|
4041
|
+
function __() { this.constructor = d; }
|
4042
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
4043
|
+
}
|
4044
|
+
|
4045
|
+
function __spreadArray(to, from, pack) {
|
4046
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
4047
|
+
if (ar || !(i in from)) {
|
4048
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
4049
|
+
ar[i] = from[i];
|
4050
|
+
}
|
4051
|
+
}
|
4052
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
4053
|
+
}
|
4054
|
+
|
4055
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
4056
|
+
var e = new Error(message);
|
4057
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
4058
|
+
};
|
4059
|
+
|
4060
|
+
// src/validation.ts
|
4061
|
+
/**
|
4062
|
+
* Custom error class for handling Markdown table generation errors.
|
4063
|
+
*/
|
4062
4064
|
var MarkdownTableError = /** @class */ (function (_super) {
|
4063
4065
|
__extends(MarkdownTableError, _super);
|
4064
4066
|
function MarkdownTableError(message) {
|
4065
4067
|
var _this = _super.call(this, message) || this;
|
4066
4068
|
_this.name = 'MarkdownTableError';
|
4069
|
+
Object.setPrototypeOf(_this, MarkdownTableError.prototype);
|
4067
4070
|
return _this;
|
4068
4071
|
}
|
4069
4072
|
return MarkdownTableError;
|
4070
4073
|
}(Error));
|
4071
|
-
|
4072
|
-
|
4073
|
-
|
4074
|
+
|
4075
|
+
// src/utils.ts
|
4076
|
+
/**
|
4077
|
+
* Calculates the maximum width for each column based on the content.
|
4078
|
+
* @param tableRows - All rows (header and body) of the table.
|
4079
|
+
* @param maxColumnCount - The maximum number of columns in the table.
|
4080
|
+
* @returns An array of maximum widths for each column.
|
4081
|
+
*/
|
4082
|
+
function calculateColumnWidths(tableRows, maxColumnCount) {
|
4083
|
+
var widths = new Array(maxColumnCount).fill(3); // Minimum width of 3 for each column.
|
4084
|
+
tableRows.forEach(function (currentRow) {
|
4074
4085
|
var _a;
|
4075
4086
|
for (var i = 0; i < maxColumnCount; i++) {
|
4076
|
-
var cell = (_a =
|
4087
|
+
var cell = (_a = currentRow[i]) !== null && _a !== void 0 ? _a : '';
|
4077
4088
|
widths[i] = Math.max(widths[i], cell.length);
|
4078
4089
|
}
|
4079
4090
|
});
|
4080
4091
|
return widths;
|
4081
4092
|
}
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4093
|
+
/**
|
4094
|
+
* Formats a single row into a Markdown-formatted string.
|
4095
|
+
* @param columnCount - The number of columns in the table.
|
4096
|
+
* @param currentRow - The data of the current row.
|
4097
|
+
* @param columnAlignments - Alignment settings for each column.
|
4098
|
+
* @param columnWidths - Widths of each column.
|
4099
|
+
* @param useTabs - Flag to use tabs between columns.
|
4100
|
+
* @param canReplaceNewlines - Flag to replace newlines with <br> tags.
|
4101
|
+
* @returns The Markdown string for the row.
|
4102
|
+
*/
|
4103
|
+
function formatMarkdownRow(columnCount, currentRow, columnAlignments, columnWidths, useTabs, canReplaceNewlines) {
|
4086
4104
|
var _a, _b;
|
4087
4105
|
if (useTabs === void 0) { useTabs = false; }
|
4088
|
-
if (
|
4106
|
+
if (canReplaceNewlines === void 0) { canReplaceNewlines = false; }
|
4089
4107
|
var defaultAlignment = 'left';
|
4090
4108
|
var adjustedAlignments = columnAlignments.length < columnCount
|
4091
4109
|
? __spreadArray(__spreadArray([], columnAlignments, true), Array(columnCount - columnAlignments.length).fill(defaultAlignment), true) : columnAlignments;
|
4092
4110
|
var markdownRow = '|';
|
4093
4111
|
for (var i = 0; i < columnCount; i++) {
|
4094
|
-
var cell = (_a =
|
4095
|
-
if (
|
4112
|
+
var cell = (_a = currentRow[i]) !== null && _a !== void 0 ? _a : '';
|
4113
|
+
if (canReplaceNewlines) {
|
4096
4114
|
cell = replaceNewlinesInCell(cell);
|
4097
4115
|
}
|
4098
4116
|
var alignment = (_b = adjustedAlignments[i]) !== null && _b !== void 0 ? _b : defaultAlignment;
|
@@ -4107,11 +4125,20 @@ function formatMarkdownRow(columnCount, row, columnAlignments, columnWidths, use
|
|
4107
4125
|
markdownRow += "".concat(useTabs ? '\t' : ' ').concat(' '.repeat(paddingLeft)).concat(cell).concat(' '.repeat(paddingRight)).concat(useTabs ? '\t' : ' ', "|");
|
4108
4126
|
}
|
4109
4127
|
else {
|
4128
|
+
// Left alignment or default
|
4110
4129
|
markdownRow += "".concat(useTabs ? '\t' : ' ').concat(cell.padEnd(targetWidth)).concat(useTabs ? '\t' : ' ', "|");
|
4111
4130
|
}
|
4112
4131
|
}
|
4113
4132
|
return markdownRow;
|
4114
4133
|
}
|
4134
|
+
/**
|
4135
|
+
* Generates the alignment row for the Markdown table syntax.
|
4136
|
+
* @param columnCount - The number of columns in the table.
|
4137
|
+
* @param columnAlignments - Alignment settings for each column.
|
4138
|
+
* @param columnWidths - Widths of each column.
|
4139
|
+
* @param useTabs - Flag to use tabs between columns.
|
4140
|
+
* @returns The Markdown string for the alignment row.
|
4141
|
+
*/
|
4115
4142
|
function formatAlignmentRow(columnCount, columnAlignments, columnWidths, useTabs) {
|
4116
4143
|
var _a;
|
4117
4144
|
if (useTabs === void 0) { useTabs = false; }
|
@@ -4141,61 +4168,92 @@ function formatAlignmentRow(columnCount, columnAlignments, columnWidths, useTabs
|
|
4141
4168
|
}
|
4142
4169
|
return alignmentRow;
|
4143
4170
|
}
|
4144
|
-
|
4145
|
-
|
4171
|
+
/**
|
4172
|
+
* Generates a complete Markdown table string from the provided data.
|
4173
|
+
* @param inputData - The table data including headers and rows.
|
4174
|
+
* @param columnAlignments - Alignment settings for each column.
|
4175
|
+
* @param canAdjustColumnWidths - Flag to adjust column widths based on content.
|
4176
|
+
* @param useTabs - Flag to use tabs between columns.
|
4177
|
+
* @param replaceNewlines - Flag to replace newlines with <br> tags.
|
4178
|
+
* @returns The complete Markdown table string.
|
4179
|
+
*/
|
4180
|
+
function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines) {
|
4181
|
+
if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
|
4146
4182
|
if (useTabs === void 0) { useTabs = false; }
|
4147
4183
|
if (replaceNewlines === void 0) { replaceNewlines = false; }
|
4148
|
-
var headerColumnCount =
|
4149
|
-
var bodyColumnCounts =
|
4184
|
+
var headerColumnCount = inputData.inputDataHeader.length;
|
4185
|
+
var bodyColumnCounts = inputData.inputDataBody.map(function (currentRow) { return currentRow.length; });
|
4150
4186
|
var maxColumnCount = Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
|
4151
|
-
var columnWidths =
|
4152
|
-
? calculateColumnWidths(__spreadArray([
|
4187
|
+
var columnWidths = canAdjustColumnWidths
|
4188
|
+
? calculateColumnWidths(__spreadArray([inputData.inputDataHeader], inputData.inputDataBody, true), maxColumnCount)
|
4153
4189
|
: undefined;
|
4154
|
-
var markdownHeaderRow = formatMarkdownRow(maxColumnCount,
|
4190
|
+
var markdownHeaderRow = formatMarkdownRow(maxColumnCount, inputData.inputDataHeader, columnAlignments, columnWidths, useTabs, replaceNewlines);
|
4155
4191
|
var markdownAlignmentRow = formatAlignmentRow(maxColumnCount, columnAlignments, columnWidths, useTabs);
|
4156
|
-
var markdownBodyRows =
|
4157
|
-
.map(function (
|
4158
|
-
return formatMarkdownRow(maxColumnCount,
|
4192
|
+
var markdownBodyRows = inputData.inputDataBody
|
4193
|
+
.map(function (currentRow) {
|
4194
|
+
return formatMarkdownRow(maxColumnCount, currentRow, columnAlignments, columnWidths, useTabs, replaceNewlines);
|
4159
4195
|
})
|
4160
4196
|
.join('\n');
|
4161
4197
|
return "".concat(markdownHeaderRow, "\n").concat(markdownAlignmentRow, "\n").concat(markdownBodyRows).trimEnd();
|
4162
4198
|
}
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4199
|
+
/**
|
4200
|
+
* Replaces newline characters in a string with <br> tags.
|
4201
|
+
* @param cell - The cell content to process.
|
4202
|
+
* @returns The processed cell content with newlines replaced.
|
4203
|
+
*/
|
4204
|
+
function replaceNewlinesInCell(cell) {
|
4205
|
+
return cell.replace(/\n/g, '<br>');
|
4169
4206
|
}
|
4207
|
+
/**
|
4208
|
+
* Converts a zero-based column index to its corresponding Excel-style column name.
|
4209
|
+
* For example, 0 -> 'A', 1 -> 'B', ..., 25 -> 'Z', 26 -> 'AA', etc.
|
4210
|
+
* @param index - The zero-based column index.
|
4211
|
+
* @returns The corresponding column name.
|
4212
|
+
*/
|
4170
4213
|
function getColumnName(index) {
|
4171
|
-
var
|
4214
|
+
var columnName = '';
|
4172
4215
|
var currentIndex = index;
|
4173
4216
|
while (currentIndex >= 0) {
|
4174
|
-
|
4217
|
+
columnName = String.fromCharCode((currentIndex % 26) + 65) + columnName;
|
4175
4218
|
currentIndex = Math.floor(currentIndex / 26) - 1;
|
4176
4219
|
}
|
4177
|
-
return
|
4220
|
+
return columnName;
|
4178
4221
|
}
|
4222
|
+
/**
|
4223
|
+
* Generates an array of alphabetic headers based on the specified column count.
|
4224
|
+
* @param columnCount - The number of columns.
|
4225
|
+
* @returns An array of column header names.
|
4226
|
+
*/
|
4227
|
+
function generateAlphabetHeaders(columnCount) {
|
4228
|
+
var alphabetHeaders = [];
|
4229
|
+
for (var i = 0; i < columnCount; i++) {
|
4230
|
+
alphabetHeaders.push(getColumnName(i));
|
4231
|
+
}
|
4232
|
+
return alphabetHeaders;
|
4233
|
+
}
|
4234
|
+
|
4235
|
+
// CSS styles
|
4236
|
+
var PRISM_CSS = "\ncode[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,\"Andale Mono\",\"Ubuntu Mono\",monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}\n";
|
4179
4237
|
var MarkdownTable = function (_a) {
|
4180
|
-
var _b = _a.
|
4238
|
+
var _b = _a.inputData, inputData = _b === void 0 ? null : _b, _c = _a.hasHeader, hasHeader = _c === void 0 ? true : _c, _d = _a.columnAlignments, columnAlignments = _d === void 0 ? [] : _d, _e = _a.isCompact, isCompact = _e === void 0 ? false : _e, _f = _a.hasTabs, hasTabs = _f === void 0 ? false : _f, _g = _a.canReplaceNewlines, canReplaceNewlines = _g === void 0 ? false : _g, className = _a.className, onTableCreate = _a.onTableCreate;
|
4181
4239
|
var adjustColumnWidths = !isCompact;
|
4182
|
-
var
|
4183
|
-
var
|
4184
|
-
if (
|
4240
|
+
var preElementRef = require$$0.useRef(null);
|
4241
|
+
var markdownTableSyntax = require$$0.useMemo(function () {
|
4242
|
+
if (inputData === null) {
|
4185
4243
|
return 'Error: No data provided for the table.';
|
4186
4244
|
}
|
4187
4245
|
try {
|
4188
|
-
if (!Array.isArray(
|
4246
|
+
if (!Array.isArray(inputData) || inputData.length === 0) {
|
4189
4247
|
throw new MarkdownTableError("The 'data' prop must be a non-empty two-dimensional array.");
|
4190
4248
|
}
|
4191
4249
|
var tableData = hasHeader
|
4192
4250
|
? {
|
4193
|
-
|
4194
|
-
|
4251
|
+
inputDataHeader: inputData[0],
|
4252
|
+
inputDataBody: inputData.slice(1),
|
4195
4253
|
}
|
4196
4254
|
: {
|
4197
|
-
|
4198
|
-
|
4255
|
+
inputDataHeader: generateAlphabetHeaders(inputData[0].length),
|
4256
|
+
inputDataBody: inputData,
|
4199
4257
|
};
|
4200
4258
|
return generateMarkdownTableString(tableData, columnAlignments, adjustColumnWidths, hasTabs, canReplaceNewlines);
|
4201
4259
|
}
|
@@ -4208,7 +4266,7 @@ var MarkdownTable = function (_a) {
|
|
4208
4266
|
}
|
4209
4267
|
}
|
4210
4268
|
}, [
|
4211
|
-
|
4269
|
+
inputData,
|
4212
4270
|
hasHeader,
|
4213
4271
|
columnAlignments,
|
4214
4272
|
isCompact,
|
@@ -4217,15 +4275,15 @@ var MarkdownTable = function (_a) {
|
|
4217
4275
|
]);
|
4218
4276
|
require$$0.useEffect(function () {
|
4219
4277
|
if (onTableCreate) {
|
4220
|
-
onTableCreate(
|
4278
|
+
onTableCreate(markdownTableSyntax);
|
4221
4279
|
}
|
4222
|
-
}, [
|
4280
|
+
}, [markdownTableSyntax, onTableCreate]);
|
4223
4281
|
require$$0.useEffect(function () {
|
4224
|
-
if (
|
4225
|
-
Prism$1.highlightElement(
|
4282
|
+
if (preElementRef.current) {
|
4283
|
+
Prism$1.highlightElement(preElementRef.current.querySelector('code'));
|
4226
4284
|
}
|
4227
|
-
}, [
|
4228
|
-
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { children:
|
4285
|
+
}, [markdownTableSyntax]);
|
4286
|
+
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { children: PRISM_CSS }), jsxRuntimeExports.jsx("pre", { ref: preElementRef, className: "".concat(className, " language-markdown line-numbers"), children: jsxRuntimeExports.jsx("code", { className: "language-markdown", role: "code", children: markdownTableSyntax }) })] }));
|
4229
4287
|
};
|
4230
4288
|
|
4231
4289
|
exports.MarkdownTable = MarkdownTable;
|