@lofcz/platejs-markdown 53.1.3 → 53.1.5
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/dist/index.js +39 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -115,25 +115,50 @@ const getCustomMark = (options) => {
|
|
|
115
115
|
//#region src/lib/rules/utils/parseAttributes.ts
|
|
116
116
|
function parseAttributes(attributes) {
|
|
117
117
|
const props = {};
|
|
118
|
-
if (attributes
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
if (!attributes || attributes.length === 0) return props;
|
|
119
|
+
for (const attr of attributes) {
|
|
120
|
+
if (!attr?.name) continue;
|
|
121
|
+
const raw = attr.value;
|
|
122
|
+
if (raw === void 0) continue;
|
|
123
|
+
if (raw === null) {
|
|
124
|
+
props[attr.name] = true;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (typeof raw === "object") {
|
|
128
|
+
props[attr.name] = raw;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (typeof raw === "string") {
|
|
121
132
|
try {
|
|
122
|
-
|
|
123
|
-
} catch
|
|
124
|
-
|
|
133
|
+
props[attr.name] = JSON.parse(raw);
|
|
134
|
+
} catch {
|
|
135
|
+
props[attr.name] = raw;
|
|
125
136
|
}
|
|
126
|
-
|
|
137
|
+
continue;
|
|
127
138
|
}
|
|
128
|
-
|
|
139
|
+
props[attr.name] = raw;
|
|
140
|
+
}
|
|
129
141
|
return props;
|
|
130
142
|
}
|
|
131
143
|
function propsToAttributes(props) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
const out = [];
|
|
145
|
+
for (const [name, value] of Object.entries(props)) {
|
|
146
|
+
if (value === void 0 || value === null) continue;
|
|
147
|
+
if (value === true) {
|
|
148
|
+
out.push({
|
|
149
|
+
name,
|
|
150
|
+
type: "mdxJsxAttribute",
|
|
151
|
+
value: null
|
|
152
|
+
});
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
out.push({
|
|
156
|
+
name,
|
|
157
|
+
type: "mdxJsxAttribute",
|
|
158
|
+
value: typeof value === "string" || value?.type === "mdxJsxAttributeValueExpression" ? value : JSON.stringify(value)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
137
162
|
}
|
|
138
163
|
|
|
139
164
|
//#endregion
|
|
@@ -1124,7 +1149,7 @@ const serializeMdWithSourceMap = (editor, options) => {
|
|
|
1124
1149
|
const startLine = info.now.line;
|
|
1125
1150
|
const emitted = handler(node, parent, state, info);
|
|
1126
1151
|
const source = node?.data?.sourceMap;
|
|
1127
|
-
if (source
|
|
1152
|
+
if (source) pushSegment(source, emitted, startLine, startLine + (emitted.replace(/(?:\r?\n|\r)+$/g, "").split(/\r?\n|\r/g).length - 1));
|
|
1128
1153
|
if (type === "table" && Array.isArray(node?.children)) for (let r = 0; r < node.children.length; r++) {
|
|
1129
1154
|
const line = r === 0 ? startLine : startLine + 1 + r;
|
|
1130
1155
|
const cells = node.children[r]?.children;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-markdown",
|
|
3
|
-
"version": "53.1.
|
|
3
|
+
"version": "53.1.5",
|
|
4
4
|
"description": "Markdown serializer plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"remark-gfm": "4.0.1",
|
|
53
53
|
"remark-math": "6.0.0",
|
|
54
54
|
"@platejs/footnote": "npm:@lofcz/platejs-footnote@53.0.0",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
55
|
+
"platejs": "npm:@lofcz/platejs@53.1.1",
|
|
56
|
+
"@plate/scripts": "1.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"platejs": ">=53.0.0",
|