comark-ui 0.8.1 → 0.8.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/README.md CHANGED
@@ -29,7 +29,9 @@ comarkUi({
29
29
  });
30
30
  ```
31
31
 
32
- `include` is off because it reads files from disk; turn it on to paste files into a document. `cast`, `table`, and `tests` are on but read no files until you pass `{ root }` or `{ read }`. When you parse in a browser, pass `chips: { download: false }`, since a browser may not download another site's images. comark-critic has no component for its styles, so put the exported `criticCss` in the page. The text around the blocks (headings, paragraphs, lists, tables, code, and quotes) is styled too, from shadcn/typeset on the same tokens and scoped to the document; pass `typeset: false` when your site already styles Markdown. See [Typeset](https://comark-ui.onmax.me/guide/typeset/).
32
+ `include` is off because it reads files from disk; turn it on to paste files into a document. `cast`, `table`, and `tests` are on but read no files until you pass `{ root }` or `{ read }`. When you parse in a browser, pass `chips: { download: false }`, since a browser may not download another site's images. comark-critic has no component for its styles, so put the exported `criticCss` in the page. The text around the blocks (headings, paragraphs, lists, tables, code, and quotes) is styled too, from shadcn/typeset on the same tokens and scoped to the document; pass `typeset: false` when your site already styles Markdown. For content outside a document, such as an editor, import `comark-ui/typeset.css` and add the `comark-typeset` class. See [Typeset](https://comark-ui.onmax.me/guide/typeset/).
33
+
34
+ It also returns `tags` and `blocks`. `tags` is every element a parsed document can hold besides the components; with the components' names, it's the allowlist for Comark's `security` plugin. `blocks` are the blocks the plugins replace while parsing, such as `::code-group`, which a linter needs beside the components' names.
33
35
 
34
36
  ## Renderers
35
37
 
package/dist/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as typesetCss } from "./typeset-css-DdOGL7WF.mjs";
1
+ import { n as typesetStylesheet, t as typesetCss } from "./typeset-css-DtOLAa1Z.mjs";
2
2
  //#region src/client.d.ts
3
3
  /**
4
4
  * comark-pele's diagrams on the shared `--comark-*` tokens, on a card like comark-diagrams'. Pele paints with its
@@ -19,4 +19,4 @@ export declare function mermaidBar(): string;
19
19
  */
20
20
  export declare function startMermaid(): () => void;
21
21
  //#endregion
22
- export { typesetCss };
22
+ export { typesetCss, typesetStylesheet };
package/dist/client.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as typesetCss } from "./typeset-css-blSNpFNK.mjs";
1
+ import { n as typesetStylesheet, t as typesetCss } from "./typeset-css-BYvWbqWz.mjs";
2
2
  import { i as startMermaid, n as mermaidBar, r as mermaidCss, t as addMermaidStyles } from "./client-kUEiRbtp.mjs";
3
- export { addMermaidStyles, mermaidBar, mermaidCss, startMermaid, typesetCss };
3
+ export { addMermaidStyles, mermaidBar, mermaidCss, startMermaid, typesetCss, typesetStylesheet };
@@ -1,12 +1,9 @@
1
+ import { n as isElement, t as childrenOf } from "./nodes-CwDBFXnO.mjs";
1
2
  import { c as fromMarkdown, l as toMarkdown, m as ComarkKit, s as checkMarkdown } from "./editor-9IcfELjG.mjs";
2
3
  import { Editor, EditorContent } from "@tiptap/vue-3";
3
4
  import { rowsOf } from "comark-properties";
4
5
  import { Properties } from "comark-properties/vue";
5
6
  import { defineComponent, h, onScopeDispose, ref, shallowRef, watch } from "vue";
6
- //#region ../../shared/nodes.ts
7
- const isElement = (node) => Array.isArray(node) && node[0] !== null;
8
- const childrenOf = ([, , ...rest]) => rest;
9
- //#endregion
10
7
  //#region src/editor-vue.ts
11
8
  /**
12
9
  * A Tiptap editor bound to a Markdown string: an edit writes the Markdown back, and a change from outside reloads the
package/dist/html.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as criticCss, n as Preset, r as PresetOptions } from "./index-DVGSDzBS.mjs";
1
+ import { a as commentsCss, n as Preset, o as criticCss, r as PresetOptions } from "./index-BTyvRIPX.mjs";
2
2
  import { NodeHandler } from "comark";
3
3
  //#region src/html.d.ts
4
4
  /**
@@ -10,4 +10,4 @@ export declare const mermaidScript: string;
10
10
  /** Every plugin for `@comark/html`, with the `components` to render them. */
11
11
  declare const _default: (options?: PresetOptions) => Preset<NodeHandler>;
12
12
  //#endregion
13
- export { type PresetOptions, criticCss, _default as default };
13
+ export { type PresetOptions, commentsCss, criticCss, _default as default };
package/dist/html.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as typesetCss } from "./typeset-css-blSNpFNK.mjs";
2
- import { n as preset, t as criticCss } from "./src-PkmYCSNu.mjs";
1
+ import { n as criticCss, r as preset, t as commentsCss } from "./src-Baygj6ZQ.mjs";
2
+ import { t as typesetCss } from "./typeset-css-BYvWbqWz.mjs";
3
3
  import { a as start, n as mermaidBar, r as mermaidCss } from "./client-kUEiRbtp.mjs";
4
4
  import { t as rawText } from "./text-D8j9clg3.mjs";
5
5
  import { escapeHtml } from "comark/utils";
@@ -111,4 +111,4 @@ var html_default = (options) => preset({
111
111
  zoom
112
112
  }, options);
113
113
  //#endregion
114
- export { criticCss, html_default as default, mermaidScript };
114
+ export { commentsCss, criticCss, html_default as default, mermaidScript };
@@ -1,12 +1,14 @@
1
1
  import { CriticOptions, css as criticCss } from "comark-critic";
2
2
  import { FigureOptions } from "comark-figure";
3
3
  import { FootnotesOptions } from "comark-footnotes";
4
+ import { CalloutsOptions, ReferencesOptions } from "comark-github";
4
5
  import { IconOptions, Icons } from "comark-icon";
5
6
  import { IncludeOptions } from "comark-include";
6
7
  import { KeysOptions } from "comark-keys";
7
8
  import { ReadingTimeOptions } from "comark-reading-time";
8
9
  import { XrefOptions } from "comark-xref";
9
10
  import { ComarkPlugin } from "comark";
11
+ import { CommentsOptions, css as commentsCss } from "comark-comments";
10
12
  import { PropertiesOptions } from "comark-properties";
11
13
  import { BadgeOptions } from "comark-badge";
12
14
  import { AnnotateOptions } from "comark-annotate";
@@ -14,11 +16,9 @@ import { CastOptions } from "comark-cast";
14
16
  import { ChartsOptions } from "comark-charts";
15
17
  import { ChipsOptions } from "comark-chips";
16
18
  import { CodeOptions } from "comark-code";
17
- import { CommentsOptions } from "comark-comments";
18
19
  import { DetailsOptions } from "comark-details";
19
20
  import { DiagramsOptions } from "comark-diagrams";
20
21
  import { FileTreeOptions } from "comark-file-tree";
21
- import { CalloutsOptions, ReferencesOptions } from "comark-github";
22
22
  import { AnchorsOptions, ExternalOptions } from "comark-links";
23
23
  import { MathOptions } from "comark-mathml";
24
24
  import { MediaOptions } from "comark-media";
@@ -29,6 +29,14 @@ import { TableOptions } from "comark-table";
29
29
  import { TabsOptions } from "comark-tabs";
30
30
  import { TestsOptions } from "comark-tests";
31
31
  import { ZoomOptions } from "comark-zoom";
32
+ //#region src/mermaid-limits.d.ts
33
+ type MermaidOptions = PeleConfig & {
34
+ /** How many diagrams a document draws. The ones after show their source as a code block. */
35
+ maxDiagrams?: number;
36
+ /** How many characters of Mermaid source a document draws, over all its diagrams. A diagram past it shows its source. */
37
+ maxSource?: number;
38
+ };
39
+ //#endregion
32
40
  //#region src/typeset.d.ts
33
41
  /** The node that adds the styles. The plugin adds one at the end of every document. */
34
42
  declare const TYPESET_TAG = "typeset-styles";
@@ -63,8 +71,11 @@ type PresetOptions = {
63
71
  comments?: CommentsOptions | boolean;
64
72
  /** Sends each diagram's source to `https://kroki.io` unless you pass your own `server`, or `{ draw: false }`. */
