@lofcz/platejs-markdown 53.1.3 → 53.1.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.
Files changed (2) hide show
  1. package/dist/index.js +38 -13
  2. 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 && attributes.length > 0) attributes.forEach((attr) => {
119
- if (attr.name && attr.value !== void 0) {
120
- let value = attr.value;
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
- value = JSON.parse(attr.value);
123
- } catch (_error) {
124
- value = attr.value;
133
+ props[attr.name] = JSON.parse(raw);
134
+ } catch {
135
+ props[attr.name] = raw;
125
136
  }
126
- props[attr.name] = value;
137
+ continue;
127
138
  }
128
- });
139
+ props[attr.name] = raw;
140
+ }
129
141
  return props;
130
142
  }
131
143
  function propsToAttributes(props) {
132
- return Object.entries(props).map(([name, value]) => ({
133
- name,
134
- type: "mdxJsxAttribute",
135
- value: typeof value === "string" || value?.type === "mdxJsxAttributeValueExpression" ? value : JSON.stringify(value)
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/platejs-markdown",
3
- "version": "53.1.3",
3
+ "version": "53.1.4",
4
4
  "description": "Markdown serializer plugin for Plate",
5
5
  "keywords": [
6
6
  "markdown",
@@ -51,9 +51,9 @@
51
51
  "remark-emoji": "5.0.1",
52
52
  "remark-gfm": "4.0.1",
53
53
  "remark-math": "6.0.0",
54
- "@platejs/footnote": "npm:@lofcz/platejs-footnote@53.0.0",
55
54
  "@plate/scripts": "1.0.0",
56
- "platejs": "npm:@lofcz/platejs@53.1.1"
55
+ "platejs": "npm:@lofcz/platejs@53.1.1",
56
+ "@platejs/footnote": "npm:@lofcz/platejs-footnote@53.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "platejs": ">=53.0.0",