markstream-angular 2.0.19 → 2.0.21
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.
|
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
|
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { Input, ChangeDetectionStrategy, Component, forwardRef, inject, ChangeDetectorRef, ViewChild, ViewContainerRef, ElementRef, Renderer2, Directive, HostListener, Injectable, InjectionToken, EventEmitter, Output } from '@angular/core';
|
|
5
5
|
import { normalizeCustomHtmlTags, normalizeCustomHtmlTagName, parseMarkdownToStructure, mergeCustomHtmlTags, getMarkdown, sanitizeHtmlAttrs, VOID_HTML_TAGS, BLOCKED_HTML_TAGS, isHtmlTagHardBlocked, isHtmlTagBlocked, isUnsafeHtmlUrl, shouldOpenLinkInNewTab, sanitizeImageSrc, NON_STRUCTURING_HTML_TAGS, toSafeMermaidSvgMarkup, getHtmlTagFromContent, stripCustomHtmlWrapper, STANDARD_HTML_TAGS, hasCompleteHtmlTagContent } from 'stream-markdown-parser';
|
|
6
|
-
import { createPanGesture, createSmoothMarkdownStream } from 'markstream-core';
|
|
6
|
+
import { createPanGesture, applyMermaidThemeDirective, createSmoothMarkdownStream } from 'markstream-core';
|
|
7
7
|
import { computePosition, offset, flip, shift, autoUpdate } from '@floating-ui/dom';
|
|
8
8
|
|
|
9
9
|
const TAG_TOKEN_RE = /<\/?([A-Z][\w:-]*)(?:\s[^<>]*)?>/gi;
|
|
@@ -7390,11 +7390,8 @@ class MermaidBlockNodeComponent {
|
|
|
7390
7390
|
return this.getSafePrefixCandidate(source);
|
|
7391
7391
|
}
|
|
7392
7392
|
applyThemeTo(source, theme) {
|
|
7393
|
-
const trimmed = source.trimStart();
|
|
7394
|
-
if (trimmed.startsWith('%%{'))
|
|
7395
|
-
return source;
|
|
7396
7393
|
const themeValue = theme === 'dark' ? 'dark' : 'default';
|
|
7397
|
-
return `%%{init: {"theme": "${themeValue}"}}%%\n
|
|
7394
|
+
return applyMermaidThemeDirective(source, `%%{init: {"theme": "${themeValue}"}}%%\n`);
|
|
7398
7395
|
}
|
|
7399
7396
|
getMermaidDiagramKind(source) {
|
|
7400
7397
|
for (const rawLine of source.split(/\r?\n/)) {
|
|
@@ -9302,11 +9299,8 @@ async function renderMermaid(root, cleanupFns, options, isActive) {
|
|
|
9302
9299
|
}
|
|
9303
9300
|
}
|
|
9304
9301
|
function applyMermaidThemeTo(source, theme) {
|
|
9305
|
-
const trimmed = source.trimStart();
|
|
9306
|
-
if (trimmed.startsWith('%%{'))
|
|
9307
|
-
return source;
|
|
9308
9302
|
const themeValue = theme === 'dark' ? 'dark' : 'default';
|
|
9309
|
-
return `%%{init: {"theme": "${themeValue}"}}%%\n
|
|
9303
|
+
return applyMermaidThemeDirective(source, `%%{init: {"theme": "${themeValue}"}}%%\n`);
|
|
9310
9304
|
}
|
|
9311
9305
|
async function canParseMermaidWithFallback(source, theme, mermaid, options) {
|
|
9312
9306
|
const workerTimeout = Number(options.mermaidProps?.workerTimeoutMs ?? 1400);
|
|
@@ -11210,6 +11204,8 @@ let DEBUG = false
|
|
|
11210
11204
|
let mermaid = null
|
|
11211
11205
|
let mermaidLoadError = null
|
|
11212
11206
|
|
|
11207
|
+
const applyMermaidThemeDirective = ${applyMermaidThemeDirective.toString()}
|
|
11208
|
+
|
|
11213
11209
|
function normalizeMermaidModule(mod) {
|
|
11214
11210
|
if (!mod)
|
|
11215
11211
|
return mod
|
|
@@ -11237,16 +11233,19 @@ function normalizeMermaidModule(mod) {
|
|
|
11237
11233
|
function applyThemeTo(code, theme) {
|
|
11238
11234
|
const themeValue = theme === 'dark' ? 'dark' : 'default'
|
|
11239
11235
|
const themeConfig = \`%%{init: {"theme": "\${themeValue}"}}%%\\n\`
|
|
11240
|
-
|
|
11241
|
-
if (trimmed.startsWith('%%{'))
|
|
11242
|
-
return code
|
|
11243
|
-
return themeConfig + code
|
|
11236
|
+
return applyMermaidThemeDirective(code || '', themeConfig)
|
|
11244
11237
|
}
|
|
11245
11238
|
|
|
11246
11239
|
function findHeaderIndex(lines) {
|
|
11247
11240
|
const headerRe = /^(?:graph|flowchart|flowchart\\s+tb|flowchart\\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\\b/
|
|
11241
|
+
let inFrontmatter = lines[0]?.trimEnd() === '---'
|
|
11248
11242
|
for (let i = 0; i < lines.length; i++) {
|
|
11249
11243
|
const line = (lines[i] || '').trim()
|
|
11244
|
+
if (inFrontmatter) {
|
|
11245
|
+
if (i > 0 && lines[i].trimEnd() === '---')
|
|
11246
|
+
inFrontmatter = false
|
|
11247
|
+
continue
|
|
11248
|
+
}
|
|
11250
11249
|
if (!line || line.startsWith('%%'))
|
|
11251
11250
|
continue
|
|
11252
11251
|
if (headerRe.test(line))
|
|
@@ -11265,7 +11264,7 @@ async function canParse(code, theme) {
|
|
|
11265
11264
|
}
|
|
11266
11265
|
|
|
11267
11266
|
async function findLastRenderablePrefix(baseCode, theme) {
|
|
11268
|
-
const lines = String(baseCode || '').split(
|
|
11267
|
+
const lines = String(baseCode || '').split(/\\r\\n?|\\n/)
|
|
11269
11268
|
const headerIndex = findHeaderIndex(lines)
|
|
11270
11269
|
if (headerIndex === -1)
|
|
11271
11270
|
return null
|