65
73
  diagrams?: DiagramsOptions | boolean;
66
- /** Draws `mermaid` fences with comark-pele, on the server and offline. */
67
- mermaid?: PeleConfig | boolean;
74
+ /**
75
+ * Draws `mermaid` fences with comark-pele, on the server and offline. A host that renders documents it didn't write
76
+ * can pass `{ maxDiagrams, maxSource }`: the diagrams past either limit show their source as code, each with an issue.
77
+ */
78
+ mermaid?: MermaidOptions | boolean;
68
79
  /** HTML only: Vue, React, and Svelte have no diff components. */
69
80
  diff?: boolean;
70
81
  embed?: boolean;
@@ -176,8 +187,19 @@ type Renderer<C> = {
176
187
  type Preset<C> = {
177
188
  plugins: AnyPlugin[];
178
189
  components: Record<string, C>;
190
+ /**
191
+ * Every tag but `components`' that a document parsed with `plugins` can hold: Markdown's own, the raw HTML that
192
+ * GitHub's `html` plugin keeps, and the plain elements the plugins draw with. With `components`' names, it's the
193
+ * allowlist a host that sanitizes the tree needs. With GitHub's `html` off, raw HTML is left to the host.
194
+ */
195
+ tags: string[];
196
+ /**
197
+ * The blocks a document may write that the plugins turn into other nodes while parsing, such as `::code-group`. A
198
+ * linter that reports unknown components needs them beside `components`' names.
199
+ */
200
+ blocks: string[];
179
201
  };
180
202
  /** Builds a renderer's preset. Use the one from `comark-ui/html`, `/vue`, `/react`, or `/svelte`. */
181
203
  declare function preset<C>(renderer: Renderer<C>, options?: PresetOptions): Preset<C>;
182
204
  //#endregion
183
- export { criticCss as a, typeset as c, Renderer as i, Preset as n, preset as o, PresetOptions as r, TYPESET_TAG as s, AnyPlugin as t };
205
+ export { commentsCss as a, TYPESET_TAG as c, Renderer as i, typeset as l, Preset as n, criticCss as o, PresetOptions as r, preset as s, AnyPlugin as t, MermaidOptions as u };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as typesetCss } from "./typeset-css-DdOGL7WF.mjs";
2
- import { a as criticCss, c as typeset, i as Renderer, n as Preset, o as preset, r as PresetOptions, s as TYPESET_TAG, t as AnyPlugin } from "./index-DVGSDzBS.mjs";
3
- export { AnyPlugin, Preset, PresetOptions, Renderer, TYPESET_TAG, criticCss, preset, typeset, typesetCss };
1
+ import { n as typesetStylesheet, t as typesetCss } from "./typeset-css-DtOLAa1Z.mjs";
2
+ import { a as commentsCss, c as TYPESET_TAG, i as Renderer, l as typeset, n as Preset, o as criticCss, r as PresetOptions, s as preset, t as AnyPlugin, u as MermaidOptions } from "./index-BTyvRIPX.mjs";
3
+ export { AnyPlugin, type MermaidOptions, Preset, PresetOptions, Renderer, TYPESET_TAG, commentsCss, criticCss, preset, typeset, typesetCss, typesetStylesheet };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as typesetCss } from "./typeset-css-blSNpFNK.mjs";
2
- import { i as typeset, n as preset, r as TYPESET_TAG, t as criticCss } from "./src-PkmYCSNu.mjs";
3
- export { TYPESET_TAG, criticCss, preset, typeset, typesetCss };
1
+ import { a as typeset, i as TYPESET_TAG, n as criticCss, r as preset, t as commentsCss } from "./src-Baygj6ZQ.mjs";
2
+ import { n as typesetStylesheet, t as typesetCss } from "./typeset-css-BYvWbqWz.mjs";
3
+ export { TYPESET_TAG, commentsCss, criticCss, preset, typeset, typesetCss, typesetStylesheet };
@@ -0,0 +1,5 @@
1
+ //#region ../../shared/nodes.ts
2
+ const isElement = (node) => Array.isArray(node) && node[0] !== null;
3
+ const childrenOf = ([, , ...rest]) => rest;
4
+ //#endregion
5
+ export { isElement as n, childrenOf as t };
package/dist/react.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { a as criticCss, n as Preset, r as PresetOptions } from "./index-DVGSDzBS.mjs";
1
+ import { a as commentsCss, n as Preset, o as criticCss, r as PresetOptions } from "./index-BTyvRIPX.mjs";
2
2
  import { ComponentType } from "react";
