rapier-markdown-kit 1.1.75 → 1.1.78
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.
|
@@ -105,6 +105,10 @@ function _rapierValidLedgerRecord(record, prior, earlier, documentAuthority, max
|
|
|
105
105
|
const transaction = record.transaction;
|
|
106
106
|
const nullableText = (value, limit, empty = true) => value === null ||
|
|
107
107
|
(typeof value === 'string' && value.length <= limit && (empty || value.length > 0));
|
|
108
|
+
// A grouped agent contribution's optional fields, bounded like the identities beside them: a name of 1 to 120 characters, a
|
|
109
|
+
// revision, at most 500 source identities (the journal the kernel retains) of 1 to 160, and a hosted row's identity of 1 to 256.
|
|
110
|
+
const optional = (value, valid) => value === undefined || valid(value);
|
|
111
|
+
const identity = (value, limit) => typeof value === 'string' && value.length > 0 && value.length <= limit;
|
|
108
112
|
if (!transaction || typeof transaction.id !== 'string' || !transaction.id.length ||
|
|
109
113
|
transaction.id.length > 256 || !Array.isArray(earlier) ||
|
|
110
114
|
earlier.some(row => row?.transaction?.id === transaction.id) ||
|
|
@@ -115,6 +119,11 @@ function _rapierValidLedgerRecord(record, prior, earlier, documentAuthority, max
|
|
|
115
119
|
transaction.operation.length > _RAPIER_TRANSACTION_OPERATION_LIMIT ||
|
|
116
120
|
!nullableText(transaction.requestId, _RAPIER_TRANSACTION_REQUEST_LIMIT) ||
|
|
117
121
|
!nullableText(transaction.sourceTransactionId, _RAPIER_TRANSACTION_REQUEST_LIMIT) ||
|
|
122
|
+
!optional(transaction.contribution, value => identity(value, 120)) ||
|
|
123
|
+
!optional(transaction.contributionBaseRevision, value => Number.isSafeInteger(value) && value >= 0 && !Object.is(value, -0)) ||
|
|
124
|
+
!optional(transaction.sourceTransactionIds, value => Array.isArray(value) && value.length <= 500 &&
|
|
125
|
+
value.every(id => identity(id, _RAPIER_TRANSACTION_REQUEST_LIMIT))) ||
|
|
126
|
+
!optional(transaction.remoteTransactionId, value => identity(value, 256)) ||
|
|
118
127
|
!nullableText(transaction.parent, 256, false) ||
|
|
119
128
|
!nullableText(transaction.reverts, 256, false) ||
|
|
120
129
|
!nullableText(transaction.reapplies, 256, false) ||
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const RAPIER_TABLE_CAPTION_PREFIX_RE = /^(?:Table:|:) /;
|
|
3
3
|
// The document's renderer. DOM, codecs and host state are explicit inputs.
|
|
4
4
|
function createMarkdownRenderer(runtime) {
|
|
5
|
-
const {RAPIER_HIGHLIGHT_COLOR_BY_MARKER, RAPIER_MARKDOWN_SPEC, RAPIER_RENDERED_HEADING_SELECTOR, _rapierApplyMarkdownSpec, _rapierBidiStrong, _rapierChromeOwnsId, _rapierCodeHtml, _rapierDeriveDarkColor, _rapierDormantHeadings, _rapierEmbedAssetSource, _rapierHeadingSlugBase, _rapierHighlightAdmitted, _rapierInstallMarkdownMath, _rapierMarkdownPreview, _rapierPlainLayout, _rapierProviders, _rapierRemoteContent, _rapierRemoteImagePlaceholder, _rapierRemoteSubresourceOrigin, _rapierRenderedAnchorOriginalIds, _rapierSourceCharEscaped, _rapierSplitOpeningFrontmatter, _rapierUiDiagram, _rapierUiMath, document, escapeRapierHtmlText, globalThis, sanitizeRapierHtml, window} = runtime;
|
|
5
|
+
const {RAPIER_HIGHLIGHT_COLOR_BY_MARKER, RAPIER_MARKDOWN_SPEC, RAPIER_RENDERED_HEADING_SELECTOR, _rapierApplyMarkdownSpec, _rapierBidiStrong, _rapierChromeOwnsId, _rapierCodeHtml, _rapierDeriveDarkColor, _rapierDormantHeadings, _rapierEmbedAssetSource, _rapierHeadingSlugBase, _rapierNextHeadingSlug, _rapierHighlightAdmitted, _rapierInstallMarkdownMath, _rapierMarkdownPreview, _rapierPlainLayout, _rapierProviders, _rapierRemoteContent, _rapierRemoteImagePlaceholder, _rapierRemoteSubresourceOrigin, _rapierRenderedAnchorOriginalIds, _rapierSourceCharEscaped, _rapierSplitOpeningFrontmatter, _rapierUiDiagram, _rapierUiMath, document, escapeRapierHtmlText, globalThis, sanitizeRapierHtml, window} = runtime;
|
|
6
6
|
let md = runtime.md;
|
|
7
7
|
function initMarkdownIt() {
|
|
8
8
|
if (typeof window.markdownit !== 'function') throw new Error('markdownit');
|
|
@@ -596,18 +596,10 @@ function _rapierAssignHeadingSlugs(root, selector = RAPIER_RENDERED_HEADING_SELE
|
|
|
596
596
|
const headings = Array.from(root.querySelectorAll(selector)).concat(_rapierDormantHeadings(root, selector));
|
|
597
597
|
const headingSet = new Set(headings);
|
|
598
598
|
if (reserveExisting) (root.isConnected ? document : root).querySelectorAll('[id]').forEach(element => {
|
|
599
|
-
if (!headingSet.has(element) && element.id) used[element.id] =
|
|
599
|
+
if (!headingSet.has(element) && element.id) used[element.id] = 0;
|
|
600
600
|
});
|
|
601
601
|
headings.forEach(heading => {
|
|
602
|
-
|
|
603
|
-
let slug = base;
|
|
604
|
-
if (used[slug]) {
|
|
605
|
-
let ordinal = used[base];
|
|
606
|
-
do { slug = base + '-' + (++ordinal); } while (used[slug]);
|
|
607
|
-
used[base] = ordinal;
|
|
608
|
-
}
|
|
609
|
-
used[slug] = 1;
|
|
610
|
-
heading.id = slug;
|
|
602
|
+
heading.id = _rapierNextHeadingSlug(_rapierHeadingSlugBase(heading.textContent), used);
|
|
611
603
|
});
|
|
612
604
|
}
|
|
613
605
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-markdown-kit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.78",
|
|
4
4
|
"description": "Read, render, write and style Self-contained Markdown, and carry its optional edit ledger: the shared HTML writer, semantic renderer, stylesheet, layout, marks, pictures, Will/1, replay, authorship and offline merge. MIT, no npm dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
package/style.css
CHANGED
|
@@ -362,7 +362,8 @@
|
|
|
362
362
|
/* The line model (the way a Word document reads). One line, --md-line, is the body's line box: 1.75rem, 1.6 lines
|
|
363
363
|
of the 1.1rem body, a whole 28 px at the browser's 16 px root so baselines land on pixels. Every block ends one
|
|
364
364
|
line below its last line; a heading ends half a line below. A heading's own box is the whole or half lines its
|
|
365
|
-
size fills: h1 at 2.
|
|
365
|
+
size fills: h1 at 2.43 x the body on two lines (medium weight, lighter than the bold smaller headings), h2 and h3
|
|
366
|
+
on one and a half, h4 to h6 on one. Nothing sets a top
|
|
366
367
|
margin, so a plain page (sibling margins collapsing) and the editor (a wrapper per block) space alike, and the
|
|
367
368
|
space before any block is the line its predecessor leaves. */
|
|
368
369
|
.md-render{
|
|
@@ -373,7 +374,7 @@
|
|
|
373
374
|
.md-render h1,.md-render h2,.md-render h3,.md-render h4,.md-render h5,.md-render h6{
|
|
374
375
|
font-family:var(--md-font-sans);letter-spacing:-0.01em;
|
|
375
376
|
line-height:var(--md-line);margin:0 0 calc(var(--md-line) / 2);color:var(--md-heading-color);text-wrap:balance}
|
|
376
|
-
.md-render h1{font-size:calc(var(--md-text-body) * 2.
|
|
377
|
+
.md-render h1{font-size:calc(var(--md-text-body) * 2.43);line-height:calc(var(--md-line) * 2);font-weight:500}
|
|
377
378
|
.md-render h2{font-size:calc(var(--md-text-body) * 1.9);line-height:calc(var(--md-line) * 1.5);font-weight:600}
|
|
378
379
|
.md-render h3{font-size:calc(var(--md-text-body) * 1.5);line-height:calc(var(--md-line) * 1.5);font-weight:600}
|
|
379
380
|
.md-render h4{font-size:calc(var(--md-text-body) * 1.25);font-weight:500}
|