fika-editor 3.6.12 → 3.6.14

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.
@@ -4,7 +4,10 @@ import { math } from 'micromark-extension-llm-math';
4
4
  import { decodeHTML } from 'entities';
5
5
  import MarkdownIt from 'markdown-it';
6
6
  import texmath from 'markdown-it-texmath';
7
- const parseOptions = { extensions: [math()], mdastExtensions: [mathFromMarkdown()] };
7
+ import { inlineDollarEnd } from './inlineDollar.js';
8
+ const mathSyntax = math();
9
+ const dollar = mathSyntax.text[36];
10
+ const mdastExtensions = [mathFromMarkdown()];
8
11
  // Preserve the existing Fika support for bare TeX environments. This parser is
9
12
  // only used for that uncommon syntax; CommonMark code fences still take priority.
10
13
  const environmentParser = new MarkdownIt({ html: false }).use(texmath, {
@@ -28,7 +31,19 @@ function parserInput(source) {
28
31
  }
29
32
  return out.join('');
30
33
  }
31
- const parseGeneratedMarkdown = (source) => fromMarkdown(parserInput(source), parseOptions);
34
+ function parseGeneratedMarkdown(source) {
35
+ const singleOrDisplay = {
36
+ ...dollar,
37
+ tokenize(effects, ok, nok) {
38
+ const start = this.now().offset;
39
+ if (source[start + 1] !== '$' && inlineDollarEnd(source, start) < 0)
40
+ return nok;
41
+ return dollar.tokenize.call(this, effects, ok, nok);
42
+ },
43
+ };
44
+ const extension = { ...mathSyntax, text: { ...mathSyntax.text, 36: singleOrDisplay } };
45
+ return fromMarkdown(parserInput(source), { extensions: [extension], mdastExtensions });
46
+ }
32
47
  function environmentSpans(source) {
33
48
  if (!source.includes('\\begin{'))
34
49
  return [];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The nearest unescaped dollar on the same line must be a closer. Never
3
+ * search past a price or the start of a second formula for a later closer.
4
+ * Digits can start a formula ($2+2$), but cannot follow its closing delimiter.
5
+ */
6
+ export declare function inlineDollarEnd(source: string, start: number): number;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The nearest unescaped dollar on the same line must be a closer. Never
3
+ * search past a price or the start of a second formula for a later closer.
4
+ * Digits can start a formula ($2+2$), but cannot follow its closing delimiter.
5
+ */
6
+ export function inlineDollarEnd(source, start) {
7
+ const first = source[start + 1];
8
+ if (!first || first === '$' || /\s/.test(first))
9
+ return -1;
10
+ for (let i = start + 1; i < source.length; i++) {
11
+ const char = source[i];
12
+ if (char === '\n' || char === '\r')
13
+ return -1;
14
+ if (char === '\\' && (source[i + 1] === '$' || source[i + 1] === '\\')) {
15
+ i++;
16
+ continue;
17
+ }
18
+ if (char !== '$')
19
+ continue;
20
+ const before = source[i - 1];
21
+ const after = source[i + 1] || '';
22
+ if (/\s/.test(before) || after === '$' || /\d/.test(after))
23
+ return -1;
24
+ if (after === '.' && /\d/.test(source[i + 2] || ''))
25
+ return -1;
26
+ // An opening parenthesis, backtick, etc. before $x makes it a new opener.
27
+ if (/[\p{P}\p{S}]/u.test(before) && /\p{L}/u.test(after))
28
+ return -1;
29
+ return i + 1;
30
+ }
31
+ return -1;
32
+ }
@@ -90,6 +90,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
90
90
  setState(nextStateOrUpdater: Partial<SlidesStore> | ((state: {
91
91
  title: string;
92
92
  theme: {
93
+ headingFontName?: string;
93
94
  headingFontColor?: string;
94
95
  backgroundColor: string;
95
96
  themeColors: string[];
@@ -350,6 +351,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
350
351
  };
351
352
  };
352
353
  type: 'image';
354
+ altText?: string;
353
355
  fixedRatio: boolean;
354
356
  src: string;
355
357
  outline?: {
@@ -1198,6 +1200,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
1198
1200
  };
1199
1201
  };
1200
1202
  type: 'image';
1203
+ altText?: string;
1201
1204
  fixedRatio: boolean;
1202
1205
  src: string;
1203
1206
  outline?: {
@@ -1788,6 +1791,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
1788
1791
  skeleton?: boolean;
1789
1792
  }[];
1790
1793
  theme: {
1794
+ headingFontName?: string;
1791
1795
  headingFontColor?: string;
1792
1796
  backgroundColor?: string;
1793
1797
  themeColors?: string[];
@@ -1852,6 +1856,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
1852
1856
  setState(nextStateOrUpdater: ((state: {
1853
1857
  title: string;
1854
1858
  theme: {
1859
+ headingFontName?: string;
1855
1860
  headingFontColor?: string;
1856
1861
  backgroundColor: string;
1857
1862
  themeColors: string[];
@@ -2112,6 +2117,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
2112
2117
  };
2113
2118
  };
2114
2119
  type: 'image';
2120
+ altText?: string;
2115
2121
  fixedRatio: boolean;
2116
2122
  src: string;
2117
2123
  outline?: {
@@ -2960,6 +2966,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
2960
2966
  };
2961
2967
  };
2962
2968
  type: 'image';
2969
+ altText?: string;
2963
2970
  fixedRatio: boolean;
2964
2971
  src: string;
2965
2972
  outline?: {
@@ -3550,6 +3557,7 @@ export declare const useSlidesStore: import("zustand").UseBoundStore<Omit<import
3550
3557
  skeleton?: boolean;
3551
3558
  }[];
3552
3559
  theme: {
3560
+ headingFontName?: string;
3553
3561
  headingFontColor?: string;
3554
3562
  backgroundColor?: string;
3555
3563
  themeColors?: string[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The nearest unescaped dollar on the same line must be a closer. Never
3
+ * search past a price or the start of a second formula for a later closer.
4
+ * Digits can start a formula ($2+2$), but cannot follow its closing delimiter.
5
+ */
6
+ export declare function inlineDollarEnd(source: string, start: number): number;
@@ -257,6 +257,8 @@ export type ImageType = 'pageFigure' | 'itemFigure' | 'background';
257
257
  */
258
258
  export interface PPTImageElement extends PPTBaseElement {
259
259
  type: 'image';
260
+ /** A description of the picture for assistive technology and PowerPoint export. */
261
+ altText?: string;
260
262
  fixedRatio: boolean;
261
263
  src: string;
262
264
  outline?: PPTElementOutline;
@@ -634,6 +636,8 @@ export interface Slide {
634
636
  * Slide theme (background, accent colors, default font).
635
637
  */
636
638
  export interface SlideTheme {
639
+ /** Display face used for the PowerPoint theme's major Latin font. Defaults to fontName. */
640
+ headingFontName?: string;
637
641
  /** Optional ink for title and item-title text when generating more slides. */
638
642
  headingFontColor?: string;
639
643
  backgroundColor: string;
@@ -178,6 +178,7 @@ export declare const rotateRectLikeElement: (element: Exclude<PPTElement, PPTLin
178
178
  source?: import("../types/slides").ElementSource;
179
179
  effects?: import("../types/slides").PPTElementEffects;
180
180
  type: 'image';
181
+ altText?: string;
181
182
  fixedRatio: boolean;
182
183
  src: string;
183
184
  outline?: import("../types/slides").PPTElementOutline;
@@ -6,6 +6,6 @@
6
6
  */
7
7
  export declare const convertOmmlMathSpans: (doc: Document) => void;
8
8
  /** Typeset leftover TeX source with MathLive — any control word, not a command list. */
9
- export declare const convertBareLatexBlocks: (doc: Document) => void;
9
+ export declare const convertBareLatexBlocks: (doc: Document) => boolean;
10
10
  /** Import-time and paint-time: OMML spans + leftover TeX source → fika-math. */
11
11
  export declare function typesetImportedTex(html: string): string;
@@ -0,0 +1,5 @@
1
+ import type { Slide } from '../types/slides';
2
+ /** Copy a batch together so links between its pages follow the new pages. */
3
+ export declare function instantiateTemplateSlides(source: Slide[], { preserveExternalSlideLinks }?: {
4
+ preserveExternalSlideLinks?: boolean;
5
+ }): Slide[];
@@ -1,10 +1,11 @@
1
1
  import { markdownMathSegments, normalizeGeneratedMarkdown } from '../text/index';
2
2
  /** True when a string carries math delimiters the math parser should handle. */
3
3
  export declare function containsMath(source: string): boolean;
4
- /** Delimited math or any TeX control sequence in the source. */
4
+ /** Cheap prefilter for HTML. Delimiter boundaries are resolved on individual text nodes. */
5
+ export declare function mayContainTexSource(source: string): boolean;
5
6
  export declare function containsTexSource(source: string): boolean;
6
7
  /** The whole string is a TeX formula MathLive can typeset as-is. */
7
- export declare function isTexFormulaSource(source: string): boolean;
8
+ export declare function isTexFormulaSource(source: string, segments?: import("../text/index").MarkdownMathSegment[]): boolean;
8
9
  /**
9
10
  * A run of either plain text or a single math span, in source order. `raw` is
10
11
  * the exact source slice (delimiters included for math); `value` is the inner
@@ -12,6 +12,15 @@ export declare const schemaNodes: {
12
12
  export declare const schemaMarks: {
13
13
  em: import("prosemirror-model").MarkSpec;
14
14
  strong: import("prosemirror-model").MarkSpec;
15
+ literalDollar: {
16
+ inclusive: false;
17
+ parseDOM: {
18
+ tag: string;
19
+ }[];
20
+ toDOM: () => [string, {
21
+ 'data-literal-dollar': string;
22
+ }, number];
23
+ };
15
24
  fontsize: import("prosemirror-model").MarkSpec;
16
25
  fontname: import("prosemirror-model").MarkSpec;
17
26
  code: import("prosemirror-model").MarkSpec;
@@ -2,6 +2,15 @@ import type { MarkSpec } from 'prosemirror-model';
2
2
  declare const _default: {
3
3
  em: MarkSpec;
4
4
  strong: MarkSpec;
5
+ literalDollar: {
6
+ inclusive: false;
7
+ parseDOM: {
8
+ tag: string;
9
+ }[];
10
+ toDOM: () => [string, {
11
+ 'data-literal-dollar': string;
12
+ }, number];
13
+ };
5
14
  fontsize: MarkSpec;
6
15
  fontname: MarkSpec;
7
16
  code: MarkSpec;
@@ -1,7 +1,7 @@
1
1
  import { Schema, type Node as PMNode } from 'prosemirror-model';
2
2
  import { EditorState, type Transaction } from 'prosemirror-state';
3
3
  import type { TableCell, TableCellStyle } from '../../types/slides';
4
- export declare const tableSchema: Schema<"doc" | "hard_break" | "math" | "paragraph" | "text", "code" | "em" | "fontname" | "fontsize" | "forecolor" | "link" | "strikethrough" | "strong" | "subscript" | "superscript" | "underline">;
4
+ export declare const tableSchema: Schema<"doc" | "hard_break" | "math" | "paragraph" | "text", "code" | "em" | "fontname" | "fontsize" | "forecolor" | "link" | "literalDollar" | "strikethrough" | "strong" | "subscript" | "superscript" | "underline">;
5
5
  export declare const plainTextToTableHTML: (text: string) => string;
6
6
  declare const markNames: {
7
7
  readonly bold: 'strong';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fika-editor",
3
- "version": "3.6.12",
3
+ "version": "3.6.14",
4
4
  "description": "Fika presentation editor embed bundle with a typed agentic bridge.",
5
5
  "type": "module",
6
6
  "main": "dist/embed/fika-embed.js",