3
3
  //#region src/react.d.ts
4
4
  type AnyComponent = ComponentType<any>;
5
5
  /** Every plugin with components for `@comark/react`, which leaves out annotate, comments, diff, and quiz. */
6
6
  declare const _default: (options?: PresetOptions) => Preset<AnyComponent>;
7
7
  //#endregion
8
- export { type PresetOptions, criticCss, _default as default };
8
+ export { type PresetOptions, commentsCss, criticCss, _default as default };
package/dist/react.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as typesetCss } from "./typeset-css-blSNpFNK.mjs";
2
- import { n as preset, t as criticCss } from "./src-PkmYCSNu.mjs";
1
+ import { n as criticCss, r as preset, t as commentsCss } from "./src-Baygj6ZQ.mjs";
2
+ import { t as typesetCss } from "./typeset-css-BYvWbqWz.mjs";
3
3
  import { i as startMermaid, n as mermaidBar, t as addMermaidStyles } from "./client-kUEiRbtp.mjs";
4
4
  import { createElement, useEffect } from "react";
5
5
  import * as badge from "comark-badge/react";
@@ -94,4 +94,4 @@ var react_default = (options) => preset({
94
94
  zoom
95
95
  }, options);
96
96
  //#endregion
97
- export { criticCss, react_default as default };
97
+ export { commentsCss, criticCss, react_default as default };
package/dist/skills.mjs CHANGED
@@ -325,6 +325,6 @@ const skills = [
325
325
  }
326
326
  ];
327
327
  /** The comark-ui version the skills come from, for a host's cache key or a digest. */
328
- const version = "0.8.1";
328
+ const version = "0.8.2";
329
329
  //#endregion
330
330
  export { skills, version };
@@ -1,14 +1,61 @@
1
+ import { n as isElement, t as childrenOf } from "./nodes-CwDBFXnO.mjs";
1
2
  import cjk from "comark-cjk";
2
3
  import critic, { css as criticCss } from "comark-critic";
3
4
  import deflist from "comark-deflist";
4
5
  import figure from "comark-figure";
5
6
  import footnotes from "comark-footnotes";
7
+ import { HTML_TAGS } from "comark-github";
6
8
  import { createIcons } from "comark-icon";
7
9
  import include from "comark-include";
8
10
  import keys from "comark-keys";
9
11
  import readingTime from "comark-reading-time";
10
12
  import xref from "comark-xref";
11
13
  import { defineComarkPlugin } from "comark";
14
+ import { css as commentsCss } from "comark-comments";
15
+ //#region src/mermaid-limits.ts
16
+ function diagramsOf(nodes, found = []) {
17
+ for (const node of nodes) {
18
+ if (!isElement(node)) continue;
19
+ if (node[0] === "pele") found.push(node);
20
+ else diagramsOf(childrenOf(node), found);
21
+ }
22
+ return found;
23
+ }
24
+ /**
25
+ * Turns the diagrams past a document's limits back into code blocks, before comark-code reads them, so a host that
26
+ * renders other people's documents bounds the time Pele spends drawing. Each one it turns back is a `meta.issues` entry.
27
+ */
28
+ var mermaid_limits_default = defineComarkPlugin(({ maxDiagrams = Infinity, maxSource = Infinity } = {}) => ({
29
+ name: "comark-ui-mermaid-limits",
30
+ post({ tree }) {
31
+ const issues = [];
32
+ let drawn = 0;
33
+ let source = 0;
34
+ for (const [n, node] of diagramsOf(tree.nodes).entries()) {
35
+ const content = node[1].content;
36
+ const why = drawn >= maxDiagrams ? ["comark/mermaid/too-many-diagrams", `a document draws at most ${maxDiagrams} Mermaid diagrams. Move it to another document`] : source + content.length > maxSource ? ["comark/mermaid/source-too-long", `a document draws at most ${maxSource} characters of Mermaid. Shorten it or move it to another document`] : void 0;
37
+ if (!why) {
38
+ drawn++;
39
+ source += content.length;
40
+ continue;
41
+ }
42
+ const language = node[1].language ?? "mermaid";
43
+ node.splice(0, node.length, "pre", { language }, [
44
+ "code",
45
+ { class: `language-${language}` },
46
+ content.replace(/\n$/, "")
47
+ ]);
48
+ issues.push([why[0], `Mermaid diagram ${n + 1} shows its source as code, because ${why[1]}.`]);
49
+ }
50
+ if (!issues.length) return;
51
+ tree.meta.issues = [...tree.meta.issues ?? [], ...issues.map(([, message]) => message)];
52
+ tree.meta.issueRules = {
53
+ ...tree.meta.issueRules,
54
+ ...Object.fromEntries(issues.map(([rule, message]) => [message, rule]))
55
+ };
56
+ }
57
+ }));
58
+ //#endregion
12
59
  //#region src/typeset.ts
