@bendyline/squisq 1.5.1 → 1.5.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/dist/{chunk-LH7I6SH7.js → chunk-5TYS5V3G.js} +91 -43
- package/dist/chunk-5TYS5V3G.js.map +1 -0
- package/dist/{chunk-TEEEILMP.js → chunk-BEQODJWV.js} +9 -2
- package/dist/chunk-BEQODJWV.js.map +1 -0
- package/dist/{chunk-6ATE2PSM.js → chunk-GPLTCSXO.js} +2 -2
- package/dist/{chunk-RUDYOTA6.js → chunk-LTN6I7QW.js} +56 -1
- package/dist/chunk-LTN6I7QW.js.map +1 -0
- package/dist/{chunk-2OIBZYKP.js → chunk-P3K7NLHF.js} +2 -2
- package/dist/doc/index.d.ts +1 -1
- package/dist/doc/index.js +10 -4
- package/dist/imageEdit/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -6
- package/dist/markdown/index.js +2 -2
- package/dist/story/index.d.ts +27 -3
- package/dist/story/index.js +10 -4
- package/package.json +1 -1
- package/src/__tests__/coverBlock.test.ts +33 -2
- package/src/__tests__/markdownToDoc.test.ts +5 -2
- package/src/__tests__/shapeGeometry.test.ts +37 -0
- package/src/doc/docToMarkdown.ts +56 -37
- package/src/doc/templates/coverBlock.ts +49 -13
- package/src/doc/templates/diagramBlock.ts +2 -2
- package/src/doc/templates/drawingBlock.ts +2 -2
- package/src/doc/utils/shapeGeometry.ts +90 -2
- package/src/markdown/convert.ts +11 -1
- package/dist/chunk-LH7I6SH7.js.map +0 -1
- package/dist/chunk-RUDYOTA6.js.map +0 -1
- package/dist/chunk-TEEEILMP.js.map +0 -1
- /package/dist/{chunk-6ATE2PSM.js.map → chunk-GPLTCSXO.js.map} +0 -0
- /package/dist/{chunk-2OIBZYKP.js.map → chunk-P3K7NLHF.js.map} +0 -0
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
hashString
|
|
8
8
|
} from "./chunk-FVTQSNR7.js";
|
|
9
9
|
import {
|
|
10
|
-
clipEndpoints,
|
|
11
10
|
connectorPath,
|
|
12
11
|
lineStyleDasharray,
|
|
13
|
-
shapePath
|
|
14
|
-
|
|
12
|
+
shapePath,
|
|
13
|
+
snapEndpoints
|
|
14
|
+
} from "./chunk-LTN6I7QW.js";
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_THEME,
|
|
17
17
|
FRONTMATTER_CUSTOM_TEMPLATES_KEY,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
serializeAnnotation,
|
|
44
44
|
splitKeyValueToken,
|
|
45
45
|
tokenizeAttrTokens
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-BEQODJWV.js";
|
|
47
47
|
import {
|
|
48
48
|
extractPlainText,
|
|
49
49
|
getChildren,
|
|
@@ -3672,7 +3672,7 @@ function diagramBlock(input, context) {
|
|
|
3672
3672
|
const a = positions.get(edge.source);
|
|
3673
3673
|
const b = positions.get(edge.target);
|
|
3674
3674
|
if (!a || !b) continue;
|
|
3675
|
-
const { start, end } =
|
|
3675
|
+
const { start, end } = snapEndpoints(a, b);
|
|
3676
3676
|
const pathLayer = {
|
|
3677
3677
|
type: "path",
|
|
3678
3678
|
id: `edge-${edge.id}`,
|
|
@@ -4108,7 +4108,7 @@ function drawingBlock(input, context) {
|
|
|
4108
4108
|
const a = boxes.get(conn.from);
|
|
4109
4109
|
const b = boxes.get(conn.to);
|
|
4110
4110
|
if (!a || !b) continue;
|
|
4111
|
-
const { start, end } =
|
|
4111
|
+
const { start, end } = snapEndpoints(a, b);
|
|
4112
4112
|
const path = {
|
|
4113
4113
|
type: "path",
|
|
4114
4114
|
id: `connector-${conn.id}`,
|
|
@@ -4472,10 +4472,15 @@ function fitCoverTitleSize(title) {
|
|
|
4472
4472
|
const scaled = COVER_TITLE_BASE_PX * Math.sqrt(COVER_TITLE_COMFORTABLE_CHARS / len);
|
|
4473
4473
|
return Math.max(COVER_TITLE_MIN_BASE_PX, Math.round(scaled));
|
|
4474
4474
|
}
|
|
4475
|
+
function isStandardLightCover(context) {
|
|
4476
|
+
const { theme } = context;
|
|
4477
|
+
return theme.id === "standard" && relativeLuminance(theme.colors.background) > 0.85;
|
|
4478
|
+
}
|
|
4475
4479
|
function coverBlock(input, context) {
|
|
4476
4480
|
const treatment = themedImageTreatment(context, input.imageTreatment);
|
|
4477
4481
|
const { heroSrc, heroAlt, title, subtitle, ambientMotion, heroCredit, heroLicense } = input;
|
|
4478
4482
|
const { theme, layout } = context;
|
|
4483
|
+
const standardLightCover = !heroSrc && isStandardLightCover(context);
|
|
4479
4484
|
const titleFontSize = themedFontSize(fitCoverTitleSize(title), context, true);
|
|
4480
4485
|
const subtitleFontSize = themedFontSize(40, context, false);
|
|
4481
4486
|
const layers = [];
|
|
@@ -4507,21 +4512,44 @@ function coverBlock(input, context) {
|
|
|
4507
4512
|
}
|
|
4508
4513
|
);
|
|
4509
4514
|
} else {
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4515
|
+
if (standardLightCover) {
|
|
4516
|
+
layers.push(
|
|
4517
|
+
{
|
|
4518
|
+
type: "shape",
|
|
4519
|
+
id: "cover-bg",
|
|
4520
|
+
content: {
|
|
4521
|
+
shape: "rect",
|
|
4522
|
+
fill: theme.colors.background
|
|
4523
|
+
},
|
|
4524
|
+
position: { x: 0, y: 0, width: "100%", height: "100%" }
|
|
4525
|
+
},
|
|
4526
|
+
{
|
|
4527
|
+
type: "shape",
|
|
4528
|
+
id: "cover-bg-tint",
|
|
4529
|
+
content: {
|
|
4530
|
+
shape: "rect",
|
|
4531
|
+
fill: `radial-gradient(ellipse at 50% 40%, ${withAlpha(theme.colors.primary, 0.16)} 0%, ${withAlpha(theme.colors.primary, 0.07)} 38%, ${withAlpha(theme.colors.primary, 0)} 78%)`
|
|
4532
|
+
},
|
|
4533
|
+
position: { x: 0, y: 0, width: "100%", height: "100%" }
|
|
4534
|
+
}
|
|
4535
|
+
);
|
|
4536
|
+
} else {
|
|
4537
|
+
layers.push({
|
|
4538
|
+
type: "shape",
|
|
4539
|
+
id: "cover-bg",
|
|
4540
|
+
content: {
|
|
4541
|
+
shape: "rect",
|
|
4542
|
+
fill: `radial-gradient(ellipse at 50% 40%, ${theme.colors.primary} 0%, ${theme.colors.background} 100%)`
|
|
4543
|
+
},
|
|
4544
|
+
position: { x: 0, y: 0, width: "100%", height: "100%" }
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4519
4547
|
layers.push({
|
|
4520
4548
|
type: "shape",
|
|
4521
4549
|
id: "cover-accent",
|
|
4522
4550
|
content: {
|
|
4523
4551
|
shape: "rect",
|
|
4524
|
-
fill: "rgba(255, 255, 255, 0.2)"
|
|
4552
|
+
fill: standardLightCover ? withAlpha(theme.colors.primary, 0.24) : "rgba(255, 255, 255, 0.2)"
|
|
4525
4553
|
},
|
|
4526
4554
|
position: {
|
|
4527
4555
|
x: "35%",
|
|
@@ -4542,7 +4570,7 @@ function coverBlock(input, context) {
|
|
|
4542
4570
|
fontWeight: "bold",
|
|
4543
4571
|
color: theme.colors.text,
|
|
4544
4572
|
textAlign: "center",
|
|
4545
|
-
shadow:
|
|
4573
|
+
shadow: !standardLightCover
|
|
4546
4574
|
}
|
|
4547
4575
|
},
|
|
4548
4576
|
position: {
|
|
@@ -4563,7 +4591,8 @@ function coverBlock(input, context) {
|
|
|
4563
4591
|
style: {
|
|
4564
4592
|
fontSize: subtitleFontSize,
|
|
4565
4593
|
fontFamily: getThemeFont(context, "body"),
|
|
4566
|
-
|
|
4594
|
+
fontWeight: standardLightCover ? "bold" : "normal",
|
|
4595
|
+
color: standardLightCover ? withAlpha(theme.colors.text, 0.78) : theme.colors.textMuted,
|
|
4567
4596
|
textAlign: "center",
|
|
4568
4597
|
lineHeight: 1.5
|
|
4569
4598
|
}
|
|
@@ -6331,6 +6360,7 @@ function buildStartBlock(markdownDoc, rootBlocks) {
|
|
|
6331
6360
|
}
|
|
6332
6361
|
|
|
6333
6362
|
// src/doc/docToMarkdown.ts
|
|
6363
|
+
var TRANSITION_PARAM_KEYS = ["transition", "transitionDuration", "transitionDirection"];
|
|
6334
6364
|
function docToMarkdown(doc) {
|
|
6335
6365
|
const children = [];
|
|
6336
6366
|
function emitBlock(block) {
|
|
@@ -6380,42 +6410,60 @@ function synthesizeAnnotationParagraph(block) {
|
|
|
6380
6410
|
return { type: "paragraph", children: [{ type: "text", value: text }] };
|
|
6381
6411
|
}
|
|
6382
6412
|
function ensureAnnotation(block, heading) {
|
|
6383
|
-
const
|
|
6413
|
+
const { attributes, transitionParams } = ensureTransitionMetadata(block, heading);
|
|
6384
6414
|
const hasExplicitTemplate = block.template && block.template !== "sectionHeader" && block.autoTemplate !== true;
|
|
6385
6415
|
const hasOverrides = block.templateOverrides && Object.keys(block.templateOverrides).length > 0;
|
|
6386
|
-
|
|
6387
|
-
|
|
6416
|
+
let templateAnnotation = heading.templateAnnotation;
|
|
6417
|
+
if (!templateAnnotation && (hasExplicitTemplate || hasOverrides || transitionParams)) {
|
|
6418
|
+
templateAnnotation = {
|
|
6419
|
+
...hasExplicitTemplate ? { template: block.template ?? "sectionHeader" } : {},
|
|
6420
|
+
...hasOverrides ? { params: block.templateOverrides } : {}
|
|
6421
|
+
};
|
|
6388
6422
|
}
|
|
6389
|
-
if (
|
|
6390
|
-
|
|
6423
|
+
if (transitionParams) {
|
|
6424
|
+
templateAnnotation = {
|
|
6425
|
+
...templateAnnotation ?? {},
|
|
6426
|
+
params: {
|
|
6427
|
+
...templateAnnotation?.params ?? {},
|
|
6428
|
+
...transitionParams
|
|
6429
|
+
}
|
|
6430
|
+
};
|
|
6391
6431
|
}
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
templateAnnotation: {
|
|
6397
|
-
template: block.template ?? "sectionHeader",
|
|
6398
|
-
...hasOverrides ? { params: block.templateOverrides } : {}
|
|
6399
|
-
}
|
|
6400
|
-
};
|
|
6432
|
+
if (attributes === heading.attributes && templateAnnotation === heading.templateAnnotation) {
|
|
6433
|
+
return heading;
|
|
6434
|
+
}
|
|
6435
|
+
return { ...heading, children: [...heading.children], attributes, templateAnnotation };
|
|
6401
6436
|
}
|
|
6402
|
-
function
|
|
6437
|
+
function ensureTransitionMetadata(block, heading) {
|
|
6403
6438
|
const transition = block.transition;
|
|
6404
|
-
if (!transition)
|
|
6405
|
-
|
|
6406
|
-
|
|
6439
|
+
if (!transition) {
|
|
6440
|
+
return { attributes: heading.attributes, transitionParams: void 0 };
|
|
6441
|
+
}
|
|
6442
|
+
const attrs = removeTransitionParams(heading.attributes) ?? {};
|
|
6443
|
+
const attributes = {
|
|
6407
6444
|
...attrs,
|
|
6408
|
-
params: {
|
|
6409
|
-
...attrs.params ?? {},
|
|
6410
|
-
transition: transition.type,
|
|
6411
|
-
...transition.duration !== void 0 ? { transitionDuration: String(transition.duration) } : {},
|
|
6412
|
-
...transition.direction ? { transitionDirection: transition.direction } : {}
|
|
6413
|
-
},
|
|
6414
6445
|
blockMeta: {
|
|
6415
6446
|
...attrs.blockMeta ?? {},
|
|
6416
6447
|
transition
|
|
6417
6448
|
}
|
|
6418
6449
|
};
|
|
6450
|
+
return {
|
|
6451
|
+
attributes,
|
|
6452
|
+
transitionParams: {
|
|
6453
|
+
transition: transition.type,
|
|
6454
|
+
...transition.duration !== void 0 ? { transitionDuration: String(transition.duration) } : {},
|
|
6455
|
+
...transition.direction ? { transitionDirection: transition.direction } : {}
|
|
6456
|
+
}
|
|
6457
|
+
};
|
|
6458
|
+
}
|
|
6459
|
+
function removeTransitionParams(attrs) {
|
|
6460
|
+
if (!attrs?.params) return attrs;
|
|
6461
|
+
const params = { ...attrs.params };
|
|
6462
|
+
for (const key of TRANSITION_PARAM_KEYS) delete params[key];
|
|
6463
|
+
return {
|
|
6464
|
+
...attrs,
|
|
6465
|
+
...Object.keys(params).length > 0 ? { params } : { params: void 0 }
|
|
6466
|
+
};
|
|
6419
6467
|
}
|
|
6420
6468
|
|
|
6421
6469
|
// src/doc/resolveDocTheme.ts
|
|
@@ -7205,4 +7253,4 @@ export {
|
|
|
7205
7253
|
validateMarkdownSource,
|
|
7206
7254
|
validateMarkdownDoc
|
|
7207
7255
|
};
|
|
7208
|
-
//# sourceMappingURL=chunk-
|
|
7256
|
+
//# sourceMappingURL=chunk-5TYS5V3G.js.map
|