@supernova-studio/client 0.9.2 → 0.9.3
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 +16 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/docs-editor/prosemirror-to-blocks.ts +20 -25
package/dist/index.js
CHANGED
|
@@ -7020,7 +7020,7 @@ function parseAsRichText(prosemirrorNode, definition, property) {
|
|
|
7020
7020
|
if (!id)
|
|
7021
7021
|
return null;
|
|
7022
7022
|
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
7023
|
-
const calloutType = parseCalloutType(getProsemirrorAttribute(prosemirrorNode, "type", _zod.z.string()));
|
|
7023
|
+
const calloutType = parseCalloutType(getProsemirrorAttribute(prosemirrorNode, "type", _zod.z.string().optional()));
|
|
7024
7024
|
return {
|
|
7025
7025
|
// TODO Artem: indent
|
|
7026
7026
|
id,
|
|
@@ -7118,8 +7118,8 @@ function parseRichTextAttribute(mark) {
|
|
|
7118
7118
|
case "code":
|
|
7119
7119
|
return { type: "Code" };
|
|
7120
7120
|
case "link":
|
|
7121
|
-
const itemId = getProsemirrorAttribute(mark, "itemId", _zod.z.string());
|
|
7122
|
-
const href = getProsemirrorAttribute(mark, "href", _zod.z.string());
|
|
7121
|
+
const itemId = getProsemirrorAttribute(mark, "itemId", _zod.z.string().optional());
|
|
7122
|
+
const href = getProsemirrorAttribute(mark, "href", _zod.z.string().optional());
|
|
7123
7123
|
return {
|
|
7124
7124
|
type: "Link",
|
|
7125
7125
|
openInNewWindow: _optionalChain([mark, 'access', _15 => _15.attrs, 'optionalAccess', _16 => _16.target]) !== "_self",
|
|
@@ -7134,7 +7134,7 @@ function parseAsTable(prosemirrorNode, definition, property) {
|
|
|
7134
7134
|
if (!id)
|
|
7135
7135
|
return null;
|
|
7136
7136
|
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
7137
|
-
const hasBorder = getProsemirrorAttribute(prosemirrorNode, "hasBorder", _zod.z.boolean()) !== false;
|
|
7137
|
+
const hasBorder = getProsemirrorAttribute(prosemirrorNode, "hasBorder", _zod.z.boolean().optional()) !== false;
|
|
7138
7138
|
const tableChild = _optionalChain([prosemirrorNode, 'access', _17 => _17.content, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((c) => c.type === "table")]);
|
|
7139
7139
|
if (!tableChild) {
|
|
7140
7140
|
return emptyTable(id, variantId, 0);
|
|
@@ -7179,9 +7179,9 @@ function parseAsTableCell(prosemirrorNode) {
|
|
|
7179
7179
|
const id = getProsemirrorBlockId(prosemirrorNode);
|
|
7180
7180
|
if (!id)
|
|
7181
7181
|
return null;
|
|
7182
|
-
const textAlign = getProsemirrorAttribute(prosemirrorNode, "textAlign", _zod.z.string());
|
|
7182
|
+
const textAlign = getProsemirrorAttribute(prosemirrorNode, "textAlign", _zod.z.string().optional());
|
|
7183
7183
|
let columnWidth;
|
|
7184
|
-
const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth", _zod.z.array(_zod.z.number()));
|
|
7184
|
+
const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth", _zod.z.array(_zod.z.number()).optional());
|
|
7185
7185
|
if (columnWidthArray) {
|
|
7186
7186
|
columnWidth = columnWidthArray[0];
|
|
7187
7187
|
}
|
|
@@ -7215,7 +7215,7 @@ function parseAsTableNode(prosemirrorNode) {
|
|
|
7215
7215
|
value: parseRichText(_nullishCoalesce(prosemirrorNode.content, () => ( [])))
|
|
7216
7216
|
};
|
|
7217
7217
|
case "image":
|
|
7218
|
-
const url = getProsemirrorAttribute(prosemirrorNode, "src", _zod.z.string());
|
|
7218
|
+
const url = getProsemirrorAttribute(prosemirrorNode, "src", _zod.z.string().optional());
|
|
7219
7219
|
if (!url)
|
|
7220
7220
|
return null;
|
|
7221
7221
|
return {
|
|
@@ -7278,9 +7278,9 @@ function parseAsEmbed(prosemirrorNode, definition, property) {
|
|
|
7278
7278
|
if (!id)
|
|
7279
7279
|
return null;
|
|
7280
7280
|
const variantId = getProsemirrorBlockVariantId(prosemirrorNode);
|
|
7281
|
-
const url = getProsemirrorAttribute(prosemirrorNode, "url", _zod.z.string());
|
|
7282
|
-
const caption = getProsemirrorAttribute(prosemirrorNode, "caption", _zod.z.string());
|
|
7283
|
-
const height = getProsemirrorAttribute(prosemirrorNode, "height", _zod.z.number());
|
|
7281
|
+
const url = getProsemirrorAttribute(prosemirrorNode, "url", _zod.z.string().optional());
|
|
7282
|
+
const caption = getProsemirrorAttribute(prosemirrorNode, "caption", _zod.z.string().optional());
|
|
7283
|
+
const height = getProsemirrorAttribute(prosemirrorNode, "height", _zod.z.number().optional());
|
|
7284
7284
|
return {
|
|
7285
7285
|
id,
|
|
7286
7286
|
data: {
|
|
@@ -7294,7 +7294,7 @@ function parseAsEmbed(prosemirrorNode, definition, property) {
|
|
|
7294
7294
|
[property.id]: {
|
|
7295
7295
|
value: url,
|
|
7296
7296
|
caption,
|
|
7297
|
-
height
|
|
7297
|
+
height: _nullishCoalesce(height, () => ( 200))
|
|
7298
7298
|
}
|
|
7299
7299
|
}
|
|
7300
7300
|
}
|
|
@@ -7350,11 +7350,11 @@ function parseBlockItems(prosemirrorNode, definition) {
|
|
|
7350
7350
|
}
|
|
7351
7351
|
function parseAppearance(prosemirrorNode) {
|
|
7352
7352
|
const appearance = {};
|
|
7353
|
-
const columns = getProsemirrorAttribute(prosemirrorNode, "columns", _zod.z.number());
|
|
7353
|
+
const columns = getProsemirrorAttribute(prosemirrorNode, "columns", _zod.z.number().optional());
|
|
7354
7354
|
if (columns) {
|
|
7355
7355
|
appearance.numberOfColumns = columns;
|
|
7356
7356
|
}
|
|
7357
|
-
const backgroundColor = getProsemirrorAttribute(prosemirrorNode, "backgroundColor", _zod.z.string());
|
|
7357
|
+
const backgroundColor = getProsemirrorAttribute(prosemirrorNode, "backgroundColor", _zod.z.string().optional());
|
|
7358
7358
|
if (backgroundColor) {
|
|
7359
7359
|
const parsedColor = ColorValue.safeParse(JSON.parse(backgroundColor));
|
|
7360
7360
|
if (parsedColor.success) {
|
|
@@ -7449,19 +7449,14 @@ function getProsemirrorBlockId(prosemirrorNode) {
|
|
|
7449
7449
|
return id;
|
|
7450
7450
|
}
|
|
7451
7451
|
function getProsemirrorBlockVariantId(prosemirrorNode) {
|
|
7452
|
-
return getProsemirrorAttribute(prosemirrorNode, "variantId", _zod.z.string());
|
|
7452
|
+
return getProsemirrorAttribute(prosemirrorNode, "variantId", nullishToOptional(_zod.z.string()));
|
|
7453
7453
|
}
|
|
7454
7454
|
function getProsemirrorAttribute(prosemirrorNode, attributeName, validationSchema) {
|
|
7455
|
-
const
|
|
7456
|
-
if (!attr) {
|
|
7457
|
-
console.warn(`Prosemirror attribute ${attributeName} on ${prosemirrorNode.type} was not defined`);
|
|
7458
|
-
return void 0;
|
|
7459
|
-
}
|
|
7460
|
-
const parsedAttr = validationSchema.safeParse(attr);
|
|
7455
|
+
const parsedAttr = validationSchema.safeParse(_optionalChain([prosemirrorNode, 'access', _36 => _36.attrs, 'optionalAccess', _37 => _37[attributeName]]));
|
|
7461
7456
|
if (parsedAttr.success) {
|
|
7462
7457
|
return parsedAttr.data;
|
|
7463
7458
|
} else {
|
|
7464
|
-
console.warn(`Prosemirror attribute ${attributeName} on ${prosemirrorNode.type} is
|
|
7459
|
+
console.warn(`Prosemirror attribute ${attributeName} on ${prosemirrorNode.type} is invalid`);
|
|
7465
7460
|
console.warn(parsedAttr.error.flatten());
|
|
7466
7461
|
return void 0;
|
|
7467
7462
|
}
|