13
60
  /** The node that adds the styles. The plugin adds one at the end of every document. */
14
61
  const TYPESET_TAG = "typeset-styles";
@@ -21,6 +68,34 @@ const typeset = defineComarkPlugin(() => ({
21
68
  }));
22
69
  //#endregion
23
70
  //#region src/index.ts
71
+ const words = (text) => text.split(" ");
72
+ const MARKDOWN_TAGS = words("a blockquote br code del em h1 h2 h3 h4 h5 h6 hr img input li ol p pre span strong table tbody td th thead tr ul");
73
+ const TAGS = [
74
+ ["carousel", words("div")],
75
+ ["codeNotes", words("div span")],
76
+ ["critic", words("del ins mark")],
77
+ ["deflist", words("dd dl dt")],
78
+ ["figure", words("figcaption figure")],
79
+ ["footnotes", words("section sup")],
80
+ ["keys", words("kbd")],
81
+ ["mark", words("mark sup")],
82
+ ["metrics", words("dd div dt")],
83
+ ["outline", words("a div li ul")],
84
+ ["properties", words("dd div dt time")],
85
+ ["quiz", words("div quiz-after quiz-answer quiz-explain quiz-hint quiz-label quiz-option quiz-options quiz-prompt quiz-rationale")],
86
+ ["sources", words("ol sup")],
87
+ ["table", words("button div span")],
88
+ ["tabs", words("div tabs-item")],
89
+ ["tests", words("details div summary")],
90
+ ["xref", words("caption figcaption figure")]
91
+ ];
92
+ const BLOCKS = [
93
+ ["details", words("accordion-item collapsible details")],
94
+ ["metrics", words("progress stats")],
95
+ ["table", words("table")],
96
+ ["tabs", words("code-group tabs-item")],
97
+ ["xref", words("ref")]
98
+ ];
24
99
  const on = (value, fallback = true) => value === void 0 ? fallback : value !== false;
25
100
  const optionsOf = (value) => value === true || value === false ? void 0 : value;
26
101
  const noFiles = { read: () => void 0 };
@@ -49,7 +124,14 @@ function preset(renderer, options = {}) {
49
124
  add(renderer.chips, options.chips);
50
125
  add(renderer.colors, options.colors);
51
126
  add(renderer.diagrams, options.diagrams);
52
- add(renderer.mermaid, options.mermaid);
127
+ if (on(options.mermaid)) {
128
+ const { maxDiagrams, maxSource, ...pele } = optionsOf(options.mermaid) ?? {};
129
+ add(renderer.mermaid, true, pele);
130
+ if (maxDiagrams !== void 0 || maxSource !== void 0) plugins.push(mermaid_limits_default({
131
+ maxDiagrams,
132
+ maxSource
133
+ }));
134
+ }
53
135
  add(renderer.diff, options.diff);
54
136
  add(renderer.embed, options.embed);
55
137
  parse(footnotes, options.footnotes);
@@ -111,10 +193,26 @@ function preset(renderer, options = {}) {
111
193
  plugins.push(typeset());
112
194
  components[TYPESET_TAG] = renderer.typeset;
113
195
  }
196
+ const { annotate, comments, diff, quiz } = renderer;
197
+ const absent = Object.entries({
198
+ annotate,
199
+ comments,
200
+ diff,
201
+ quiz
202
+ }).flatMap(([key, part]) => part ? [] : [key]);
203
+ const enabled = (key) => on(options[key], key !== "include") && !absent.includes(key);
204
+ const tags = /* @__PURE__ */ new Set([
205
+ ...MARKDOWN_TAGS,
206
+ ...on(options.github) && on(optionsOf(options.github)?.html) ? HTML_TAGS : [],
207
+ ...TAGS.flatMap(([key, list]) => enabled(key) ? list : [])
208
+ ]);
209
+ const blocks = BLOCKS.flatMap(([key, list]) => enabled(key) ? list : []);
114
210
  return {
115
211
  plugins,
116
- components
212
+ components,
213
+ tags: [...tags],
214
+ blocks
117
215
  };
118
216
  }
119
217
  //#endregion
120
- export { typeset as i, preset as n, TYPESET_TAG as r, criticCss as t };
218
+ export { typeset as a, TYPESET_TAG as i, criticCss as n, preset as r, commentsCss as t };
@@ -1,7 +1,7 @@
1
1
  import type { Component } from "svelte";
2
2
  import type { Preset, PresetOptions } from "comark-ui";
3
3
 
4
- export { criticCss } from "comark-ui";
4
+ export { commentsCss, criticCss } from "comark-ui";
5
5
  export type { PresetOptions } from "comark-ui";
6
6
 
7
7
  /** Every plugin with components for `@comark/svelte`, which leaves out annotate, comments, diff, and quiz. */
@@ -35,7 +35,7 @@ import * as zoom from "comark-zoom/svelte";
35
35
  import Mermaid from "./Mermaid.svelte";
36
36
  import typeset from "./Typeset.svelte";
37
37
 
38
- export { criticCss } from "comark-ui";
38
+ export { commentsCss, criticCss } from "comark-ui";
39
39
 
40
40
  const mermaid = { default: pele, components: { pele: Mermaid } };
41
41
 
