blixify-ui-web 1.2.126 → 1.2.127

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.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * A document's headings — the outline a reader navigates by.
3
+ *
4
+ * INFO: read from the markdown, not from the rendered DOM. The editor and the
5
+ * static renderer draw a heading through completely different paths (tiptap
6
+ * nodes vs markdown-it html), and an outline built from either one would only
7
+ * be correct in that one. The markdown is the single thing they agree on, so it
8
+ * is what the outline is derived from and what both of them are then labelled
9
+ * against.
10
+ *
11
+ * INFO: no id is ever written INTO the markdown. Ids are slugs computed from
12
+ * the heading text every time, so a note saved before this existed gets an
13
+ * outline with no migration, and adding one changes no stored byte — the same
14
+ * commitment the embed's `data-view` makes by omitting itself for the default.
15
+ */
16
+ export interface MarkdownHeading {
17
+ /** Slug of the heading text, unique within the document */
18
+ id: string;
19
+ /** 1, 2 or 3 — deeper headings are not offered as navigation */
20
+ level: number;
21
+ text: string;
22
+ }
23
+ export declare const MAX_OUTLINE_LEVEL = 3;
24
+ /**
25
+ * INFO: a document with one or two headings is not navigated, it is read. The
26
+ * rail would cost a column of width to say what the first screen already shows.
27
+ */
28
+ export declare const MIN_OUTLINE_HEADINGS = 3;
29
+ /**
30
+ * The anchor id for a heading's text.
31
+ *
32
+ * INFO: exported because both renderers have to arrive at the same id from the
33
+ * same text without talking to each other — that identity is the whole
34
+ * mechanism, so it lives in one function rather than being spelled twice.
35
+ */
36
+ export declare const handleSlugHeading: (text: string) => string;
37
+ /**
38
+ * Makes a slug unique within one document by suffixing repeats.
39
+ *
40
+ * INFO: two "Overview" headings are ordinary in a long page. Without this they
41
+ * share an id, and every click on the second one jumps to the first.
42
+ */
43
+ export declare const handleDedupeSlug: (slug: string, seen: Map<string, number>) => string;
44
+ /**
45
+ * Reads the outline out of a markdown document.
46
+ *
47
+ * INFO: fenced blocks are tracked and skipped, because a `# comment` inside a
48
+ * ```bash block and a `%% title` inside a ```mermaid one are code, not
49
+ * structure — a diagram-heavy page would otherwise produce an outline of its
50
+ * own source. The closing fence must be at least as long as the opening one,
51
+ * which is how a ``` block nested inside a ```` one stays inside it.
52
+ */
53
+ export declare const handleParseMarkdownHeadings: (markdown?: string | null) => MarkdownHeading[];
54
+ /**
55
+ * Writes the outline's ids into rendered html, in document order.
56
+ *
57
+ * INFO: into the HTML STRING, not onto the mounted DOM. The static renderer sets
58
+ * its html through dangerouslySetInnerHTML, and React re-commits that html
59
+ * whenever it re-renders the element — which wipes every attribute added
60
+ * afterwards. Ids set from an effect therefore survived until the first
61
+ * re-render and then vanished silently, leaving an outline whose entries no
62
+ * longer scrolled anywhere. Being part of the html itself, these cannot be lost.
63
+ *
64
+ * INFO: the heading order is the only thing tying the two together, and it is
65
+ * reliable because both come from one parse of one document — the nth `<h1-3>`
66
+ * in the html is the nth entry in the outline. Levels deeper than the outline
67
+ * carry no id, which is why the pattern stops at h3.
68
+ */
69
+ export declare const handleInjectHeadingIds: (html: string, headings: MarkdownHeading[]) => string;
70
+ /**
71
+ * The id a heading node carries in the editor, as a ProseMirror decoration.
72
+ *
73
+ * INFO: a decoration rather than a node attribute or a DOM write. An attribute
74
+ * would reach `getHTML()` — turndown's input — and be written into the saved
75
+ * markdown; a DOM write is undone the next time ProseMirror redraws that node.
76
+ * Decorations are recomputed from the document on every redraw by construction,
77
+ * so an anchor cannot drift out of the view or into the file.
78
+ */
79
+ export declare const handleBuildHeadingAnchors: (doc: any) => {
80
+ from: number;
81
+ to: number;
82
+ id: string;
83
+ }[];
84
+ //# sourceMappingURL=headings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headings.d.ts","sourceRoot":"","sources":["../../../../src/components/input/markdown/headings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAsBtC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,MAgBhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SACrB,MAAM,QACN,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KACxB,MAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,cAC3B,MAAM,GAAG,IAAI,KACvB,eAAe,EAqCjB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,SAC3B,MAAM,YACF,eAAe,EAAE,KAC1B,MASF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,QAC/B,GAAG,KACP;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAgB1C,CAAC"}
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ /**
3
+ * A document's headings — the outline a reader navigates by.
4
+ *
5
+ * INFO: read from the markdown, not from the rendered DOM. The editor and the
6
+ * static renderer draw a heading through completely different paths (tiptap
7
+ * nodes vs markdown-it html), and an outline built from either one would only
8
+ * be correct in that one. The markdown is the single thing they agree on, so it
9
+ * is what the outline is derived from and what both of them are then labelled
10
+ * against.
11
+ *
12
+ * INFO: no id is ever written INTO the markdown. Ids are slugs computed from
13
+ * the heading text every time, so a note saved before this existed gets an
14
+ * outline with no migration, and adding one changes no stored byte — the same
15
+ * commitment the embed's `data-view` makes by omitting itself for the default.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.handleBuildHeadingAnchors = exports.handleInjectHeadingIds = exports.handleParseMarkdownHeadings = exports.handleDedupeSlug = exports.handleSlugHeading = exports.MIN_OUTLINE_HEADINGS = exports.MAX_OUTLINE_LEVEL = void 0;
19
+ exports.MAX_OUTLINE_LEVEL = 3;
20
+ /**
21
+ * INFO: a document with one or two headings is not navigated, it is read. The
22
+ * rail would cost a column of width to say what the first screen already shows.
23
+ */
24
+ exports.MIN_OUTLINE_HEADINGS = 3;
25
+ var FENCE = /^\s{0,3}(`{3,}|~{3,})/;
26
+ var HEADING = /^(#{1,6})\s+(.*)$/;
27
+ /**
28
+ * Strips the inline markup a heading may carry, so the outline shows the words
29
+ * rather than the syntax around them.
30
+ */
31
+ var handleCleanHeadingText = function (raw) {
32
+ return raw
33
+ // INFO: trailing #s of a closed atx heading — "## Title ##"
34
+ .replace(/\s+#+\s*$/, "")
35
+ // INFO: link and image syntax reduced to the text that was visible
36
+ .replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1")
37
+ .replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
38
+ .replace(/`([^`]*)`/g, "$1")
39
+ .replace(/[*_~]/g, "")
40
+ .replace(/<[^>]+>/g, "")
41
+ .replace(/\s+/g, " ")
42
+ .trim();
43
+ };
44
+ /**
45
+ * The anchor id for a heading's text.
46
+ *
47
+ * INFO: exported because both renderers have to arrive at the same id from the
48
+ * same text without talking to each other — that identity is the whole
49
+ * mechanism, so it lives in one function rather than being spelled twice.
50
+ */
51
+ var handleSlugHeading = function (text) {
52
+ var slug = handleCleanHeadingText(text)
53
+ .toLowerCase()
54
+ // INFO: punctuation is REMOVED rather than letters being kept. A
55
+ // `\p{L}`-style whitelist needs the unicode flag, which this library cannot
56
+ // use at an es5 target — and matching `[a-z0-9]` instead would slug a
57
+ // heading in Chinese or Malay to an empty string. Full-width punctuation is
58
+ // listed too, since it is what a CJK heading actually carries.
59
+ .replace(/["'’“”!?@#$%^&*()+=[\]{}<>,.:;/\\|`~]/g, "")
60
+ .replace(/[,。!?:;()【】、「」…]/g, "")
61
+ .replace(/\s+/g, "-")
62
+ .replace(/-+/g, "-")
63
+ .replace(/^-|-$/g, "");
64
+ // INFO: a heading of only punctuation would otherwise slug to "" and every
65
+ // such heading would share one id
66
+ return slug || "section";
67
+ };
68
+ exports.handleSlugHeading = handleSlugHeading;
69
+ /**
70
+ * Makes a slug unique within one document by suffixing repeats.
71
+ *
72
+ * INFO: two "Overview" headings are ordinary in a long page. Without this they
73
+ * share an id, and every click on the second one jumps to the first.
74
+ */
75
+ var handleDedupeSlug = function (slug, seen) {
76
+ var _a;
77
+ var count = (_a = seen.get(slug)) !== null && _a !== void 0 ? _a : 0;
78
+ seen.set(slug, count + 1);
79
+ return count === 0 ? slug : "".concat(slug, "-").concat(count + 1);
80
+ };
81
+ exports.handleDedupeSlug = handleDedupeSlug;
82
+ /**
83
+ * Reads the outline out of a markdown document.
84
+ *
85
+ * INFO: fenced blocks are tracked and skipped, because a `# comment` inside a
86
+ * ```bash block and a `%% title` inside a ```mermaid one are code, not
87
+ * structure — a diagram-heavy page would otherwise produce an outline of its
88
+ * own source. The closing fence must be at least as long as the opening one,
89
+ * which is how a ``` block nested inside a ```` one stays inside it.
90
+ */
91
+ var handleParseMarkdownHeadings = function (markdown) {
92
+ if (!markdown)
93
+ return [];
94
+ var headings = [];
95
+ var seen = new Map();
96
+ var fence = "";
97
+ for (var _i = 0, _a = markdown.split("\n"); _i < _a.length; _i++) {
98
+ var eachLine = _a[_i];
99
+ var fenceMatch = eachLine.match(FENCE);
100
+ if (fenceMatch) {
101
+ var marker = fenceMatch[1];
102
+ if (!fence) {
103
+ fence = marker;
104
+ continue;
105
+ }
106
+ // INFO: only a fence of the same character and at least the same length
107
+ // closes the block
108
+ if (marker[0] === fence[0] && marker.length >= fence.length)
109
+ fence = "";
110
+ continue;
111
+ }
112
+ if (fence)
113
+ continue;
114
+ var headingMatch = eachLine.match(HEADING);
115
+ if (!headingMatch)
116
+ continue;
117
+ var level = headingMatch[1].length;
118
+ if (level > exports.MAX_OUTLINE_LEVEL)
119
+ continue;
120
+ var text = handleCleanHeadingText(headingMatch[2]);
121
+ // INFO: "###" with nothing after it is not a section anyone can navigate to
122
+ if (!text)
123
+ continue;
124
+ headings.push({
125
+ id: (0, exports.handleDedupeSlug)((0, exports.handleSlugHeading)(text), seen),
126
+ level: level,
127
+ text: text,
128
+ });
129
+ }
130
+ return headings;
131
+ };
132
+ exports.handleParseMarkdownHeadings = handleParseMarkdownHeadings;
133
+ /**
134
+ * Writes the outline's ids into rendered html, in document order.
135
+ *
136
+ * INFO: into the HTML STRING, not onto the mounted DOM. The static renderer sets
137
+ * its html through dangerouslySetInnerHTML, and React re-commits that html
138
+ * whenever it re-renders the element — which wipes every attribute added
139
+ * afterwards. Ids set from an effect therefore survived until the first
140
+ * re-render and then vanished silently, leaving an outline whose entries no
141
+ * longer scrolled anywhere. Being part of the html itself, these cannot be lost.
142
+ *
143
+ * INFO: the heading order is the only thing tying the two together, and it is
144
+ * reliable because both come from one parse of one document — the nth `<h1-3>`
145
+ * in the html is the nth entry in the outline. Levels deeper than the outline
146
+ * carry no id, which is why the pattern stops at h3.
147
+ */
148
+ var handleInjectHeadingIds = function (html, headings) {
149
+ if (!headings.length)
150
+ return html;
151
+ var index = 0;
152
+ return html.replace(/<h([1-3])(\s[^>]*)?>/g, function (match, level, attrs) {
153
+ var heading = headings[index];
154
+ if (!heading)
155
+ return match;
156
+ index += 1;
157
+ return "<h".concat(level).concat(attrs !== null && attrs !== void 0 ? attrs : "", " id=\"").concat(heading.id, "\" data-heading-id=\"").concat(heading.id, "\">");
158
+ });
159
+ };
160
+ exports.handleInjectHeadingIds = handleInjectHeadingIds;
161
+ /**
162
+ * The id a heading node carries in the editor, as a ProseMirror decoration.
163
+ *
164
+ * INFO: a decoration rather than a node attribute or a DOM write. An attribute
165
+ * would reach `getHTML()` — turndown's input — and be written into the saved
166
+ * markdown; a DOM write is undone the next time ProseMirror redraws that node.
167
+ * Decorations are recomputed from the document on every redraw by construction,
168
+ * so an anchor cannot drift out of the view or into the file.
169
+ */
170
+ var handleBuildHeadingAnchors = function (doc) {
171
+ var anchors = [];
172
+ var seen = new Map();
173
+ doc.descendants(function (node, pos) {
174
+ var _a, _b, _c, _d;
175
+ if (((_a = node.type) === null || _a === void 0 ? void 0 : _a.name) !== "heading")
176
+ return;
177
+ var level = (_c = (_b = node.attrs) === null || _b === void 0 ? void 0 : _b.level) !== null && _c !== void 0 ? _c : 1;
178
+ if (level > exports.MAX_OUTLINE_LEVEL)
179
+ return;
180
+ var text = ((_d = node.textContent) !== null && _d !== void 0 ? _d : "").trim();
181
+ if (!text)
182
+ return;
183
+ anchors.push({
184
+ from: pos,
185
+ to: pos + node.nodeSize,
186
+ id: (0, exports.handleDedupeSlug)((0, exports.handleSlugHeading)(text), seen),
187
+ });
188
+ });
189
+ return anchors;
190
+ };
191
+ exports.handleBuildHeadingAnchors = handleBuildHeadingAnchors;
192
+ //# sourceMappingURL=headings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headings.js","sourceRoot":"","sources":["../../../../src/components/input/markdown/headings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAUU,QAAA,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;GAGG;AACU,QAAA,oBAAoB,GAAG,CAAC,CAAC;AAEtC,IAAM,KAAK,GAAG,uBAAuB,CAAC;AACtC,IAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC;;;GAGG;AACH,IAAM,sBAAsB,GAAG,UAAC,GAAW;IACzC,OAAA,GAAG;QACD,4DAA4D;SAC3D,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QACzB,mEAAmE;SAClE,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC;SACxC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;SACvC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE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EAAC,IAAI,CAAC,EAAE,IAAI,CAAC;SACpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAlBW,QAAA,yBAAyB,6BAkBpC"}
@@ -1,5 +1,6 @@
1
1
  import React, { ReactElement } from "react";
2
2
  import { MermaidLoader } from "./mermaid";
3
+ import { MarkdownHeading } from "./headings";
3
4
  export type EmbedView = "grid" | "list";
4
5
  export declare const handleParseEmbedView: (value?: string | null) => EmbedView;
5
6
  export interface EmbedActions {
@@ -76,6 +77,16 @@ interface Props {
76
77
  * until the supplied callback runs, so the host can confirm first.
77
78
  */
78
79
  onRequestRemove?: (spaceId: string, remove: () => void) => void;
80
+ /**
81
+ * Called with the document's headings whenever they change, for a host that
82
+ * renders an outline beside the editor.
83
+ *
84
+ * INFO: the headings are read from the markdown rather than from the editor's
85
+ * nodes, so the list a host gets here is identical to the one MarkdownStatic
86
+ * reports for the same document — the editor and a published page cannot show
87
+ * different outlines for the same note.
88
+ */
89
+ onHeadingsChange?: (headings: MarkdownHeading[]) => void;
79
90
  /**
80
91
  * Extra entries for the `/` menu, appended after the built-in formatting
81
92
  * commands. Use for actions the host app owns, such as creating a database.
@@ -100,6 +111,11 @@ interface MarkdownStaticProps {
100
111
  value: string;
101
112
  darkMode?: boolean;
102
113
  containerClassName?: string;
114
+ /**
115
+ * Called with the document's headings whenever they change, for a host that
116
+ * renders an outline beside the page.
117
+ */
118
+ onHeadingsChange?: (headings: MarkdownHeading[]) => void;
103
119
  lib?: {
104
120
  /**
105
121
  * Loads mermaid, e.g. `() => import("mermaid")`. When given, ```mermaid
@@ -115,7 +131,7 @@ interface MarkdownStaticProps {
115
131
  * many markdown fields stay responsive instead of freezing from 50+ ProseMirror
116
132
  * instances or a heavy re-parse.
117
133
  */
118
- export declare const MarkdownStatic: ({ id, label, labelExtra, subLabel, value, darkMode, containerClassName, lib, }: MarkdownStaticProps) => React.JSX.Element;
134
+ export declare const MarkdownStatic: ({ id, label, labelExtra, subLabel, value, darkMode, containerClassName, onHeadingsChange, lib, }: MarkdownStaticProps) => React.JSX.Element;
119
135
  export declare const MarkdownInput: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<unknown>>;
120
136
  export {};
121
137
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/input/markdown/index.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,EACZ,YAAY,EAQb,MAAM,OAAO,CAAC;AAKf,OAAO,EAGL,aAAa,EAGd,MAAM,WAAW,CAAC;AAiGnB,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAIxC,eAAO,MAAM,oBAAoB,WAAY,MAAM,GAAG,IAAI,KAAG,SACzB,CAAC;AA+lBrC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,UAC9B,GAAG,iBACK,MAAM,KACpB,SAUF,CAAC;AA6WF,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OA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