@lofcz/pptist 2.0.20 → 2.0.22

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.
Files changed (62) hide show
  1. package/dist/embed/agentic-manifest.json +7 -5
  2. package/dist/embed/chunks/mathlive.min-Bl0OCKCJ.js +39046 -0
  3. package/dist/embed/chunks/texmath-Ca6UVlA5.js +215 -0
  4. package/dist/embed/fonts/KaTeX_AMS-400-normal-34494743.woff2 +0 -0
  5. package/dist/embed/fonts/KaTeX_Caligraphic-400-normal-9f8077e0.woff2 +0 -0
  6. package/dist/embed/fonts/KaTeX_Caligraphic-700-normal-5bfa49ca.woff2 +0 -0
  7. package/dist/embed/fonts/KaTeX_Fraktur-400-normal-a5764c6e.woff2 +0 -0
  8. package/dist/embed/fonts/KaTeX_Fraktur-700-normal-f98f8927.woff2 +0 -0
  9. package/dist/embed/fonts/KaTeX_Main-400-italic-c9b2b5ff.woff2 +0 -0
  10. package/dist/embed/fonts/KaTeX_Main-400-normal-c884086c.woff2 +0 -0
  11. package/dist/embed/fonts/KaTeX_Main-700-italic-a4a4905b.woff2 +0 -0
  12. package/dist/embed/fonts/KaTeX_Main-700-normal-31050a1b.woff2 +0 -0
  13. package/dist/embed/fonts/KaTeX_Math-400-italic-db4883d0.woff2 +0 -0
  14. package/dist/embed/fonts/KaTeX_Math-700-italic-8fcb9d2d.woff2 +0 -0
  15. package/dist/embed/fonts/KaTeX_SansSerif-400-italic-3d5fa3cb.woff2 +0 -0
  16. package/dist/embed/fonts/KaTeX_SansSerif-400-normal-e45d5f4f.woff2 +0 -0
  17. package/dist/embed/fonts/KaTeX_SansSerif-700-normal-886e6179.woff2 +0 -0
  18. package/dist/embed/fonts/KaTeX_Script-400-normal-63b80959.woff2 +0 -0
  19. package/dist/embed/fonts/KaTeX_Size1-400-normal-57fa5999.woff2 +0 -0
  20. package/dist/embed/fonts/KaTeX_Size2-400-normal-ee187136.woff2 +0 -0
  21. package/dist/embed/fonts/KaTeX_Size3-400-normal-19a7caad.woff2 +0 -0
  22. package/dist/embed/fonts/KaTeX_Size4-400-normal-9bed17fb.woff2 +0 -0
  23. package/dist/embed/fonts/KaTeX_Typewriter-400-normal-7a08883f.woff2 +0 -0
  24. package/dist/embed/pptist-embed.css +1 -1
  25. package/dist/embed/pptist-embed.js +79960 -79527
  26. package/dist/types/embed/mount.d.ts +2 -0
  27. package/dist/types/i18n/i18n-types.d.ts +28 -0
  28. package/dist/types/main.d.ts +2 -0
  29. package/dist/types/utils/emitter.d.ts +21 -1
  30. package/dist/types/utils/katex-stub.d.ts +15 -0
  31. package/dist/types/utils/markdown.d.ts +1 -1
  32. package/dist/types/utils/math.d.ts +57 -0
  33. package/dist/types/utils/prosemirror/schema/index.d.ts +1 -0
  34. package/dist/types/utils/prosemirror/schema/nodes.d.ts +1 -0
  35. package/dist/types/utils/textFit.d.ts +76 -0
  36. package/dist/types/views/Editor/InlineMathEditorDialog.vue.d.ts +3 -0
  37. package/dist/types/views/components/element/TableElement/utils.d.ts +10 -0
  38. package/dist/types/views/components/element/hooks/useTextFit.d.ts +22 -0
  39. package/package.json +2 -2
  40. package/dist/embed/chunks/katex-CYXlUYaK.js +0 -21817
  41. package/dist/embed/chunks/texmath-By1nWhxV.js +0 -22173
  42. /package/dist/embed/fonts/{AlibabaPuHuiTi.woff2 → AlibabaPuHuiTi-6313a86b.woff2} +0 -0
  43. /package/dist/embed/fonts/{DeYiHei.woff2 → DeYiHei-b28e2636.woff2} +0 -0
  44. /package/dist/embed/fonts/{Inter.woff2 → Inter-4074cf0a.woff2} +0 -0
  45. /package/dist/embed/fonts/{JetBrainsMono.woff2 → JetBrainsMono-a4e25a97.woff2} +0 -0
  46. /package/dist/embed/fonts/{LXGWNeoXiHei.woff2 → LXGWNeoXiHei-60b0871c.woff2} +0 -0
  47. /package/dist/embed/fonts/{LXGWNeoZhiSong.woff2 → LXGWNeoZhiSong-9aaae14d.woff2} +0 -0
  48. /package/dist/embed/fonts/{LXGWWenKai.woff2 → LXGWWenKai-f26bb608.woff2} +0 -0
  49. /package/dist/embed/fonts/{Lato.woff2 → Lato-90c2b482.woff2} +0 -0
  50. /package/dist/embed/fonts/{Literata.woff2 → Literata-31359124.woff2} +0 -0
  51. /package/dist/embed/fonts/{Merriweather.woff2 → Merriweather-40d48271.woff2} +0 -0
  52. /package/dist/embed/fonts/{MiSans.woff2 → MiSans-1b1362c0.woff2} +0 -0
  53. /package/dist/embed/fonts/{Montserrat.woff2 → Montserrat-3f6c7436.woff2} +0 -0
  54. /package/dist/embed/fonts/{OpenSans.woff2 → OpenSans-1f8c4a74.woff2} +0 -0
  55. /package/dist/embed/fonts/{Roboto.woff2 → Roboto-8df37b32.woff2} +0 -0
  56. /package/dist/embed/fonts/{SourceHanSans.woff2 → SourceHanSans-639ce484.woff2} +0 -0
  57. /package/dist/embed/fonts/{SourceHanSerif.woff2 → SourceHanSerif-076e69d8.woff2} +0 -0
  58. /package/dist/embed/fonts/{SourceSansPro.woff2 → SourceSansPro-2e5c488e.woff2} +0 -0
  59. /package/dist/embed/fonts/{SourceSerif4.woff2 → SourceSerif4-e250b371.woff2} +0 -0
  60. /package/dist/embed/fonts/{WenDingPLKaiTi.woff2 → WenDingPLKaiTi-8c595bad.woff2} +0 -0
  61. /package/dist/embed/fonts/{WenDingPLSongTi.woff2 → WenDingPLSongTi-99ca3c11.woff2} +0 -0
  62. /package/dist/embed/fonts/{ZhuQueFangSong.woff2 → ZhuQueFangSong-f53fc6b0.woff2} +0 -0