@@ -137,7 +137,8 @@ const rules = `
137
137
  }
138
138
 
139
139
  &:where(img, video) { border-radius: var(--_ty-radius); max-width: 100%; height: auto; margin-block: var(--_ty-flow) 0; }
140
- &:where(p img) { margin-block-start: 0; }
140
+ /* An image in a line of text sits on the text; a block's top margin would push it below. */
141
+ &:where(:is(p, li, td, th, a) img) { margin-block-start: 0; }
141
142
  &:where(figure) { margin-block: var(--_ty-flow) 0; margin-inline: 0; }
142
143
  &:where(figcaption, caption) {
143
144
  color: var(--_ty-muted); font-size: 0.875em; text-align: center; margin-block-start: calc(0.75em / 0.875);
@@ -175,10 +176,18 @@ const rules = `
175
176
  }
176
177
 
177
178
  /* Code highlighted with a light and a dark theme follows the page into dark mode, as the tokens do: a .dark class
178
- above it, or the system's dark mode on a page with no .light class. Only spans that carry a dark color switch. */
179
- .shiki:where(.dark *) span[style*="--shiki-dark:"] { color: var(--shiki-dark) !important; }
179
+ above it, or the system's dark mode on a page with no .light class. A span switches what it has a dark value for. */
180
+ .shiki:where(.dark *) span {
181
+ &[style*="--shiki-dark:"] { color: var(--shiki-dark) !important; }
182
+ &[style*="--shiki-dark-font-style:"] { font-style: var(--shiki-dark-font-style) !important; }
183
+ &[style*="--shiki-dark-font-weight:"] { font-weight: var(--shiki-dark-font-weight) !important; }
184
+ }
180
185
  @media (prefers-color-scheme: dark) {
181
- .shiki:not(:where(.light *)) span[style*="--shiki-dark:"] { color: var(--shiki-dark) !important; }
186
+ .shiki:not(:where(.light *)) span {
187
+ &[style*="--shiki-dark:"] { color: var(--shiki-dark) !important; }
188
+ &[style*="--shiki-dark-font-style:"] { font-style: var(--shiki-dark-font-style) !important; }
189
+ &[style*="--shiki-dark-font-weight:"] { font-weight: var(--shiki-dark-font-weight) !important; }
190
+ }
182
191
  }
183
192
 
184
193
  /* A block marked data-wide, such as a before/after comparison or a diagram wider than the text, grows past the column
@@ -212,5 +221,11 @@ const rules = `
212
221
  * the page wins over both.
213
222
  */
214
223
  const typesetCss = `@layer comark{@layer typeset{@scope{${theme(":scope", "primary")}${rules}}}}`.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/ ?([{};,>(]) ?/g, "$1").replace(/: /g, ":").trim();
224
+ /**
225
+ * The same styles for a page's own stylesheet, scoped to every element that matches `selector`, for Comark content
226
+ * that isn't a rendered document, such as a rich-text editor. `comark-ui/typeset.css` is this with `.comark-typeset`.
227
+ * The rules are the same string as `typesetCss`, so the two can't drift.
228
+ */
229
+ const typesetStylesheet = (selector = ".comark-typeset") => typesetCss.replace("@scope{", `@scope (${selector}){`);
215
230
  //#endregion
216
- export { typesetCss as t };
231
+ export { typesetStylesheet as n, typesetCss as t };
@@ -6,5 +6,11 @@
6
6
  * the page wins over both.
7
7
  */
8
8
  declare const typesetCss: string;
9
+ /**
10
+ * The same styles for a page's own stylesheet, scoped to every element that matches `selector`, for Comark content
11
+ * that isn't a rendered document, such as a rich-text editor. `comark-ui/typeset.css` is this with `.comark-typeset`.
12
+ * The rules are the same string as `typesetCss`, so the two can't drift.
13
+ */
14
+ declare const typesetStylesheet: (selector?: string) => string;
9
15
  //#endregion
