@valbuild/shared 0.65.2 → 0.67.0
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/declarations/src/internal/richtext/conversion/remirrorToRichTextSource.d.ts +2 -2
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +24 -23
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +24 -23
- package/internal/dist/valbuild-shared-internal.esm.js +25 -24
- package/package.json +2 -3
@@ -1,6 +1,6 @@
|
|
1
|
-
import { RichTextSource, AllRichTextOptions } from "@valbuild/core";
|
1
|
+
import { RichTextSource, AllRichTextOptions, ConfigDirectory } from "@valbuild/core";
|
2
2
|
import { RemirrorJSON } from "./remirrorTypes.js";
|
3
|
-
export declare function remirrorToRichTextSource(node: RemirrorJSON): {
|
3
|
+
export declare function remirrorToRichTextSource(node: RemirrorJSON, configDirectory: ConfigDirectory): {
|
4
4
|
blocks: RichTextSource<AllRichTextOptions>;
|
5
5
|
files: Record<string, {
|
6
6
|
value: string;
|
@@ -117,7 +117,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
117
117
|
};
|
118
118
|
}
|
119
119
|
|
120
|
-
function remirrorToRichTextSource(node) {
|
120
|
+
function remirrorToRichTextSource(node, configDirectory) {
|
121
121
|
var files = {};
|
122
122
|
var blocks = [];
|
123
123
|
var i = 0;
|
@@ -126,7 +126,7 @@ function remirrorToRichTextSource(node) {
|
|
126
126
|
try {
|
127
127
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
128
128
|
var child = _step.value;
|
129
|
-
var block = convertBlock([(i++).toString()], child, files);
|
129
|
+
var block = convertBlock([(i++).toString()], child, files, configDirectory);
|
130
130
|
blocks.push(block);
|
131
131
|
}
|
132
132
|
} catch (err) {
|
@@ -139,7 +139,7 @@ function remirrorToRichTextSource(node) {
|
|
139
139
|
files: files
|
140
140
|
};
|
141
141
|
}
|
142
|
-
function convertBlock(path, node, files) {
|
142
|
+
function convertBlock(path, node, files, configDirectory) {
|
143
143
|
if (node.type === "heading") {
|
144
144
|
var _node$attrs, _node$content;
|
145
145
|
var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
|
@@ -149,21 +149,21 @@ function convertBlock(path, node, files) {
|
|
149
149
|
return {
|
150
150
|
tag: "h".concat(depth),
|
151
151
|
children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
|
152
|
-
return convertHeadingChild(path.concat("children", i.toString()), child, files);
|
152
|
+
return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
|
153
153
|
})) || []
|
154
154
|
};
|
155
155
|
} else if (node.type === "paragraph") {
|
156
|
-
return convertParagraph(path, node, files);
|
156
|
+
return convertParagraph(path, node, files, configDirectory);
|
157
157
|
} else if (node.type === "bulletList") {
|
158
|
-
return convertBulletList(path, node, files);
|
158
|
+
return convertBulletList(path, node, files, configDirectory);
|
159
159
|
} else if (node.type === "orderedList") {
|
160
|
-
return convertOrderedList(path, node, files);
|
160
|
+
return convertOrderedList(path, node, files, configDirectory);
|
161
161
|
} else {
|
162
162
|
var exhaustiveCheck = node;
|
163
163
|
throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
|
164
164
|
}
|
165
165
|
}
|
166
|
-
function convertHeadingChild(path, node, files) {
|
166
|
+
function convertHeadingChild(path, node, files, configDirectory) {
|
167
167
|
if (node.type === "text") {
|
168
168
|
return convertTextNode(node);
|
169
169
|
} else if (node.type === "hardBreak") {
|
@@ -171,13 +171,13 @@ function convertHeadingChild(path, node, files) {
|
|
171
171
|
tag: "br"
|
172
172
|
};
|
173
173
|
} else if (node.type === "image") {
|
174
|
-
return convertImageNode(path, node, files);
|
174
|
+
return convertImageNode(path, node, files, configDirectory);
|
175
175
|
} else {
|
176
176
|
var exhaustiveCheck = node;
|
177
177
|
throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
178
178
|
}
|
179
179
|
}
|
180
|
-
function convertParagraph(path, child, files) {
|
180
|
+
function convertParagraph(path, child, files, configDirectory) {
|
181
181
|
var _child$content;
|
182
182
|
return {
|
183
183
|
tag: "p",
|
@@ -189,7 +189,7 @@ function convertParagraph(path, child, files) {
|
|
189
189
|
tag: "br"
|
190
190
|
};
|
191
191
|
} else if (child.type === "image") {
|
192
|
-
return convertImageNode(path.concat("children", i.toString()), child, files);
|
192
|
+
return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
|
193
193
|
}
|
194
194
|
var exhaustiveCheck = child;
|
195
195
|
throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
@@ -248,17 +248,17 @@ function convertTextNode(node) {
|
|
248
248
|
throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
|
249
249
|
}
|
250
250
|
}
|
251
|
-
function convertListItem(path, child, files) {
|
251
|
+
function convertListItem(path, child, files, configDirectory) {
|
252
252
|
var _child$content2;
|
253
253
|
return {
|
254
254
|
tag: "li",
|
255
255
|
children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
|
256
256
|
if (child.type === "paragraph") {
|
257
|
-
return convertParagraph(path.concat("children", i.toString()), child, files);
|
257
|
+
return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
|
258
258
|
} else if (child.type === "bulletList") {
|
259
|
-
return convertBulletList(path.concat("children", i.toString()), child, files);
|
259
|
+
return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
|
260
260
|
} else if (child.type === "orderedList") {
|
261
|
-
return convertOrderedList(path.concat("children", i.toString()), child, files);
|
261
|
+
return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
|
262
262
|
} else {
|
263
263
|
var exhaustiveCheck = child;
|
264
264
|
throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
|
@@ -266,13 +266,13 @@ function convertListItem(path, child, files) {
|
|
266
266
|
})) || []
|
267
267
|
};
|
268
268
|
}
|
269
|
-
function convertBulletList(path, node, files) {
|
269
|
+
function convertBulletList(path, node, files, configDirectory) {
|
270
270
|
var _node$content2;
|
271
271
|
return {
|
272
272
|
tag: "ul",
|
273
273
|
children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
|
274
274
|
if (child.type === "listItem") {
|
275
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
275
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
276
276
|
} else {
|
277
277
|
var exhaustiveCheck = child.type;
|
278
278
|
throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
|
@@ -280,13 +280,13 @@ function convertBulletList(path, node, files) {
|
|
280
280
|
})) || []
|
281
281
|
};
|
282
282
|
}
|
283
|
-
function convertOrderedList(path, node, files) {
|
283
|
+
function convertOrderedList(path, node, files, configDirectory) {
|
284
284
|
var _node$content3;
|
285
285
|
return {
|
286
286
|
tag: "ol",
|
287
287
|
children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
|
288
288
|
if (child.type === "listItem") {
|
289
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
289
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
290
290
|
} else {
|
291
291
|
var exhaustiveCheck = child.type;
|
292
292
|
throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
|
@@ -295,7 +295,7 @@ function convertOrderedList(path, node, files) {
|
|
295
295
|
};
|
296
296
|
}
|
297
297
|
var textEncoder = new TextEncoder();
|
298
|
-
function convertImageNode(path, node, files) {
|
298
|
+
function convertImageNode(path, node, files, configDirectory) {
|
299
299
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
300
300
|
var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
|
301
301
|
var mimeType = core.Internal.getMimeType(node.attrs.src);
|
@@ -307,7 +307,8 @@ function convertImageNode(path, node, files) {
|
|
307
307
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
308
308
|
mimeType: mimeType
|
309
309
|
}, sha256);
|
310
|
-
var
|
310
|
+
var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
|
311
|
+
var filePath = "".concat(dir).concat(fileName);
|
311
312
|
var existingFilesEntry = files[filePath];
|
312
313
|
var thisPath = path
|
313
314
|
// file is added as src (see below):
|
@@ -322,7 +323,7 @@ function convertImageNode(path, node, files) {
|
|
322
323
|
}
|
323
324
|
return {
|
324
325
|
tag: "img",
|
325
|
-
src: _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
|
326
|
+
src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
326
327
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
327
328
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
328
329
|
mimeType: mimeType
|
@@ -347,7 +348,7 @@ function convertImageNode(path, node, files) {
|
|
347
348
|
}
|
348
349
|
var tag = {
|
349
350
|
tag: "img",
|
350
|
-
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), "metadata", {
|
351
|
+
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
351
352
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
352
353
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
353
354
|
mimeType: noParamsUrl && core.Internal.filenameToMimeType(noParamsUrl) || ""
|
@@ -117,7 +117,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
117
117
|
};
|
118
118
|
}
|
119
119
|
|
120
|
-
function remirrorToRichTextSource(node) {
|
120
|
+
function remirrorToRichTextSource(node, configDirectory) {
|
121
121
|
var files = {};
|
122
122
|
var blocks = [];
|
123
123
|
var i = 0;
|
@@ -126,7 +126,7 @@ function remirrorToRichTextSource(node) {
|
|
126
126
|
try {
|
127
127
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
128
128
|
var child = _step.value;
|
129
|
-
var block = convertBlock([(i++).toString()], child, files);
|
129
|
+
var block = convertBlock([(i++).toString()], child, files, configDirectory);
|
130
130
|
blocks.push(block);
|
131
131
|
}
|
132
132
|
} catch (err) {
|
@@ -139,7 +139,7 @@ function remirrorToRichTextSource(node) {
|
|
139
139
|
files: files
|
140
140
|
};
|
141
141
|
}
|
142
|
-
function convertBlock(path, node, files) {
|
142
|
+
function convertBlock(path, node, files, configDirectory) {
|
143
143
|
if (node.type === "heading") {
|
144
144
|
var _node$attrs, _node$content;
|
145
145
|
var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
|
@@ -149,21 +149,21 @@ function convertBlock(path, node, files) {
|
|
149
149
|
return {
|
150
150
|
tag: "h".concat(depth),
|
151
151
|
children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
|
152
|
-
return convertHeadingChild(path.concat("children", i.toString()), child, files);
|
152
|
+
return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
|
153
153
|
})) || []
|
154
154
|
};
|
155
155
|
} else if (node.type === "paragraph") {
|
156
|
-
return convertParagraph(path, node, files);
|
156
|
+
return convertParagraph(path, node, files, configDirectory);
|
157
157
|
} else if (node.type === "bulletList") {
|
158
|
-
return convertBulletList(path, node, files);
|
158
|
+
return convertBulletList(path, node, files, configDirectory);
|
159
159
|
} else if (node.type === "orderedList") {
|
160
|
-
return convertOrderedList(path, node, files);
|
160
|
+
return convertOrderedList(path, node, files, configDirectory);
|
161
161
|
} else {
|
162
162
|
var exhaustiveCheck = node;
|
163
163
|
throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
|
164
164
|
}
|
165
165
|
}
|
166
|
-
function convertHeadingChild(path, node, files) {
|
166
|
+
function convertHeadingChild(path, node, files, configDirectory) {
|
167
167
|
if (node.type === "text") {
|
168
168
|
return convertTextNode(node);
|
169
169
|
} else if (node.type === "hardBreak") {
|
@@ -171,13 +171,13 @@ function convertHeadingChild(path, node, files) {
|
|
171
171
|
tag: "br"
|
172
172
|
};
|
173
173
|
} else if (node.type === "image") {
|
174
|
-
return convertImageNode(path, node, files);
|
174
|
+
return convertImageNode(path, node, files, configDirectory);
|
175
175
|
} else {
|
176
176
|
var exhaustiveCheck = node;
|
177
177
|
throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
178
178
|
}
|
179
179
|
}
|
180
|
-
function convertParagraph(path, child, files) {
|
180
|
+
function convertParagraph(path, child, files, configDirectory) {
|
181
181
|
var _child$content;
|
182
182
|
return {
|
183
183
|
tag: "p",
|
@@ -189,7 +189,7 @@ function convertParagraph(path, child, files) {
|
|
189
189
|
tag: "br"
|
190
190
|
};
|
191
191
|
} else if (child.type === "image") {
|
192
|
-
return convertImageNode(path.concat("children", i.toString()), child, files);
|
192
|
+
return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
|
193
193
|
}
|
194
194
|
var exhaustiveCheck = child;
|
195
195
|
throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
@@ -248,17 +248,17 @@ function convertTextNode(node) {
|
|
248
248
|
throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
|
249
249
|
}
|
250
250
|
}
|
251
|
-
function convertListItem(path, child, files) {
|
251
|
+
function convertListItem(path, child, files, configDirectory) {
|
252
252
|
var _child$content2;
|
253
253
|
return {
|
254
254
|
tag: "li",
|
255
255
|
children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
|
256
256
|
if (child.type === "paragraph") {
|
257
|
-
return convertParagraph(path.concat("children", i.toString()), child, files);
|
257
|
+
return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
|
258
258
|
} else if (child.type === "bulletList") {
|
259
|
-
return convertBulletList(path.concat("children", i.toString()), child, files);
|
259
|
+
return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
|
260
260
|
} else if (child.type === "orderedList") {
|
261
|
-
return convertOrderedList(path.concat("children", i.toString()), child, files);
|
261
|
+
return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
|
262
262
|
} else {
|
263
263
|
var exhaustiveCheck = child;
|
264
264
|
throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
|
@@ -266,13 +266,13 @@ function convertListItem(path, child, files) {
|
|
266
266
|
})) || []
|
267
267
|
};
|
268
268
|
}
|
269
|
-
function convertBulletList(path, node, files) {
|
269
|
+
function convertBulletList(path, node, files, configDirectory) {
|
270
270
|
var _node$content2;
|
271
271
|
return {
|
272
272
|
tag: "ul",
|
273
273
|
children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
|
274
274
|
if (child.type === "listItem") {
|
275
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
275
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
276
276
|
} else {
|
277
277
|
var exhaustiveCheck = child.type;
|
278
278
|
throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
|
@@ -280,13 +280,13 @@ function convertBulletList(path, node, files) {
|
|
280
280
|
})) || []
|
281
281
|
};
|
282
282
|
}
|
283
|
-
function convertOrderedList(path, node, files) {
|
283
|
+
function convertOrderedList(path, node, files, configDirectory) {
|
284
284
|
var _node$content3;
|
285
285
|
return {
|
286
286
|
tag: "ol",
|
287
287
|
children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
|
288
288
|
if (child.type === "listItem") {
|
289
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
289
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
290
290
|
} else {
|
291
291
|
var exhaustiveCheck = child.type;
|
292
292
|
throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
|
@@ -295,7 +295,7 @@ function convertOrderedList(path, node, files) {
|
|
295
295
|
};
|
296
296
|
}
|
297
297
|
var textEncoder = new TextEncoder();
|
298
|
-
function convertImageNode(path, node, files) {
|
298
|
+
function convertImageNode(path, node, files, configDirectory) {
|
299
299
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
300
300
|
var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
|
301
301
|
var mimeType = core.Internal.getMimeType(node.attrs.src);
|
@@ -307,7 +307,8 @@ function convertImageNode(path, node, files) {
|
|
307
307
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
308
308
|
mimeType: mimeType
|
309
309
|
}, sha256);
|
310
|
-
var
|
310
|
+
var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
|
311
|
+
var filePath = "".concat(dir).concat(fileName);
|
311
312
|
var existingFilesEntry = files[filePath];
|
312
313
|
var thisPath = path
|
313
314
|
// file is added as src (see below):
|
@@ -322,7 +323,7 @@ function convertImageNode(path, node, files) {
|
|
322
323
|
}
|
323
324
|
return {
|
324
325
|
tag: "img",
|
325
|
-
src: _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
|
326
|
+
src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
326
327
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
327
328
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
328
329
|
mimeType: mimeType
|
@@ -347,7 +348,7 @@ function convertImageNode(path, node, files) {
|
|
347
348
|
}
|
348
349
|
var tag = {
|
349
350
|
tag: "img",
|
350
|
-
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), "metadata", {
|
351
|
+
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
351
352
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
352
353
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
353
354
|
mimeType: noParamsUrl && core.Internal.filenameToMimeType(noParamsUrl) || ""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
1
|
+
import { Internal, VAL_EXTENSION, FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from '@valbuild/core';
|
2
2
|
import { z } from 'zod';
|
3
3
|
import { result } from '@valbuild/core/fp';
|
4
4
|
import { fromZodError } from 'zod-validation-error';
|
@@ -113,7 +113,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
113
113
|
};
|
114
114
|
}
|
115
115
|
|
116
|
-
function remirrorToRichTextSource(node) {
|
116
|
+
function remirrorToRichTextSource(node, configDirectory) {
|
117
117
|
var files = {};
|
118
118
|
var blocks = [];
|
119
119
|
var i = 0;
|
@@ -122,7 +122,7 @@ function remirrorToRichTextSource(node) {
|
|
122
122
|
try {
|
123
123
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
124
124
|
var child = _step.value;
|
125
|
-
var block = convertBlock([(i++).toString()], child, files);
|
125
|
+
var block = convertBlock([(i++).toString()], child, files, configDirectory);
|
126
126
|
blocks.push(block);
|
127
127
|
}
|
128
128
|
} catch (err) {
|
@@ -135,7 +135,7 @@ function remirrorToRichTextSource(node) {
|
|
135
135
|
files: files
|
136
136
|
};
|
137
137
|
}
|
138
|
-
function convertBlock(path, node, files) {
|
138
|
+
function convertBlock(path, node, files, configDirectory) {
|
139
139
|
if (node.type === "heading") {
|
140
140
|
var _node$attrs, _node$content;
|
141
141
|
var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
|
@@ -145,21 +145,21 @@ function convertBlock(path, node, files) {
|
|
145
145
|
return {
|
146
146
|
tag: "h".concat(depth),
|
147
147
|
children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
|
148
|
-
return convertHeadingChild(path.concat("children", i.toString()), child, files);
|
148
|
+
return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
|
149
149
|
})) || []
|
150
150
|
};
|
151
151
|
} else if (node.type === "paragraph") {
|
152
|
-
return convertParagraph(path, node, files);
|
152
|
+
return convertParagraph(path, node, files, configDirectory);
|
153
153
|
} else if (node.type === "bulletList") {
|
154
|
-
return convertBulletList(path, node, files);
|
154
|
+
return convertBulletList(path, node, files, configDirectory);
|
155
155
|
} else if (node.type === "orderedList") {
|
156
|
-
return convertOrderedList(path, node, files);
|
156
|
+
return convertOrderedList(path, node, files, configDirectory);
|
157
157
|
} else {
|
158
158
|
var exhaustiveCheck = node;
|
159
159
|
throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
|
160
160
|
}
|
161
161
|
}
|
162
|
-
function convertHeadingChild(path, node, files) {
|
162
|
+
function convertHeadingChild(path, node, files, configDirectory) {
|
163
163
|
if (node.type === "text") {
|
164
164
|
return convertTextNode(node);
|
165
165
|
} else if (node.type === "hardBreak") {
|
@@ -167,13 +167,13 @@ function convertHeadingChild(path, node, files) {
|
|
167
167
|
tag: "br"
|
168
168
|
};
|
169
169
|
} else if (node.type === "image") {
|
170
|
-
return convertImageNode(path, node, files);
|
170
|
+
return convertImageNode(path, node, files, configDirectory);
|
171
171
|
} else {
|
172
172
|
var exhaustiveCheck = node;
|
173
173
|
throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
174
174
|
}
|
175
175
|
}
|
176
|
-
function convertParagraph(path, child, files) {
|
176
|
+
function convertParagraph(path, child, files, configDirectory) {
|
177
177
|
var _child$content;
|
178
178
|
return {
|
179
179
|
tag: "p",
|
@@ -185,7 +185,7 @@ function convertParagraph(path, child, files) {
|
|
185
185
|
tag: "br"
|
186
186
|
};
|
187
187
|
} else if (child.type === "image") {
|
188
|
-
return convertImageNode(path.concat("children", i.toString()), child, files);
|
188
|
+
return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
|
189
189
|
}
|
190
190
|
var exhaustiveCheck = child;
|
191
191
|
throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
@@ -244,17 +244,17 @@ function convertTextNode(node) {
|
|
244
244
|
throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
|
245
245
|
}
|
246
246
|
}
|
247
|
-
function convertListItem(path, child, files) {
|
247
|
+
function convertListItem(path, child, files, configDirectory) {
|
248
248
|
var _child$content2;
|
249
249
|
return {
|
250
250
|
tag: "li",
|
251
251
|
children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
|
252
252
|
if (child.type === "paragraph") {
|
253
|
-
return convertParagraph(path.concat("children", i.toString()), child, files);
|
253
|
+
return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
|
254
254
|
} else if (child.type === "bulletList") {
|
255
|
-
return convertBulletList(path.concat("children", i.toString()), child, files);
|
255
|
+
return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
|
256
256
|
} else if (child.type === "orderedList") {
|
257
|
-
return convertOrderedList(path.concat("children", i.toString()), child, files);
|
257
|
+
return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
|
258
258
|
} else {
|
259
259
|
var exhaustiveCheck = child;
|
260
260
|
throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
|
@@ -262,13 +262,13 @@ function convertListItem(path, child, files) {
|
|
262
262
|
})) || []
|
263
263
|
};
|
264
264
|
}
|
265
|
-
function convertBulletList(path, node, files) {
|
265
|
+
function convertBulletList(path, node, files, configDirectory) {
|
266
266
|
var _node$content2;
|
267
267
|
return {
|
268
268
|
tag: "ul",
|
269
269
|
children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
|
270
270
|
if (child.type === "listItem") {
|
271
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
271
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
272
272
|
} else {
|
273
273
|
var exhaustiveCheck = child.type;
|
274
274
|
throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
|
@@ -276,13 +276,13 @@ function convertBulletList(path, node, files) {
|
|
276
276
|
})) || []
|
277
277
|
};
|
278
278
|
}
|
279
|
-
function convertOrderedList(path, node, files) {
|
279
|
+
function convertOrderedList(path, node, files, configDirectory) {
|
280
280
|
var _node$content3;
|
281
281
|
return {
|
282
282
|
tag: "ol",
|
283
283
|
children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
|
284
284
|
if (child.type === "listItem") {
|
285
|
-
return convertListItem(path.concat("children", i.toString()), child, files);
|
285
|
+
return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
|
286
286
|
} else {
|
287
287
|
var exhaustiveCheck = child.type;
|
288
288
|
throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
|
@@ -291,7 +291,7 @@ function convertOrderedList(path, node, files) {
|
|
291
291
|
};
|
292
292
|
}
|
293
293
|
var textEncoder = new TextEncoder();
|
294
|
-
function convertImageNode(path, node, files) {
|
294
|
+
function convertImageNode(path, node, files, configDirectory) {
|
295
295
|
if (node.attrs && node.attrs.src.startsWith("data:")) {
|
296
296
|
var sha256 = Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
|
297
297
|
var mimeType = Internal.getMimeType(node.attrs.src);
|
@@ -303,7 +303,8 @@ function convertImageNode(path, node, files) {
|
|
303
303
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
304
304
|
mimeType: mimeType
|
305
305
|
}, sha256);
|
306
|
-
var
|
306
|
+
var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
|
307
|
+
var filePath = "".concat(dir).concat(fileName);
|
307
308
|
var existingFilesEntry = files[filePath];
|
308
309
|
var thisPath = path
|
309
310
|
// file is added as src (see below):
|
@@ -318,7 +319,7 @@ function convertImageNode(path, node, files) {
|
|
318
319
|
}
|
319
320
|
return {
|
320
321
|
tag: "img",
|
321
|
-
src: _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), "metadata", {
|
322
|
+
src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
322
323
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
323
324
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
324
325
|
mimeType: mimeType
|
@@ -343,7 +344,7 @@ function convertImageNode(path, node, files) {
|
|
343
344
|
}
|
344
345
|
var tag = {
|
345
346
|
tag: "img",
|
346
|
-
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, noParamsUrl), "metadata", {
|
347
|
+
src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, noParamsUrl), FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
|
347
348
|
width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
|
348
349
|
height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
|
349
350
|
mimeType: noParamsUrl && Internal.filenameToMimeType(noParamsUrl) || ""
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/shared",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.67.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Val shared types and utilities",
|
6
6
|
"scripts": {
|
@@ -29,8 +29,7 @@
|
|
29
29
|
"exports": true
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@valbuild/core": "~0.
|
33
|
-
"marked": "^9.0.3",
|
32
|
+
"@valbuild/core": "~0.67.0",
|
34
33
|
"zod": "^3.22.4",
|
35
34
|
"zod-validation-error": "^3.3.0"
|
36
35
|
},
|