@@ -1,5 +1,7 @@
1
1
  import 'prosemirror-view/style/prosemirror.css';
2
2
  import 'animate.css';
3
+ import 'mathlive/static.css';
4
+ import 'mathlive/fonts.css';
3
5
  import '../assets/styles/prosemirror.scss';
4
6
  import '../assets/styles/global.scss';
5
7
  import '../assets/styles/font.scss';
@@ -551,6 +551,20 @@ export type NamespaceComponentsTranslation = {
551
551
  */
552
552
  formulaEmpty: string;
553
553
  };
554
+ inlineMathEditor: {
555
+ /**
556
+ * E​d​i​t​ ​f​o​r​m​u​l​a
557
+ */
558
+ title: string;
559
+ /**
560
+ * E​n​t​e​r​ ​a​ ​f​o​r​m​u​l​a
561
+ */
562
+ inputPlaceholder: string;
563
+ /**
564
+ * F​o​r​m​u​l​a​ ​c​a​n​n​o​t​ ​b​e​ ​e​m​p​t​y
565
+ */
566
+ empty: string;
567
+ };
554
568
  };
555
569
  export type NamespaceConfigsTranslation = {
556
570
  shapes: {
@@ -5144,6 +5158,20 @@ export type TranslationFunctions = {
5144
5158
  */
5145
5159
  formulaEmpty: () => LocalizedString;
5146
5160
  };
5161
+ inlineMathEditor: {
5162
+ /**
5163
+ * Edit formula
5164
+ */
5165
+ title: () => LocalizedString;
5166
+ /**
5167
+ * Enter a formula
5168
+ */
5169
+ inputPlaceholder: () => LocalizedString;
5170
+ /**
5171
+ * Formula cannot be empty
5172
+ */
5173
+ empty: () => LocalizedString;
5174
+ };
5147
5175
  };
5148
5176
  configs: {
5149
5177
  shapes: {
@@ -1,5 +1,7 @@
1
1
  import 'prosemirror-view/style/prosemirror.css';
2
2
  import 'animate.css';
3
+ import 'mathlive/static.css';
4
+ import 'mathlive/fonts.css';
3
5
  import './assets/styles/prosemirror.scss';
4
6
  import './assets/styles/global.scss';
5
7
  import './assets/styles/font.scss';
@@ -4,7 +4,9 @@ export declare const enum EmitterEvents {
4
4
  TABLE_COMMAND = "TABLE_COMMAND",
5
5
  SYNC_RICH_TEXT_ATTRS_TO_STORE = "SYNC_RICH_TEXT_ATTRS_TO_STORE",
6
6
  OPEN_CHART_DATA_EDITOR = "OPEN_CHART_DATA_EDITOR",
7
- OPEN_LATEX_EDITOR = "OPEN_LATEX_EDITOR"
7
+ OPEN_LATEX_EDITOR = "OPEN_LATEX_EDITOR",
8
+ OPEN_INLINE_MATH_EDITOR = "OPEN_INLINE_MATH_EDITOR",
9
+ APPLY_INLINE_MATH = "APPLY_INLINE_MATH"
8
10
  }
9
11
  export interface RichTextAction {
10
12
  command: string;
@@ -19,12 +21,30 @@ export interface TableCommand {
19
21
  command: 'insert-row' | 'insert-col' | 'delete-row' | 'delete-col';
20
22
  position?: 'before' | 'after';
21
23
  }
24
+ /** Request to open the inline-math (MathLive) editor for a math node in a text element. */
25
+ export interface OpenInlineMathPayload {
26
+ elementId: string;
27
+ /** Document position immediately before the math node (for `setNodeMarkup`). */
28
+ pos: number;
29
+ latex: string;
30
+ display: boolean;
31
+ }
32
+ /** Result of editing an inline-math node, applied back to its text element. */
33
+ export interface ApplyInlineMathPayload {
34
+ elementId: string;
35
+ pos: number;
36
+ latex: string;
37
+ html: string;
38
+ display: boolean;
39
+ }
22
40
  type Events = {
23
41
  [EmitterEvents.RICH_TEXT_COMMAND]: RichTextCommand;
24
42
  [EmitterEvents.TABLE_COMMAND]: TableCommand;
25
43
  [EmitterEvents.SYNC_RICH_TEXT_ATTRS_TO_STORE]: void;
26
44
  [EmitterEvents.OPEN_CHART_DATA_EDITOR]: void;
27
45
  [EmitterEvents.OPEN_LATEX_EDITOR]: void;
46
+ [EmitterEvents.OPEN_INLINE_MATH_EDITOR]: OpenInlineMathPayload;
47
+ [EmitterEvents.APPLY_INLINE_MATH]: ApplyInlineMathPayload;
28
48
  };
29
49
  declare const emitter: Emitter<Events>;
30
50
  export default emitter;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Stub that replaces the real `katex` package at build time.
3
+ *
4
+ * `markdown-it-texmath` contains a static `require('katex')` fallback that the
5
+ * bundler must resolve even though PPTist always passes a MathLive `engine`
6
+ * adapter (see `utils/math.ts`), so that branch is never executed. Aliasing
7
+ * `katex` to this stub (in `vite.config.ts` / `vite.config.embed.ts`) lets us
8
+ * drop the real ~280KB KaTeX dependency while keeping the require resolvable.
9
+ */
10
+ declare function renderToString(): string;
11
+ export { renderToString };
12
+ declare const _default: {
13
+ renderToString: typeof renderToString;
14
+ };
15
+ export default _default;
@@ -25,7 +25,7 @@ export declare function tokenizeMath(source: string): ContentSegment[];
25
25
  export declare function splitLinesPreservingMath(value: string): string[];
26
26
  export declare function markdownToHtml(markdown: string): Promise<string>;
27
27
  /**
28
- * Preload the math-capable markdown parser (lazy KaTeX + texmath) so
28
+ * Preload the math-capable markdown parser (lazy MathLive + texmath) so
29
29
  * `renderInlineMarkdown` can render `$…$` math synchronously afterwards. No-op
30
30
  * once loaded; call before rendering content that may contain math.
31
31
  */
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shared MathLive typesetting helpers.
3
+ *
4
+ * LaTeX is the single source of truth for in-text math. It is carried on a
5
+ * canonical wrapper element:
6
+ *
7
+ * <span class="pptist-math" data-latex="\frac{1}{2}" data-display="false">…markup…</span>
8
+ *
9
+ * The inner markup is MathLive's `convertLatexToMarkup` output, preserved in the
10
+ * stored HTML so the static render paths (`v-html`) and ProseMirror round-trips
11
+ * never need to re-typeset existing content. MathLive itself is lazy-loaded the
12
+ * first time math actually appears (or the editor opens), so decks without math
13
+ * never pull it into the bundle. Static styling comes from `mathlive/static.css`
14
+ * + `mathlive/fonts.css`, imported once at app/embed bootstrap.
15
+ */
16
+ export declare const MATH_CLASS = "pptist-math";
17
+ type ConvertLatexToMarkup = (latex: string, options?: {
18
+ defaultMode?: 'inline-math' | 'math' | 'text';
19
+ }) => string;
20
+ interface MathliveModule {
21
+ convertLatexToMarkup: ConvertLatexToMarkup;
22
+ MathfieldElement: {
23
+ fontsDirectory: string | null;
24
+ soundsDirectory: string | null;
25
+ };
26
+ }
27
+ /**
28
+ * Reactive flag flipped to `true` once MathLive has loaded. Reading it inside a
29
+ * render (e.g. table `formatText`) registers a dependency so the math re-renders
30
+ * the moment the engine becomes available.
31
+ */
32
+ export declare const mathReady: import("vue").Ref<boolean, boolean>;
33
+ /** Lazily import MathLive and configure it for a bundled (offline) font setup. */
34
+ export declare function ensureMathliveReady(): Promise<MathliveModule>;
35
+ /** Escape a string for safe inclusion in a double-quoted HTML attribute. */
36
+ export declare function escapeLatexAttr(latex: string): string;
37
+ /**
38
+ * Render `latex` to the canonical `span.pptist-math` wrapper HTML string. Must
39
+ * only be called once {@link ensureMathliveReady} has resolved (the markdown
40
+ * pipeline and editor await it; tables fall back to literal source until ready).
41
+ */
42
+ export declare function renderMathToHtml(latex: string, display?: boolean): string;
43
+ /**
44
+ * Build a real `span.pptist-math` DOM node for the given latex/markup. Used by
45
+ * the ProseMirror schema `toDOM` so the editor DOM (and the innerHTML persisted
46
+ * on edit) is the same canonical wrapper the parser reads back.
47
+ */
48
+ export declare function buildMathElement(latex: string, html: string, display?: boolean): HTMLSpanElement;
49
+ /** Engine adapter that lets `markdown-it-texmath` typeset via MathLive. */
50
+ export declare const texmathEngine: {
51
+ renderToString(latex: string, options?: {
52
+ displayMode?: boolean;
53
+ }): string;
54
+ };
55
+ /** True when an HTML string already contains rendered/wrapped math. */
56
+ export declare function htmlContainsMath(html: string): boolean;
57
+ export {};
@@ -3,6 +3,7 @@ export declare const schemaNodes: {
3
3
  paragraph: import("prosemirror-model").NodeSpec;
4
4
  blockquote: import("prosemirror-model").NodeSpec;
5
5
  text: import("prosemirror-model").NodeSpec;
6
+ math: import("prosemirror-model").NodeSpec;
6
7
  ordered_list: import("prosemirror-model").NodeSpec;
7
8
  bullet_list: import("prosemirror-model").NodeSpec;
8
9
  list_item: import("prosemirror-model").NodeSpec;
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  paragraph: NodeSpec;
5
5
  blockquote: NodeSpec;
6
6
  text: NodeSpec;
7
+ math: NodeSpec;
7
8
  ordered_list: NodeSpec;
8
9
  bullet_list: NodeSpec;
9
10
  list_item: NodeSpec;
@@ -0,0 +1,76 @@
1
+ /** ProseMirror's default text size (assets/styles/prosemirror.scss). */
2
+ export declare const DEFAULT_TEXT_FONT_SIZE = 16;
3
+ /** Horizontal space a list marker + indent steals from a bullet's text column. */
4
+ export declare const BULLET_INDENT = 28;
5
+ /** A single measurable text block (one paragraph or one list item). */
6
+ export interface TextFitBlock {
7
+ /** Plain text of the block (markers stripped). */
8
+ text: string;
9
+ /** Authored font size in px (its largest run, to stay safe). */
10
+ size: number;
11
+ bold?: boolean;
12
+ italic?: boolean;
13
+ fontFamily: string;
14
+ /** When true, a list marker indent is subtracted from the text column. */
15
+ listItem?: boolean;
16
+ }
17
+ export interface MeasureBlocksOptions {
18
+ /** Box content width in px (insets already removed). */
19
+ innerWidth: number;
20
+ /** Line height multiplier (e.g. 1.5). */
21
+ lineHeight: number;
22
+ /** Vertical gap added between consecutive blocks, in px (NOT scaled by sizeScale). */
23
+ blockSpace?: number;
24
+ /** Indent subtracted from the text column for list items, in px. */
25
+ bulletIndent?: number;
26
+ letterSpacing?: number;
27
+ /** Multiply every block's font size by this factor before measuring (default 1). */
28
+ sizeScale?: number;
29
+ }
30
+ /**
31
+ * Total wrapped height (px) of `blocks` laid out in a column of `innerWidth`,
32
+ * with each block's font size multiplied by `sizeScale`. Each block is measured
33
+ * independently with pretext, then summed with the (unscaled, px-fixed)
34
+ * inter-block gap. Returns 0 for an empty input.
35
+ */
36
+ export declare function measureTextBlocksHeight(blocks: TextFitBlock[], options: MeasureBlocksOptions): number;
37
+ export interface FitFontScaleOptions {
38
+ innerWidth: number;
39
+ innerHeight: number;
40
+ lineHeight: number;
41
+ blockSpace?: number;
42
+ bulletIndent?: number;
43
+ letterSpacing?: number;
44
+ /** Smallest font factor to fall back to before clipping takes over (default 0.1). */
45
+ minScale?: number;
46
+ }
47
+ /**
48
+ * Largest uniform font factor in `[minScale, 1]` at which `blocks` fit
49
+ * `innerHeight`, found by binary search over pretext measurements. The factor
50
+ * multiplies the authored font sizes; because wrapping changes as the type
51
+ * shrinks, this re-measures at each candidate (not a single geometric divide).
52
+ * Returns 1 when content already fits (or measurement isn't possible).
53
+ */
54
+ export declare function fitFontScaleForBlocks(blocks: TextFitBlock[], options: FitFontScaleOptions): number;
55
+ export interface ExtractedContent {
56
+ blocks: TextFitBlock[];
57
+ }
58
+ export interface ExtractOptions {
59
+ defaultFontFamily: string;
60
+ defaultSize?: number;
61
+ }
62
+ /**
63
+ * Parse a PPTist rich-text HTML string into measurable blocks. Each list item
64
+ * and top-level paragraph/quote becomes one block; a block's representative font
65
+ * size is the largest inline size in it (so measurement never under-estimates).
66
+ * Returns no blocks when there's no DOM parser or no text. List items are tagged
67
+ * so the marker indent is accounted for.
68
+ */
69
+ export declare function extractFitBlocksFromHtml(html: string, options: ExtractOptions): ExtractedContent;
70
+ /**
71
+ * Return a copy of `html` with every inline `font-size:Npx` multiplied by
72
+ * `scale` (rounded to 0.1px). Text without an explicit size is untouched here —
73
+ * the renderer scales that through the `--text-fit-base-size` CSS variable. A
74
+ * scale >= 1 (or a non-DOM context) returns the HTML unchanged.
75
+ */
76
+ export declare function scaleHtmlFontSizes(html: string, scale: number): string;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -8,4 +8,14 @@ export declare const getCellStyle: (outline: PPTElementOutline, style?: TableCel
8
8
  * Compute table cell text layout styles from optional cell style.
9
9
  */
10
10
  export declare const getTextStyle: (cellMinHeight: number, style?: TableCellStyle) => CSSProperties;
11
+ /**
12
+ * Render a table cell's stored source for display. Plain text keeps the legacy
13
+ * newline/space escaping; cells whose source contains math (`$…$`, `$$…$$`,
14
+ * `\(…\)`, …) get each formula typeset with MathLive into the canonical
15
+ * `span.pptist-math` wrapper while the surrounding text stays escaped.
16
+ *
17
+ * Reads the reactive {@link mathReady} flag so the cell re-renders the moment
18
+ * MathLive finishes loading (kicked off lazily here on first math encounter);
19
+ * until then math segments fall back to their literal LaTeX source.
20
+ */
11
21
  export declare const formatText: (text: string) => string;
@@ -0,0 +1,22 @@
1
+ import { type CSSProperties, type Ref } from 'vue';
2
+ import type { PPTTextElement } from '../../../../types/slides';
3
+ /**
4
+ * Auto-fit a fixed-size text box so its content never overflows — by computing a
5
+ * real font size with pretext, not a CSS transform.
6
+ *
7
+ * Only fixed-height (`fixedHeight`) boxes are constrained; normal boxes grow to
8
+ * fit. We measure the wrapped content with pretext (the same engine the agentic
9
+ * layout builder uses) and binary-search the largest uniform font factor at which
10
+ * it still fits. The renderer then applies that factor as actual font sizes:
11
+ * - text with an explicit inline size renders from `fittedContent` (sizes
12
+ * rewritten to `size * factor`);
13
+ * - text using the default size shrinks via the `--text-fit-base-size` CSS
14
+ * variable (the computed px value), since `.ProseMirror` hardcodes 16px.
15
+ * Vertical (top-to-bottom) text is left untouched.
16
+ */
17
+ declare const _default: (elementInfo: Ref<PPTTextElement>) => {
18
+ fitScale: Ref<number, number>;
19
+ fittedContent: import("vue").ComputedRef<string>;
20
+ fitVars: import("vue").ComputedRef<CSSProperties>;
21
+ };
22
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/pptist",
3
- "version": "2.0.20",
3
+ "version": "2.0.22",
4
4
  "description": "PPTist presentation editor embed bundle with a typed agentic bridge.",
5
5
  "type": "module",
6
6
  "main": "dist/embed/pptist-embed.js",
@@ -75,10 +75,10 @@
75
75
  "hfmath": "^0.0.2",
76
76
  "html-to-image": "^1.11.13",
77
77
  "jsonrepair": "^3.13.2",
78
- "katex": "^0.17.0",
79
78
  "lodash": "^4.17.21",
80
79
  "markdown-it": "^14.2.0",
81
80
  "markdown-it-texmath": "^1.0.0",
81
+ "mathlive": "^0.110.0",
82
82
  "mitt": "^3.0.1",
83
83
  "nanoid": "^5.0.7",
84
84
  "number-precision": "^1.6.0",