10
- export { typesetCss as t };
16
+ export { typesetStylesheet as n, typesetCss as t };
@@ -0,0 +1 @@
1
+ @layer comark{@layer typeset{@scope (.comark-typeset){:where(:scope){--_comark-background:var(--comark-background,var(--ui-bg,var(--background,#fff)));--_comark-foreground:var(--comark-foreground,var(--ui-text-highlighted,var(--foreground,#0a0a0a)));--_comark-muted:var(--comark-muted,var(--ui-text-muted,var(--muted-foreground,#737373)));--_comark-border:var(--comark-border,var(--ui-border,var(--border,#e5e5e5)));--_comark-accent:var(--comark-accent,var(--ui-bg-elevated,var(--accent,#f5f5f5)));--_comark-ring:var(--comark-ring,var(--ui-primary,var(--ring,#a1a1a1)));--_comark-primary:var(--comark-primary,var(--ui-primary,var(--primary,var(--_comark-foreground))));--_comark-primary-foreground:var(--comark-primary-foreground,var(--ui-text-inverted,var(--primary-foreground,var(--_comark-background))));--_comark-secondary:var(--comark-secondary,var(--ui-secondary,var(--_comark-muted)));--_comark-radius:var(--comark-radius,calc(var(--ui-radius,calc(var(--radius,.625rem)/2))*2));--_comark-font:var(--comark-font,var(--font-sans,ui-sans-serif,system-ui,sans-serif))}@media(prefers-color-scheme:dark){:where(:scope){--_comark-background:var(--comark-background,var(--ui-bg,var(--background,#0a0a0a)));--_comark-foreground:var(--comark-foreground,var(--ui-text-highlighted,var(--foreground,#fafafa)));--_comark-muted:var(--comark-muted,var(--ui-text-muted,var(--muted-foreground,#a1a1a1)));--_comark-border:var(--comark-border,var(--ui-border,var(--border,rgb(255 255 255/.1))));--_comark-accent:var(--comark-accent,var(--ui-bg-elevated,var(--accent,#262626)));--_comark-ring:var(--comark-ring,var(--ui-primary,var(--ring,#737373)));--_comark-primary:var(--comark-primary,var(--ui-primary,var(--primary,var(--_comark-foreground))));--_comark-primary-foreground:var(--comark-primary-foreground,var(--ui-text-inverted,var(--primary-foreground,var(--_comark-background))));--_comark-secondary:var(--comark-secondary,var(--ui-secondary,var(--_comark-muted)))}}:scope{--_ty-flow:var(--typeset-flow,1.25em);--_ty-muted:var(--_comark-muted);--_ty-rule:var(--_comark-border);--_ty-surface:var(--_comark-accent);--_ty-radius:calc(var(--_comark-radius) * 0.8);--_ty-mono:var(--comark-font-mono,var(--font-mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace));font-family:var(--_comark-font);font-size:calc(var(--typeset-size,1em) * 1.125);line-height:var(--typeset-leading,1.75);color:var(--_comark-foreground);overflow-wrap:break-word;background-image:var(--comark-grain,url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"));background-repeat:repeat;background-size:var(--comark-grain-size,256px 256px);@media(min-width:48rem),print{font-size:var(--typeset-size,1em);}}:scope *:not(:where(.not-typeset,[data-not-typeset],.not-typeset *,[data-not-typeset] *)){&:where(p){margin-block:var(--_ty-flow) 0;}&:where(h1,h2,h3,h4,h5,h6){color:var(--_comark-foreground);font-family:var(--comark-font-heading,var(--font-heading,inherit));font-weight:600;margin-block-end:0;}&:where(h1){font-size:1.75em;line-height:1.3;margin-block-start:var(--_ty-flow);}&:where(h2){font-size:1.25em;line-height:1.4;margin-block-start:calc(var(--_ty-flow) * 1.4);}&:where(h3){font-size:1.125em;line-height:1.45;margin-block-start:var(--_ty-flow);}&:where(h4){font-size:1em;line-height:1.5;margin-block-start:var(--_ty-flow);}&:where(h5){font-size:0.875em;line-height:1.5;font-weight:500;color:var(--_ty-muted);margin-block-start:calc(var(--_ty-flow) / 0.875);}&:where(h6){font-size:0.8125em;line-height:1.5;font-weight:500;letter-spacing:0.08em;text-transform:uppercase;color:var(--_ty-muted);margin-block-start:calc(var(--_ty-flow) / 0.8125);}&:where([id]){scroll-margin-block-start:var(--_ty-flow);}&:where(h1 + *,h2 + *,h3 + *,h4 + *,h5 + *,h6 + *){margin-block-start:1em;}&:where(:is(h1,h2,h3,h4) code){font-size:0.9em;}&:where(a){color:inherit;font-weight:500;text-decoration-line:underline;text-decoration-color:color-mix(in oklab,currentColor 30%,transparent);}&:where(a:hover){text-decoration-color:currentColor;}&:where(a:focus-visible){outline:2px solid var(--_comark-ring);outline-offset:2px;border-radius:0.125em;}&:where(:is(h1,h2,h3,h4,h5,h6) a){font-weight:inherit;}&:where(strong,b){font-weight:600;}&:where(mark){background-color:color-mix(in oklab,oklch(0.86 0.17 95) 40%,transparent);color:inherit;padding:0.05em 0.15em;border-radius:0.2em;}&:where(abbr[title]){text-decoration-line:underline;text-decoration-style:dotted;text-underline-offset:0.2em;cursor:help;}&:where(del,s){color:var(--_ty-muted);text-decoration-line:line-through;}&:where(sup,sub){font-size:0.75em;line-height:0;position:relative;vertical-align:baseline;}&:where(sup){top:-0.5em;}&:where(sub){bottom:-0.25em;}&:where(sup a){text-decoration-line:none;font-weight:500;}&:where(ul){list-style-type:disc;}&:where(ol){list-style-type:decimal;}&:where(ul ul){list-style-type:circle;}&:where(ul ul ul){list-style-type:square;}&:where(ol[type="a" i]){list-style-type:lower-alpha;}&:where(ol[type="i" i]){list-style-type:lower-roman;}&:where(ol[type="A" s]){list-style-type:upper-alpha;}&:where(ol[type="I" s]){list-style-type:upper-roman;}&:where(ul,ol){margin-block:var(--_ty-flow) 0;padding-inline-start:1.5em;}&:where(li){margin-block-start:0.5em;padding-inline-start:0.4em;}&:where(li>p,li>ul,li>ol){margin-block-start:0.5em;}&:where(ul>li,ol>li)::marker{color:var(--_ty-muted);}&:where(ul.contains-task-list){list-style-type:none;padding-inline-start:0.25em;}&:where(li.task-list-item>input[type="checkbox"]){margin-inline-end:0.5em;vertical-align:-0.1em;accent-color:var(--_comark-primary);}&:where(details){margin-block:var(--_ty-flow) 0;}&:where(summary){cursor:pointer;font-weight:500;}&:where(summary)::marker{color:var(--_ty-muted);}&:where(kbd){font-family:inherit;font-size:0.85em;font-weight:500;border:1px solid var(--_ty-rule);border-block-end-width:2px;border-radius:0.35em;padding:0.0625em 0.35em;}&:where(dl){margin-block:var(--_ty-flow) 0;}&:where(dt){font-weight:500;margin-block-start:1em;}&:where(dt + dt){margin-block-start:0.25em;}&:where(dd){margin-block-start:0.25em;margin-inline-start:0;padding-inline-start:1em;color:var(--_ty-muted);}&:where(:not(pre)>code){background-color:var(--_ty-surface);font-family:var(--_ty-mono);font-size:0.85em;border-radius:0.35em;padding:0.125em 0.3em;}&:where(pre){background-color:var(--_ty-surface);font-family:var(--_ty-mono);font-size:0.875em;line-height:1.5;tab-size:2;direction:ltr;border-radius:var(--_ty-radius);padding:0.75em 1em;overflow-x:auto;margin-block:calc(var(--_ty-flow) / 0.875) 0;}&:where(pre code){background-color:transparent;font-family:inherit;font-size:inherit;padding:0;border-radius:0;}&:where(blockquote){border-inline-start:2px solid var(--_ty-rule);padding-inline-start:1em;margin-block:var(--_ty-flow) 0;margin-inline:0;}&:where(hr){border:0;border-block-start:1px solid var(--_ty-rule);margin-block:calc(var(--_ty-flow) * 2.4) 0;}&:where(hr + h1,hr + h2,hr + h3,hr + h4){margin-block-start:var(--_ty-flow);}&:where(.footnotes,[data-footnotes]){margin-block-start:calc(var(--_ty-flow) * 2);font-size:0.875em;color:var(--_ty-muted);}&:where(.footnotes>hr:first-child){margin-block-start:0;}&:where(.footnote-ref a,.footnote-backref){text-decoration-line:none;}&:where(math[display="block"]){margin-block:var(--_ty-flow) 0;overflow-x:auto;overflow-y:hidden;padding-block:0.25em;}&:where(img,video){border-radius:var(--_ty-radius);max-width:100%;height:auto;margin-block:var(--_ty-flow) 0;}&:where(:is(p,li,td,th,a) img){margin-block-start:0;}&:where(figure){margin-block:var(--_ty-flow) 0;margin-inline:0;}&:where(figcaption,caption){color:var(--_ty-muted);font-size:0.875em;text-align:center;margin-block-start:calc(0.75em / 0.875);}&:where(caption){caption-side:bottom;}&:where(table){display:block;width:max-content;max-width:100%;overflow-x:auto;font-size:1em;line-height:1.5;font-variant-numeric:tabular-nums;border-collapse:separate;border-spacing:0;border-block-end:1px solid var(--_ty-rule);margin-block:var(--_ty-flow) 0;}&:where(thead th){font-weight:500;text-align:start;padding:0.65em 1em;}&:where(:is(tbody,tfoot) :is(td,th)){padding:0.75em 1em;text-align:start;vertical-align:top;border-block-start:1px solid var(--_ty-rule);}&:where(tbody th,tfoot th){font-weight:500;}&:where(th:first-child,td:first-child){padding-inline-start:0;}&:where(th[align="center"],td[align="center"]){text-align:center;}&:where(th[align="right"],td[align="right"]){text-align:end;}&:where(li>blockquote,li>table,li>figure){margin-block-start:0.5em;}&:where(li>pre){margin-block-start:calc(0.5em / 0.875);}@media print{&:where(pre,table,blockquote,figure){break-inside:avoid;}&:where(h1,h2,h3,h4){break-after:avoid;}}@media(forced-colors:active){&:where(:not(pre)>code){border:1px solid;}}}.shiki:where(.dark *) span{&[style*="--shiki-dark:"]{color:var(--shiki-dark) !important;}&[style*="--shiki-dark-font-style:"]{font-style:var(--shiki-dark-font-style) !important;}&[style*="--shiki-dark-font-weight:"]{font-weight:var(--shiki-dark-font-weight) !important;}}@media(prefers-color-scheme:dark){.shiki:not(:where(.light *)) span{&[style*="--shiki-dark:"]{color:var(--shiki-dark) !important;}&[style*="--shiki-dark-font-style:"]{font-style:var(--shiki-dark-font-style) !important;}&[style*="--shiki-dark-font-weight:"]{font-weight:var(--shiki-dark-font-weight) !important;}}}:scope>[data-wide]{--_ty-start:max(0px,var(--comark-wide-start,0px));--_ty-end:max(0px,var(--comark-wide-end,0px));--_ty-wide:max(100%,min(var(--comark-wide-width,100vw),var(--comark-wide-max,72rem),100% + var(--_ty-start) + var(--_ty-end)));width:var(--_ty-wide);margin-inline:clamp(-1 * var(--_ty-start),(100% - var(--_ty-wide)) / 2,100% + var(--_ty-end) - var(--_ty-wide)) 0;}:scope>:where(:first-child):not(:where(.not-typeset,[data-not-typeset],.not-typeset *,[data-not-typeset] *)),:scope>:where(:first-child)>:where(:first-child):not(:where(.not-typeset,[data-not-typeset],.not-typeset *,[data-not-typeset] *)),:scope :where(li>:first-child,blockquote>:first-child,td>:first-child,th>:first-child,dd>:first-child,figure>:first-child,figure>picture>img ):not(:where(.not-typeset,[data-not-typeset],.not-typeset *,[data-not-typeset] *)){margin-block-start:0;}}}}
package/dist/vue.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as criticCss, n as Preset, r as PresetOptions } from "./index-DVGSDzBS.mjs";
1
+ import { a as commentsCss, n as Preset, o as criticCss, r as PresetOptions } from "./index-BTyvRIPX.mjs";
2
2
  import { Component } from "vue";
3
3
  //#region src/vue.d.ts
4
4
  /** Every plugin with components for `@comark/vue`, which leaves out annotate, comments, diff, and quiz. */
5
5
  declare const _default: (options?: PresetOptions) => Preset<Component>;
6
6
  //#endregion
7
- export { type PresetOptions, criticCss, _default as default };
7
+ export { type PresetOptions, commentsCss, criticCss, _default as default };
package/dist/vue.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as typesetCss } from "./typeset-css-blSNpFNK.mjs";
2
- import { n as preset, t as criticCss } from "./src-PkmYCSNu.mjs";
1
+ import { n as criticCss, r as preset, t as commentsCss } from "./src-Baygj6ZQ.mjs";
2
+ import { t as typesetCss } from "./typeset-css-BYvWbqWz.mjs";
3
3
  import { i as startMermaid, n as mermaidBar, t as addMermaidStyles } from "./client-kUEiRbtp.mjs";
4
4
  import * as properties from "comark-properties/vue";
5
5
  import { defineComponent, h, onBeforeUnmount, onMounted } from "vue";
@@ -110,4 +110,4 @@ var vue_default = (options) => preset({
110
110
  zoom
111
111
  }, options);
112
112
  //#endregion
113
- export { criticCss, vue_default as default };
113
+ export { commentsCss, criticCss, vue_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comark-ui",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Every comark-ui block in one install: annotated screenshots, charts, diffs, tabs, zoom, and more, registered in the order they need with shared icons. Turn any of them off or pass its options.",
5
5
  "keywords": [
6
6
  "comark",
@@ -23,7 +23,9 @@
23
23
  "dist"
24
24
  ],
25
25
  "type": "module",
26
- "sideEffects": false,
26
+ "sideEffects": [
27
+ "*.css"
28
+ ],
27
29
  "exports": {
28
30
  ".": "./dist/index.mjs",
29
31
  "./client": "./dist/client.mjs",
@@ -40,7 +42,8 @@
40
42
  "./vue": "./dist/vue.mjs",
41
43
  "./package.json": "./package.json",
42
44
  "./skills": "./dist/skills.mjs",
43
- "./skills/*": "./dist/skills/*"
45
+ "./skills/*": "./dist/skills/*",
46
+ "./typeset.css": "./dist/typeset.css"
44
47
  },
45
48
  "publishConfig": {
46
49
  "access": "public",
@@ -48,50 +51,50 @@
48
51
  },
49
52
  "dependencies": {
50
53
  "comark-pele": "^1.1.0",
51
- "comark-annotate": "^0.8.1",
52
- "comark-carousel": "^0.8.1",
53
- "comark-cast": "^0.8.1",
54
- "comark-badge": "^0.8.1",
55
- "comark-charts": "^0.8.1",
56
- "comark-cards": "^0.8.1",
57
- "comark-chips": "^0.8.1",
58
- "comark-cjk": "^0.8.1",
59
- "comark-code-notes": "^0.8.1",
60
- "comark-comments": "^0.8.1",
61
- "comark-code": "^0.8.1",
62
- "comark-colors": "^0.8.1",
63
- "comark-critic": "^0.8.1",
64
- "comark-deflist": "^0.8.1",
65
- "comark-details": "^0.8.1",
66
- "comark-diagrams": "^0.8.1",
67
- "comark-diff": "^0.8.1",
68
- "comark-embed": "^0.8.1",
69
- "comark-figure": "^0.8.1",
70
- "comark-footnotes": "^0.8.1",
71
- "comark-file-tree": "^0.8.1",
72
- "comark-fields": "^0.8.1",
73
- "comark-keys": "^0.8.1",
74
- "comark-include": "^0.8.1",
75
- "comark-icon": "^0.8.1",
76
- "comark-github": "^0.8.1",
77
- "comark-magic-move": "^0.8.1",
78
- "comark-mark": "^0.8.1",
79
- "comark-links": "^0.8.1",
80
- "comark-media": "^0.8.1",
81
- "comark-mathml": "^0.8.1",
82
- "comark-metrics": "^0.8.1",
83
- "comark-properties": "^0.8.1",
84
- "comark-outline": "^0.8.1",
85
- "comark-qr": "^0.8.1",
86
- "comark-quiz": "^0.8.1",
87
- "comark-steps": "^0.8.1",
88
- "comark-table": "^0.8.1",
89
- "comark-sources": "^0.8.1",
90
- "comark-reading-time": "^0.8.1",
91
- "comark-tabs": "^0.8.1",
92
- "comark-tests": "^0.8.1",
93
- "comark-xref": "^0.8.1",
94
- "comark-zoom": "^0.8.1"
54
+ "comark-annotate": "^0.8.2",
55
+ "comark-cast": "^0.8.2",
56
+ "comark-cards": "^0.8.2",
57
+ "comark-charts": "^0.8.2",
58
+ "comark-carousel": "^0.8.2",
59
+ "comark-badge": "^0.8.2",
60
+ "comark-chips": "^0.8.2",
61
+ "comark-cjk": "^0.8.2",
62
+ "comark-code": "^0.8.2",
63
+ "comark-colors": "^0.8.2",
64
+ "comark-critic": "^0.8.2",
65
+ "comark-details": "^0.8.2",
66
+ "comark-deflist": "^0.8.2",
67
+ "comark-comments": "^0.8.2",
68
+ "comark-diagrams": "^0.8.2",
69
+ "comark-code-notes": "^0.8.2",
70
+ "comark-embed": "^0.8.2",
71
+ "comark-diff": "^0.8.2",
72
+ "comark-fields": "^0.8.2",
73
+ "comark-figure": "^0.8.2",
74
+ "comark-file-tree": "^0.8.2",
75
+ "comark-include": "^0.8.2",
76
+ "comark-icon": "^0.8.2",
77
+ "comark-keys": "^0.8.2",
78
+ "comark-links": "^0.8.2",
79
+ "comark-mathml": "^0.8.2",
80
+ "comark-footnotes": "^0.8.2",
81
+ "comark-mark": "^0.8.2",
82
+ "comark-github": "^0.8.2",
83
+ "comark-magic-move": "^0.8.2",
84
+ "comark-metrics": "^0.8.2",
85
+ "comark-media": "^0.8.2",
86
+ "comark-outline": "^0.8.2",
87
+ "comark-quiz": "^0.8.2",
88
+ "comark-reading-time": "^0.8.2",
89
+ "comark-steps": "^0.8.2",
90
+ "comark-properties": "^0.8.2",
91
+ "comark-table": "^0.8.2",
92
+ "comark-tests": "^0.8.2",
93
+ "comark-tabs": "^0.8.2",
94
+ "comark-xref": "^0.8.2",
95
+ "comark-qr": "^0.8.2",
96
+ "comark-zoom": "^0.8.2",
97
+ "comark-sources": "^0.8.2"
95
98
  },
96
99
  "devDependencies": {
97
100
  "@comark/html": "^0.8.1",