myrole-docx-editor 0.1.2 → 0.1.3
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 +81 -8
- package/dist/chunks/sdk-BKmEus_j.js +29652 -0
- package/dist/chunks/sdk-BKmEus_j.js.map +1 -0
- package/dist/chunks/{vars-blockly-C-0oL-Mc.js → vars-blockly-DMblR7c7.js} +2 -2
- package/dist/chunks/{vars-blockly-C-0oL-Mc.js.map → vars-blockly-DMblR7c7.js.map} +1 -1
- package/dist/index.js +8 -7
- package/dist/react.js +44 -28
- package/dist/react.js.map +1 -1
- package/dist/types/packages/docx-editor/src/chrome.d.ts +11 -0
- package/dist/types/packages/docx-editor/src/commands.d.ts +8 -1
- package/dist/types/packages/docx-editor/src/drafts.d.ts +7 -0
- package/dist/types/packages/docx-editor/src/editor.d.ts +17 -3
- package/dist/types/packages/docx-editor/src/feedback.d.ts +73 -0
- package/dist/types/packages/docx-editor/src/index.d.ts +5 -0
- package/dist/types/packages/docx-editor/src/inspector-ui.d.ts +2 -2
- package/dist/types/packages/docx-editor/src/react.d.ts +2 -0
- package/dist/types/packages/docx-editor/src/ruler.d.ts +1 -0
- package/dist/types/packages/docx-editor/src/sdk.d.ts +37 -8
- package/dist/types/packages/docx-editor/src/ui/context-menu.d.ts +4 -0
- package/dist/types/packages/docx-editor/src/ui/panels.d.ts +13 -0
- package/dist/types/packages/docx-editor/src/ui/popover.d.ts +4 -0
- package/dist/types/packages/docx-editor/src/ui/shell.d.ts +10 -1
- package/dist/types/packages/docx-editor/src/variables.d.ts +7 -0
- package/dist/types/packages/docx-editor/src/vars-complete.d.ts +4 -1
- package/dist/types/packages/docx-editor/src/vars-library.d.ts +2 -2
- package/dist/types/packages/docx-editor/src/vars-panel.d.ts +4 -0
- package/dist/types/packages/docx-model/src/editor.d.ts +21 -1
- package/dist/types/packages/docx-model/src/layout.d.ts +9 -0
- package/dist/types/packages/docx-model/src/textbox.d.ts +2 -0
- package/dist/types/packages/docx-render/src/hyphenation.d.ts +9 -0
- package/dist/types/packages/docx-render/src/text.d.ts +7 -0
- package/dist/types/packages/docx-render/src/types.d.ts +3 -0
- package/package.json +4 -4
- package/dist/chunks/sdk-CxT1eC2o.js +0 -16294
- package/dist/chunks/sdk-CxT1eC2o.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as s from "blockly";
|
|
2
|
-
import {
|
|
2
|
+
import { k as p, T as u, m, n as f, o as g, q as h } from "./sdk-BKmEus_j.js";
|
|
3
3
|
let r = !1;
|
|
4
4
|
function b(o, n, i) {
|
|
5
5
|
r || (p(), r = !0), o.replaceChildren();
|
|
@@ -39,4 +39,4 @@ function b(o, n, i) {
|
|
|
39
39
|
export {
|
|
40
40
|
b as mountBlockly
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=vars-blockly-
|
|
42
|
+
//# sourceMappingURL=vars-blockly-DMblR7c7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vars-blockly-
|
|
1
|
+
{"version":3,"file":"vars-blockly-DMblR7c7.js","sources":["../../src/vars-blockly.ts"],"sourcesContent":["import * as Blockly from 'blockly'\nimport {\n decorate, defineBlocks, fieldLibrary, setFields, THEME, TOOLBOX,\n type BlockJson,\n} from '@myrole/docx-vars'\nimport type { Tag } from '@myrole/docx-tags'\n\n/**\n * Le mode Blockly, chargé à la demande.\n *\n * Le canvas ne se replie pas — c'est ce qui a fait choisir le rendu DOM par\n * défaut — mais il sait ce que le DOM ne fait pas encore aussi bien :\n * restructurer librement une expression au glisser-déposer, avec sa poubelle,\n * son annulation et ses connexions typées.\n *\n * Il vit dans son propre module pour ne peser que si on l'ouvre : un\n * mégaoctet et demi qu'un utilisateur qui ne bascule jamais ne télécharge pas.\n */\n\nlet defined = false\n\nexport interface BlocklyView {\n load(tree: BlockJson): void\n read(): BlockJson | null\n resize(): void\n dispose(): void\n}\n\nexport function mountBlockly(\n holder: HTMLElement, onChange: () => void, tags: () => Tag[],\n): BlocklyView {\n if (!defined) { defineBlocks(); defined = true }\n holder.replaceChildren()\n const host = document.createElement('div')\n host.className = 'vp-canvas-host'\n holder.append(host)\n\n const ws = Blockly.inject(host, {\n // La boîte à outils : sans elle, on peut lire une expression et la\n // rebrancher, mais pas y AJOUTER quoi que ce soit — c'est la moitié de ce\n // qu'on vient chercher dans un canvas de blocs.\n toolbox: TOOLBOX,\n theme: THEME,\n renderer: 'geras',\n trashcan: true,\n sounds: false,\n grid: { spacing: 20, length: 1, colour: '#e8e9ed', snap: false },\n zoom: { controls: true, wheel: true, startScale: 0.95, minScale: 0.3, maxScale: 2 },\n move: { scrollbars: true, drag: true, wheel: true },\n })\n ws.addChangeListener((e) => { if (!e.isUiEvent) onChange() })\n\n return {\n load(tree) {\n // `setFields` alimente le sélecteur du bloc « champ » : sans lui, un clic\n // sur un champ n'ouvre rien.\n const groups = fieldLibrary(tags())\n setFields(groups.flatMap((g) => g.fields.map((f) => ({ path: f.path, label: f.label }))))\n Blockly.serialization.workspaces.load({ blocks: { languageVersion: 0, blocks: [tree] } }, ws)\n decorate(ws)\n Blockly.svgResize(ws)\n },\n read() {\n const state = Blockly.serialization.workspaces.save(ws) as {\n blocks?: { blocks?: BlockJson[] }\n }\n return state?.blocks?.blocks?.[0] ?? null\n },\n resize() { Blockly.svgResize(ws) },\n dispose() { ws.dispose() },\n }\n}\n"],"names":["defined","mountBlockly","holder","onChange","tags","defineBlocks","host","ws","Blockly","TOOLBOX","THEME","e","tree","groups","fieldLibrary","setFields","g","f","decorate"],"mappings":";;AAmBA,IAAIA,IAAU;AASP,SAASC,EACdC,GAAqBC,GAAsBC,GAC9B;AACb,EAAKJ,MAAWK,EAAA,GAAgBL,IAAU,KAC1CE,EAAO,gBAAA;AACP,QAAMI,IAAO,SAAS,cAAc,KAAK;AACzC,EAAAA,EAAK,YAAY,kBACjBJ,EAAO,OAAOI,CAAI;AAElB,QAAMC,IAAKC,EAAQ,OAAOF,GAAM;AAAA;AAAA;AAAA;AAAA,IAI9B,SAASG;AAAA,IACT,OAAOC;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM,EAAE,SAAS,IAAI,QAAQ,GAAG,QAAQ,WAAW,MAAM,GAAA;AAAA,IACzD,MAAM,EAAE,UAAU,IAAM,OAAO,IAAM,YAAY,MAAM,UAAU,KAAK,UAAU,EAAA;AAAA,IAChF,MAAM,EAAE,YAAY,IAAM,MAAM,IAAM,OAAO,GAAA;AAAA,EAAK,CACnD;AACD,SAAAH,EAAG,kBAAkB,CAACI,MAAM;AAAE,IAAKA,EAAE,aAAWR,EAAA;AAAA,EAAW,CAAC,GAErD;AAAA,IACL,KAAKS,GAAM;AAGT,YAAMC,IAASC,EAAaV,GAAM;AAClC,MAAAW,EAAUF,EAAO,QAAQ,CAACG,MAAMA,EAAE,OAAO,IAAI,CAACC,OAAO,EAAE,MAAMA,EAAE,MAAM,OAAOA,EAAE,MAAA,EAAQ,CAAC,CAAC,GACxFT,EAAQ,cAAc,WAAW,KAAK,EAAE,QAAQ,EAAE,iBAAiB,GAAG,QAAQ,CAACI,CAAI,EAAA,EAAE,GAAKL,CAAE,GAC5FW,EAASX,CAAE,GACXC,EAAQ,UAAUD,CAAE;AAAA,IACtB;AAAA,IACA,OAAO;AAIL,aAHcC,EAAQ,cAAc,WAAW,KAAKD,CAAE,GAGxC,QAAQ,SAAS,CAAC,KAAK;AAAA,IACvC;AAAA,IACA,SAAS;AAAE,MAAAC,EAAQ,UAAUD,CAAE;AAAA,IAAE;AAAA,IACjC,UAAU;AAAE,MAAAA,EAAG,QAAA;AAAA,IAAU;AAAA,EAAA;AAE7B;"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { i as f, r as m, e as
|
|
2
|
-
import { d as
|
|
1
|
+
import { i as f, r as m, e as w, f as p, p as u, l as y, a as g, b as h, c as x } from "./chunks/sdk-BKmEus_j.js";
|
|
2
|
+
import { d as R, g as b, h as U, j, s as A } from "./chunks/sdk-BKmEus_j.js";
|
|
3
3
|
async function P(a, o, r = {}) {
|
|
4
4
|
const i = performance.now(), [c] = await Promise.all([
|
|
5
5
|
typeof a == "string" ? fetch(a).then((e) => e.ok ? e.arrayBuffer() : Promise.reject(new Error(`${e.status} ${a}`))) : Promise.resolve(a),
|
|
6
6
|
f(r.fontsUrl)
|
|
7
7
|
]), t = m(new Uint8Array(c));
|
|
8
|
-
for (const e of
|
|
8
|
+
for (const e of w(t))
|
|
9
9
|
try {
|
|
10
|
-
const s =
|
|
10
|
+
const s = p(e), n = new FontFace(s.family, e.data, { weight: s.weight, style: s.style });
|
|
11
11
|
await n.load(), document.fonts.add(n);
|
|
12
12
|
} catch {
|
|
13
13
|
}
|
|
@@ -22,9 +22,10 @@ async function P(a, o, r = {}) {
|
|
|
22
22
|
}), { pages: [...o.querySelectorAll("canvas")], ms: Math.round(performance.now() - i) };
|
|
23
23
|
}
|
|
24
24
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
U as
|
|
25
|
+
R as createDocxEditor,
|
|
26
|
+
b as createDocxViewer,
|
|
27
|
+
U as defaultFontsUrl,
|
|
28
|
+
j as evaluateTags,
|
|
28
29
|
f as installFonts,
|
|
29
30
|
P as renderDocx,
|
|
30
31
|
A as sampleValues
|
package/dist/react.js
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { d as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
typeof
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as v, useRef as f, useEffect as n } from "react";
|
|
3
|
+
import { d as S } from "./chunks/sdk-BKmEus_j.js";
|
|
4
|
+
const s = v(function({ src: u, className: o, style: g, onReady: y, ...e }, d) {
|
|
5
|
+
const l = f(null), c = f(null), t = f(e);
|
|
6
|
+
t.current = e;
|
|
7
|
+
const m = (r) => {
|
|
8
|
+
typeof d == "function" ? d(r) : d && (d.current = r);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
...
|
|
13
|
-
onSave: (
|
|
14
|
-
|
|
10
|
+
return n(() => {
|
|
11
|
+
const r = S(l.current, {
|
|
12
|
+
...e,
|
|
13
|
+
onSave: e.onSave ? (a) => t.current.onSave(a) : void 0,
|
|
14
|
+
onError: (a) => t.current.onError?.(a),
|
|
15
|
+
onSaveState: (a) => t.current.onSaveState?.(a),
|
|
16
|
+
onChange: () => t.current.onChange?.(),
|
|
17
|
+
feedback: typeof e.feedback == "object" ? {
|
|
18
|
+
...e.feedback,
|
|
19
|
+
onSubmit: e.feedback.onSubmit ? (a) => {
|
|
20
|
+
const b = t.current.feedback;
|
|
21
|
+
if (typeof b != "object" || !b.onSubmit) throw new Error("Feedback submission handler is no longer configured");
|
|
22
|
+
return b.onSubmit(a);
|
|
23
|
+
} : void 0
|
|
24
|
+
} : e.feedback
|
|
15
25
|
});
|
|
16
|
-
return
|
|
17
|
-
|
|
26
|
+
return c.current = r, m(r), y?.(r), () => {
|
|
27
|
+
r.destroy(), c.current = null, m(null);
|
|
18
28
|
};
|
|
19
|
-
}, [])
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, [
|
|
29
|
+
}, [e.draftKey, e.chrome, !!e.onSave]), n(() => {
|
|
30
|
+
u && c.current && c.current.load(u).catch((r) => t.current.onError?.(r));
|
|
31
|
+
}, [u, e.draftKey, e.chrome, !!e.onSave]), n(() => {
|
|
32
|
+
e.theme && c.current?.setTheme(e.theme);
|
|
33
|
+
}, [e.theme]), n(() => {
|
|
34
|
+
c.current?.setReadOnly(e.readOnly ?? !1);
|
|
35
|
+
}, [e.readOnly]), n(() => {
|
|
36
|
+
e.zoom !== void 0 && c.current?.setZoom(e.zoom);
|
|
37
|
+
}, [e.zoom]), n(() => {
|
|
38
|
+
e.badges !== void 0 && c.current?.variables.setDisplay(e.badges);
|
|
39
|
+
}, [typeof e.badges == "boolean" ? e.badges : e.badges?.variables, typeof e.badges == "boolean" ? e.badges : e.badges?.expressions]), /* @__PURE__ */ h("div", { ref: l, className: o, style: { height: "100%", minHeight: 320, minWidth: 0, ...g } });
|
|
28
40
|
});
|
|
29
|
-
function
|
|
30
|
-
return
|
|
41
|
+
function D() {
|
|
42
|
+
return f(null);
|
|
31
43
|
}
|
|
44
|
+
const w = v(function(u, o) {
|
|
45
|
+
return /* @__PURE__ */ h(s, { ...u, ref: o, chrome: "viewer", readOnly: !0 });
|
|
46
|
+
});
|
|
32
47
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
s as DocxEditor,
|
|
49
|
+
w as DocxViewer,
|
|
50
|
+
D as useDocxEditor
|
|
35
51
|
};
|
|
36
52
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sources":["../src/react.tsx"],"sourcesContent":["/**\n * The React face of the SDK.\n *\n * <DocxEditor src={file} onSave={(bytes) => upload(bytes)} style={{ height: '100vh' }} />\n *\n * The component owns one `createDocxEditor` for its lifetime; `src` changes\n * reload the document in place, every other option is read at mount. React is\n * an optional peer: nothing here runs unless `myrole-docx-editor/react` is\n * imported.\n */\nimport { useEffect, useRef, forwardRef, type CSSProperties } from 'react'\nimport { createDocxEditor, type DocxEditorHandle, type DocxEditorOptions } from './sdk'\n\nexport interface DocxEditorProps extends Omit<DocxEditorOptions, 'onReady'> {\n /** the document: bytes, a Blob/File, or a URL */\n src?: ArrayBuffer | Uint8Array | Blob | string\n className?: string\n style?: CSSProperties\n /** the handle, once mounted */\n onReady?: (editor: DocxEditorHandle) => void\n}\n\nexport const DocxEditor = forwardRef<DocxEditorHandle | null, DocxEditorProps>(function DocxEditor(\n { src, className, style, onReady, ...options }, ref,\n) {\n const host = useRef<HTMLDivElement>(null)\n const handle = useRef<DocxEditorHandle | null>(null)\n // The latest callbacks, without remounting the editor when they change.\n const latest = useRef(options)\n latest.current = options\n\n // The forwarded ref is filled HERE, not by useImperativeHandle: that one\n // runs in the layout phase, before this effect has created anything, and\n // would hand the parent a null for the component's whole life.\n const give = (h: DocxEditorHandle | null) => {\n if (typeof ref === 'function') ref(h)\n else if (ref) ref.current = h\n }\n\n useEffect(() => {\n const h = createDocxEditor(host.current!, {\n ...options,\n onSave: (b) => latest.current.onSave
|
|
1
|
+
{"version":3,"file":"react.js","sources":["../src/react.tsx"],"sourcesContent":["/**\n * The React face of the SDK.\n *\n * <DocxEditor src={file} onSave={(bytes) => upload(bytes)} style={{ height: '100vh' }} />\n *\n * The component owns one `createDocxEditor` for its lifetime; `src` changes\n * reload the document in place, every other option is read at mount. React is\n * an optional peer: nothing here runs unless `myrole-docx-editor/react` is\n * imported.\n */\nimport { useEffect, useRef, forwardRef, type CSSProperties } from 'react'\nimport { createDocxEditor, type DocxEditorHandle, type DocxEditorOptions } from './sdk'\n\nexport interface DocxEditorProps extends Omit<DocxEditorOptions, 'onReady'> {\n /** the document: bytes, a Blob/File, or a URL */\n src?: ArrayBuffer | Uint8Array | Blob | string\n className?: string\n style?: CSSProperties\n /** the handle, once mounted */\n onReady?: (editor: DocxEditorHandle) => void\n}\n\nexport const DocxEditor = forwardRef<DocxEditorHandle | null, DocxEditorProps>(function DocxEditor(\n { src, className, style, onReady, ...options }, ref,\n) {\n const host = useRef<HTMLDivElement>(null)\n const handle = useRef<DocxEditorHandle | null>(null)\n // The latest callbacks, without remounting the editor when they change.\n const latest = useRef(options)\n latest.current = options\n\n // The forwarded ref is filled HERE, not by useImperativeHandle: that one\n // runs in the layout phase, before this effect has created anything, and\n // would hand the parent a null for the component's whole life.\n const give = (h: DocxEditorHandle | null) => {\n if (typeof ref === 'function') ref(h)\n else if (ref) ref.current = h\n }\n\n useEffect(() => {\n const h = createDocxEditor(host.current!, {\n ...options,\n onSave: options.onSave ? (b) => latest.current.onSave!(b) : undefined,\n onError: e => latest.current.onError?.(e),\n onSaveState: state => latest.current.onSaveState?.(state),\n onChange: () => latest.current.onChange?.(),\n feedback: typeof options.feedback === 'object' ? {\n ...options.feedback,\n onSubmit: options.feedback.onSubmit ? report => {\n const feedback = latest.current.feedback\n if (typeof feedback !== 'object' || !feedback.onSubmit) throw new Error('Feedback submission handler is no longer configured')\n return feedback.onSubmit(report)\n } : undefined,\n } : options.feedback,\n })\n handle.current = h\n give(h)\n onReady?.(h)\n return () => { h.destroy(); handle.current = null; give(null) }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [options.draftKey, options.chrome, !!options.onSave])\n\n useEffect(() => {\n if (src && handle.current) void handle.current.load(src).catch(e => latest.current.onError?.(e))\n }, [src, options.draftKey, options.chrome, !!options.onSave])\n useEffect(() => { if (options.theme) handle.current?.setTheme(options.theme) }, [options.theme])\n useEffect(() => { handle.current?.setReadOnly(options.readOnly ?? false) }, [options.readOnly])\n useEffect(() => { if (options.zoom !== undefined) handle.current?.setZoom(options.zoom) }, [options.zoom])\n useEffect(() => { if (options.badges !== undefined) handle.current?.variables.setDisplay(options.badges) }, [typeof options.badges === 'boolean' ? options.badges : options.badges?.variables, typeof options.badges === 'boolean' ? options.badges : options.badges?.expressions])\n\n return <div ref={host} className={className} style={{ height: '100%', minHeight: 320, minWidth: 0, ...style }} />\n})\n\n/** A ref to hand to `<DocxEditor ref={…}>`, and the handle once it exists. */\nexport function useDocxEditor() {\n return useRef<DocxEditorHandle | null>(null)\n}\n\nexport type { DocxEditorHandle, DocxEditorOptions } from './sdk'\n\n/** Read-only companion, with the same rendering and lifecycle as the editor. */\nexport const DocxViewer = forwardRef<DocxEditorHandle | null, DocxEditorProps>(function DocxViewer(props, ref) {\n return <DocxEditor {...props} ref={ref} chrome=\"viewer\" readOnly />\n})\n"],"names":["DocxEditor","forwardRef","src","className","style","onReady","options","ref","host","useRef","handle","latest","give","h","useEffect","createDocxEditor","b","e","state","report","feedback","jsx","useDocxEditor","DocxViewer","props"],"mappings":"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"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { EditContext } from '../../docx-model/src/index';
|
|
2
2
|
import type { Editor } from './editor';
|
|
3
3
|
import type { Shell } from './ui/shell';
|
|
4
|
+
import type { Panel } from './ui/shell';
|
|
5
|
+
import type { BadgeDisplay } from './variables';
|
|
4
6
|
export interface ChromeHost {
|
|
5
7
|
shell: Shell;
|
|
8
|
+
showPanel(p: Panel | null): void;
|
|
9
|
+
refreshInspector(): void;
|
|
10
|
+
find(): void;
|
|
11
|
+
library(): void;
|
|
12
|
+
fitZoom(mode: 'width' | 'page'): void;
|
|
13
|
+
badges: {
|
|
14
|
+
get(): BadgeDisplay;
|
|
15
|
+
set(v: Partial<BadgeDisplay>): void;
|
|
16
|
+
};
|
|
6
17
|
zoom: {
|
|
7
18
|
get(): number;
|
|
8
19
|
set(z: number): void;
|
|
@@ -13,4 +13,11 @@ export declare const FONTS: string[];
|
|
|
13
13
|
export declare const SIZES: number[];
|
|
14
14
|
/** Quatre traits, décalés selon l'alignement — l'icône de Word, en SVG. */
|
|
15
15
|
export declare function alignIcon(align: string): SVGElement;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Insere une variable au curseur, choisie dans la bibliotheque du document.
|
|
18
|
+
*
|
|
19
|
+
* Les champs viennent de ce que la matrice utilise DEJA — la seule source qui
|
|
20
|
+
* ne se perime pas, et elle couvre l'immense majorite des besoins : sur le
|
|
21
|
+
* corpus, presque toutes les variables sont des acces de champ simples.
|
|
22
|
+
*/
|
|
23
|
+
export declare function builtinCommands(openLibrary: () => void): Command[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Explicitly keyed by the host: never mix documents or silently enable local retention. */
|
|
2
|
+
export interface Draft {
|
|
3
|
+
bytes: Uint8Array;
|
|
4
|
+
name: string;
|
|
5
|
+
updatedAt: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function draftStore(key: string, value?: Draft | null): Promise<Draft | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MarginPatch, type DocViews, type DocxDocument, type DocPos, type EditContext, type PageSetup, type PageSetupPatch, type ParaPatch, type RunPatch } from '../../docx-model/src/index';
|
|
1
|
+
import { type CellPatch, type MarginPatch, type DocViews, type DocxDocument, type DocPos, type EditContext, type PageSetup, type PageSetupPatch, type ParaPatch, type RunPatch } from '../../docx-model/src/index';
|
|
2
2
|
import { type ImageRect, type LineTrace, type MarkRect, type ResumeState, type SelRect, type TableRect } from '../../docx-render/src/index';
|
|
3
3
|
export interface EditorHooks {
|
|
4
4
|
/** appelé après chaque composition, avec ce qu'il faut pour la barre d'outils */
|
|
@@ -48,6 +48,8 @@ export interface EditorSetup {
|
|
|
48
48
|
* on ne fait pas semblant d'avoir réussi.
|
|
49
49
|
*/
|
|
50
50
|
persist?(bytes: Uint8Array): void | Promise<void>;
|
|
51
|
+
saveDelay?: number;
|
|
52
|
+
saveLabel?: string;
|
|
51
53
|
hooks?: EditorHooks;
|
|
52
54
|
}
|
|
53
55
|
export declare function createEditor(setup: EditorSetup): {
|
|
@@ -159,15 +161,22 @@ export declare function createEditor(setup: EditorSetup): {
|
|
|
159
161
|
} | null;
|
|
160
162
|
/** Pose la sélection. Une seule adresse donne un simple curseur. */
|
|
161
163
|
selectRange(anchor: DocPos, focus?: DocPos): void;
|
|
164
|
+
/** Right-click targets the item under the pointer without discarding a containing selection. */
|
|
165
|
+
selectAtPoint(clientX: number, clientY: number): boolean;
|
|
162
166
|
selectAll: () => void;
|
|
163
167
|
/** Bornes du paragraphe entier, telles que la mise en page les a dessinées. */
|
|
164
168
|
paragraphRange: (para: number) => {
|
|
165
169
|
from: number;
|
|
166
170
|
to: number;
|
|
167
171
|
} | null;
|
|
172
|
+
setList(ordered: boolean | null): void;
|
|
173
|
+
formatCell(patch: CellPatch): boolean;
|
|
174
|
+
mergeNextCell(): boolean;
|
|
175
|
+
replaceAll(query: string, replacement: string, matchCase?: boolean): number;
|
|
168
176
|
/** Insère du texte au curseur, ou remplace la sélection. */
|
|
169
177
|
insert: (text: string) => void;
|
|
170
178
|
deleteSelection: () => void;
|
|
179
|
+
deleteObject: () => void;
|
|
171
180
|
splitAtCaret: () => void;
|
|
172
181
|
format: (patch: RunPatch) => void;
|
|
173
182
|
formatPara: (patch: ParaPatch) => void;
|
|
@@ -191,9 +200,14 @@ export declare function createEditor(setup: EditorSetup): {
|
|
|
191
200
|
canRedo: () => boolean;
|
|
192
201
|
save: () => Uint8Array<ArrayBufferLike>;
|
|
193
202
|
/** État de l'enregistrement, tel que la barre d'état le montre. */
|
|
194
|
-
saveState: () => "à jour" | "à enregistrer" | "enregistrement…" | "échec";
|
|
203
|
+
saveState: () => "à jour" | "à enregistrer" | "enregistrement…" | "échec" | "modifications non enregistrées";
|
|
195
204
|
/** Force l'envoi maintenant, sans attendre l'accalmie. */
|
|
196
205
|
saveNow: () => Promise<void>;
|
|
206
|
+
isDirty: () => boolean;
|
|
207
|
+
markSaved: () => void;
|
|
208
|
+
markDirty: () => void;
|
|
209
|
+
revealCaret: () => void;
|
|
210
|
+
root: HTMLElement;
|
|
197
211
|
focus: () => void;
|
|
198
212
|
/** Agrandit l'affichage. Le canvas n'est pas recomposé : c'est du CSS. */
|
|
199
213
|
setZoom(z: number): void;
|
|
@@ -248,7 +262,7 @@ export type Editor = ReturnType<typeof createEditor>;
|
|
|
248
262
|
* déplacement du curseur, `render` après chaque composition, `context` avec
|
|
249
263
|
* l'état complet sous le curseur, `commands` quand le registre bouge.
|
|
250
264
|
*/
|
|
251
|
-
export type EditorEvent = 'change' | 'selection' | 'render' | 'context' | 'commands' | 'load' | 'save';
|
|
265
|
+
export type EditorEvent = 'change' | 'selection' | 'render' | 'context' | 'commands' | 'load' | 'save' | 'command';
|
|
252
266
|
/**
|
|
253
267
|
* Une commande ajoutée par l'hôte ou par une extension.
|
|
254
268
|
*
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DocPos } from '../../docx-model/src/index';
|
|
2
|
+
import type { Editor } from './editor';
|
|
3
|
+
export interface FeedbackContext {
|
|
4
|
+
sdkVersion: string;
|
|
5
|
+
browser: string;
|
|
6
|
+
language: string;
|
|
7
|
+
devicePixelRatio: number;
|
|
8
|
+
viewport: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
scrollTop: number;
|
|
12
|
+
scrollLeft: number;
|
|
13
|
+
};
|
|
14
|
+
visiblePages: number[];
|
|
15
|
+
pageCount: number;
|
|
16
|
+
zoom: number;
|
|
17
|
+
mode: 'edit' | 'preview' | 'readOnly';
|
|
18
|
+
chrome: string;
|
|
19
|
+
theme: string;
|
|
20
|
+
panel: string | null;
|
|
21
|
+
badges: {
|
|
22
|
+
variables: boolean;
|
|
23
|
+
expressions: boolean;
|
|
24
|
+
};
|
|
25
|
+
dirty: boolean;
|
|
26
|
+
selection: {
|
|
27
|
+
anchor: DocPos;
|
|
28
|
+
focus: DocPos;
|
|
29
|
+
} | null;
|
|
30
|
+
object: ReturnType<Editor['selectedObject']>;
|
|
31
|
+
font: {
|
|
32
|
+
family?: string;
|
|
33
|
+
sizePt?: number;
|
|
34
|
+
};
|
|
35
|
+
recentEvents: Array<{
|
|
36
|
+
at: string;
|
|
37
|
+
type: string;
|
|
38
|
+
detail?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export interface FeedbackReport {
|
|
42
|
+
schemaVersion: 1;
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
fileName: string;
|
|
46
|
+
wanted: string;
|
|
47
|
+
missing: string;
|
|
48
|
+
workaround: string;
|
|
49
|
+
context: FeedbackContext;
|
|
50
|
+
screenshot?: {
|
|
51
|
+
dataUrl: string;
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
};
|
|
55
|
+
captureError?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface FeedbackOptions {
|
|
58
|
+
/** Resolution acknowledges receipt; rejection keeps the form available for retry. */
|
|
59
|
+
onSubmit?: (report: FeedbackReport) => void | Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
type EditorContext = Pick<FeedbackContext, 'pageCount' | 'zoom' | 'mode' | 'chrome' | 'theme' | 'panel' | 'badges' | 'dirty' | 'selection' | 'object' | 'font'>;
|
|
62
|
+
/** One feedback tool per SDK instance; never reads document bytes or global console logs. */
|
|
63
|
+
export declare function mountFeedback(root: HTMLElement, main: HTMLElement, pages: HTMLElement, context: () => {
|
|
64
|
+
fileName: string;
|
|
65
|
+
context: EditorContext;
|
|
66
|
+
}, options: FeedbackOptions): {
|
|
67
|
+
open: () => void;
|
|
68
|
+
loaded(): void;
|
|
69
|
+
record(type: string, detail?: string): void;
|
|
70
|
+
reset(): void;
|
|
71
|
+
destroy(): void;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { createDocxEditor } from './sdk';
|
|
11
11
|
export type { DocxEditorHandle, DocxEditorOptions, DocxEditorEvent, ChromeMode, Theme } from './sdk';
|
|
12
|
+
export type { FeedbackReport, FeedbackContext, FeedbackOptions } from './feedback';
|
|
12
13
|
export { renderDocx } from './embed';
|
|
13
14
|
export type { Rendered } from './embed';
|
|
14
15
|
export { installFonts, defaultFontsUrl } from './fonts';
|
|
@@ -18,3 +19,7 @@ export type { DocxDocument, DocPos, EditContext, RunPatch, ParaPatch, MarginPatc
|
|
|
18
19
|
export { sampleValues, evaluateTags } from '../../docx-vars/src/index';
|
|
19
20
|
export type { LibraryExtras, LibraryField, LibrarySnippet } from './vars-library';
|
|
20
21
|
export type { Comment, CommentRange } from './comments';
|
|
22
|
+
export type { BadgeDisplay } from './variables';
|
|
23
|
+
export type { Draft } from './drafts';
|
|
24
|
+
export type { Panel } from './ui/shell';
|
|
25
|
+
export { createDocxViewer } from './sdk';
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* UI de l'inspecteur — panneau latéral avec onglets.
|
|
3
3
|
*/
|
|
4
4
|
import type { InspectorData } from './inspector';
|
|
5
|
-
export declare function renderInspector(data: InspectorData): void;
|
|
6
|
-
export declare function setupInspectorControls(): void;
|
|
5
|
+
export declare function renderInspector(data: InspectorData, root: HTMLElement): void;
|
|
6
|
+
export declare function setupInspectorControls(root: HTMLElement, refresh: () => void): void;
|
|
@@ -22,3 +22,5 @@ export declare const DocxEditor: import("react").ForwardRefExoticComponent<DocxE
|
|
|
22
22
|
/** A ref to hand to `<DocxEditor ref={…}>`, and the handle once it exists. */
|
|
23
23
|
export declare function useDocxEditor(): import("react").RefObject<DocxEditorHandle | null>;
|
|
24
24
|
export type { DocxEditorHandle, DocxEditorOptions } from './sdk';
|
|
25
|
+
/** Read-only companion, with the same rendering and lifecycle as the editor. */
|
|
26
|
+
export declare const DocxViewer: import("react").ForwardRefExoticComponent<DocxEditorProps & import("react").RefAttributes<DocxEditorHandle | null>>;
|
|
@@ -9,21 +9,24 @@
|
|
|
9
9
|
* the variables layer), the editor, the chrome — behind one handle, so the
|
|
10
10
|
* host page owns nothing but a `<div>`.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* a few elements by id (`#info`, `#pages`, `#inspector`…); two editors on one
|
|
14
|
-
* page would share them. ponytail: scope the ids to the root the day a page
|
|
15
|
-
* needs two editors.
|
|
12
|
+
* Instances own their UI, persistence and lifecycle. The host owns the surrounding app.
|
|
16
13
|
*/
|
|
17
14
|
import { type DocxDocument } from '../../docx-model/src/index';
|
|
18
15
|
import type { Tag } from '../../docx-tags/src/index';
|
|
19
16
|
import { type Editor } from './editor';
|
|
17
|
+
import { type BadgeDisplay } from './variables';
|
|
20
18
|
import { type LibraryExtras } from './vars-library';
|
|
21
19
|
import { type CommentRange } from './comments';
|
|
20
|
+
import { type Panel } from './ui/shell';
|
|
21
|
+
import { type Draft } from './drafts';
|
|
22
|
+
import { type FeedbackOptions } from './feedback';
|
|
22
23
|
export type ChromeMode = 'full' | 'viewer' | 'none';
|
|
23
24
|
export type Theme = 'light' | 'dark' | 'system';
|
|
24
|
-
export type DocxEditorEvent = 'load' | 'change' | 'selection' | 'render' | 'save' | 'context' | 'zoom';
|
|
25
|
+
export type DocxEditorEvent = 'load' | 'change' | 'selection' | 'render' | 'save' | 'context' | 'zoom' | 'saveState' | 'error' | 'command';
|
|
25
26
|
export interface DocxEditorOptions {
|
|
26
27
|
/** `full`: ribbon, rulers, panels. `viewer`: read-only pages under a slim header. `none`: pages only. */
|
|
28
|
+
/** Development host compatibility only; npm instances expose no window globals or IDs. */
|
|
29
|
+
debug?: boolean;
|
|
27
30
|
chrome?: ChromeMode;
|
|
28
31
|
readOnly?: boolean;
|
|
29
32
|
theme?: Theme;
|
|
@@ -34,6 +37,15 @@ export interface DocxEditorOptions {
|
|
|
34
37
|
/** the document after a quiet period, and on tab change — where autosave goes */
|
|
35
38
|
onSave?: (bytes: Uint8Array) => void | Promise<void>;
|
|
36
39
|
onChange?: () => void;
|
|
40
|
+
onError?: (error: Error) => void;
|
|
41
|
+
onSaveState?: (state: string) => void;
|
|
42
|
+
/** Text after onSave resolves, e.g. "enregistré sur le serveur". */
|
|
43
|
+
savedLabel?: string;
|
|
44
|
+
/** Local draft retention is opt-in; use a stable, unique key per document/user. */
|
|
45
|
+
draftKey?: string;
|
|
46
|
+
saveDelay?: number;
|
|
47
|
+
/** false shows the original variable/JSONata text without badges. */
|
|
48
|
+
badges?: boolean | Partial<BadgeDisplay>;
|
|
37
49
|
onReady?: (handle: DocxEditorHandle) => void;
|
|
38
50
|
zoom?: number;
|
|
39
51
|
rulers?: boolean;
|
|
@@ -42,16 +54,27 @@ export interface DocxEditorOptions {
|
|
|
42
54
|
/** preview values; when absent the preview deduces a sample set from the tags */
|
|
43
55
|
values?: Record<string, unknown>;
|
|
44
56
|
/** open the editor on the last-used side panel */
|
|
45
|
-
panel?:
|
|
57
|
+
panel?: Panel | null;
|
|
46
58
|
/** the fields and snippets the application offers, beyond what the document already uses */
|
|
47
59
|
library?: LibraryExtras;
|
|
48
60
|
/** show Word's comments as marks on the text (default true) */
|
|
49
61
|
comments?: boolean;
|
|
62
|
+
/** Opt-in feedback button: true exports JSON; onSubmit routes the report to the host. */
|
|
63
|
+
feedback?: boolean | FeedbackOptions;
|
|
50
64
|
}
|
|
51
65
|
export interface DocxEditorHandle {
|
|
52
|
-
load(src: ArrayBuffer | Uint8Array | Blob | string
|
|
66
|
+
load(src: ArrayBuffer | Uint8Array | Blob | string, options?: {
|
|
67
|
+
discardChanges?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
53
69
|
/** the document as .docx bytes, now */
|
|
54
70
|
save(): Uint8Array;
|
|
71
|
+
/** Wait for the host to acknowledge every outstanding modification. */
|
|
72
|
+
saveNow(): Promise<void>;
|
|
73
|
+
isDirty(): boolean;
|
|
74
|
+
saveState(): string;
|
|
75
|
+
getDraft(): Promise<Draft | undefined>;
|
|
76
|
+
restoreDraft(): Promise<boolean>;
|
|
77
|
+
discardDraft(): Promise<void>;
|
|
55
78
|
/** triggers the browser download */
|
|
56
79
|
download(name?: string): void;
|
|
57
80
|
/** the low-level editor: commands, selection, formatting — `null` before the first load */
|
|
@@ -61,10 +84,13 @@ export interface DocxEditorHandle {
|
|
|
61
84
|
pages(): number;
|
|
62
85
|
fileName(name?: string): string;
|
|
63
86
|
setZoom(z: number): void;
|
|
87
|
+
fitZoom(mode: 'width' | 'page'): void;
|
|
64
88
|
getZoom(): number;
|
|
65
89
|
setTheme(t: Theme): void;
|
|
66
90
|
setReadOnly(on: boolean): void;
|
|
67
|
-
showPanel(p:
|
|
91
|
+
showPanel(p: Panel | null): void;
|
|
92
|
+
/** Open the feedback form; requires feedback to be enabled and a loaded document. */
|
|
93
|
+
openFeedback(): void;
|
|
68
94
|
/** Word's comments of the open document, with their ranges */
|
|
69
95
|
comments(): CommentRange[];
|
|
70
96
|
showComments(on: boolean): void;
|
|
@@ -73,6 +99,8 @@ export interface DocxEditorHandle {
|
|
|
73
99
|
/** show the GENERATED document: values interpolated, false sections hidden */
|
|
74
100
|
preview(on: boolean, values?: Record<string, unknown>): Promise<void>;
|
|
75
101
|
previewOn(): boolean;
|
|
102
|
+
setDisplay(value: boolean | Partial<BadgeDisplay>): void;
|
|
103
|
+
display(): BadgeDisplay;
|
|
76
104
|
};
|
|
77
105
|
on(ev: DocxEditorEvent, fn: (payload?: unknown) => void): () => void;
|
|
78
106
|
destroy(): void;
|
|
@@ -83,3 +111,4 @@ export declare function paragraphStyles(doc: DocxDocument): {
|
|
|
83
111
|
name: string;
|
|
84
112
|
}[];
|
|
85
113
|
export declare function createDocxEditor(container: HTMLElement, options?: DocxEditorOptions): DocxEditorHandle;
|
|
114
|
+
export declare function createDocxViewer(container: HTMLElement, options?: DocxEditorOptions): DocxEditorHandle;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Editor } from '../editor';
|
|
2
|
+
import type { Panel } from './shell';
|
|
3
|
+
/** Context actions share the editor's command registry, selection and undo stack. */
|
|
4
|
+
export declare function mountContextMenu(root: HTMLElement, editor: Editor, showPanel: (panel: Panel) => void): () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EditContext } from '../../../docx-model/src/index';
|
|
2
|
+
import type { Editor } from '../editor';
|
|
3
|
+
/** Properties use the same mutations and undo stack as the ribbon. */
|
|
4
|
+
export declare function mountProperties(root: HTMLElement, editor: Editor, styles: () => {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}[], close: () => void): {
|
|
8
|
+
refresh: (ctx: EditContext | null) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function mountNavigation(root: HTMLElement, editor: Editor, close: () => void): {
|
|
11
|
+
refresh: () => void;
|
|
12
|
+
find: (replace?: boolean) => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Popovers belong to one editor, including their theme and event lifetime. */
|
|
2
|
+
export declare function showPopover(root: HTMLElement, pop: HTMLElement, anchor?: HTMLElement): () => void;
|
|
3
|
+
/** Keep the document selection on mouse press; native click also supports keyboard/touch. */
|
|
4
|
+
export declare function action(button: HTMLButtonElement, run: () => void): void;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
export type ChromeMode = 'full' | 'viewer' | 'none';
|
|
2
2
|
export type Theme = 'light' | 'dark' | 'system';
|
|
3
|
-
export type Panel = 'variables' | 'inspector';
|
|
3
|
+
export type Panel = 'variables' | 'inspector' | 'properties' | 'navigation';
|
|
4
4
|
export interface ShellHost {
|
|
5
5
|
open(file: File): void;
|
|
6
6
|
save(): void;
|
|
7
|
+
download(): void;
|
|
7
8
|
zoom(z: number): void;
|
|
8
9
|
panel(p: Panel | null): void;
|
|
9
10
|
rename(name: string): void;
|
|
11
|
+
raw: {
|
|
12
|
+
get(): boolean;
|
|
13
|
+
set(on: boolean): void;
|
|
14
|
+
};
|
|
10
15
|
}
|
|
11
16
|
export interface ShellOptions {
|
|
12
17
|
mode: ChromeMode;
|
|
@@ -14,6 +19,7 @@ export interface ShellOptions {
|
|
|
14
19
|
rulers: boolean;
|
|
15
20
|
statusBar: boolean;
|
|
16
21
|
fileName: string;
|
|
22
|
+
debug?: boolean;
|
|
17
23
|
host: ShellHost;
|
|
18
24
|
}
|
|
19
25
|
export interface Shell {
|
|
@@ -25,6 +31,8 @@ export interface Shell {
|
|
|
25
31
|
rulerV: HTMLElement;
|
|
26
32
|
varsEl: HTMLElement;
|
|
27
33
|
inspectorEl: HTMLElement;
|
|
34
|
+
propertiesEl: HTMLElement;
|
|
35
|
+
navigationEl: HTMLElement;
|
|
28
36
|
statusEl: HTMLElement;
|
|
29
37
|
/** the composition line the bench reads (« N page(s) ») */
|
|
30
38
|
info: HTMLElement;
|
|
@@ -32,6 +40,7 @@ export interface Shell {
|
|
|
32
40
|
loader: Loader;
|
|
33
41
|
setFileName(name: string): void;
|
|
34
42
|
setSaveState(s: string): void;
|
|
43
|
+
setRaw(on: boolean): void;
|
|
35
44
|
setPages(n: number): void;
|
|
36
45
|
setWords(n: number): void;
|
|
37
46
|
setPosition(page: number, pages: number, selChars: number): void;
|
|
@@ -21,7 +21,13 @@ import { type Evaluated } from '../../docx-vars/src/index';
|
|
|
21
21
|
* chaque caractère qui SUIT dans le paragraphe en dépend, et un curseur posé
|
|
22
22
|
* après un badge écrirait sinon quatorze caractères trop tôt.
|
|
23
23
|
*/
|
|
24
|
+
export type BadgeDisplay = {
|
|
25
|
+
variables: boolean;
|
|
26
|
+
expressions: boolean;
|
|
27
|
+
};
|
|
24
28
|
export interface VarsHost {
|
|
29
|
+
root: HTMLElement;
|
|
30
|
+
readOnly?(): boolean;
|
|
25
31
|
/** Texte de chaque paragraphe, tel que les EXTENSIONS le voient. */
|
|
26
32
|
paras(): string[];
|
|
27
33
|
/** Curseur courant, pour les extensions qui s'y intéressent. */
|
|
@@ -60,6 +66,7 @@ export interface Variables {
|
|
|
60
66
|
* le début ; l'éditeur, non — il ne montrait que les tags.
|
|
61
67
|
*/
|
|
62
68
|
setPreview(ev: Evaluated | null): void;
|
|
69
|
+
setDisplay(display: BadgeDisplay): void;
|
|
63
70
|
/** Pose les badges dans les boîtes que le renderer a publiées. */
|
|
64
71
|
place(layers: HTMLElement[], rects: MarkRect[]): void;
|
|
65
72
|
/** Met en évidence le badge d'un tag — ou aucun. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LibEntry } from './vars-library';
|
|
1
|
+
import { type LibEntry, type LibraryExtras } from './vars-library';
|
|
2
2
|
import type { Tag } from '../../docx-tags/src/index';
|
|
3
3
|
/**
|
|
4
4
|
* L'autocomplétion, dans le document.
|
|
@@ -19,6 +19,8 @@ import type { Tag } from '../../docx-tags/src/index';
|
|
|
19
19
|
export interface CompleteHost {
|
|
20
20
|
/** Le champ invisible qui reçoit la frappe — c'est là qu'on capture. */
|
|
21
21
|
input: HTMLElement;
|
|
22
|
+
root: HTMLElement;
|
|
23
|
+
library?: LibraryExtras;
|
|
22
24
|
tags(): Tag[];
|
|
23
25
|
/** Texte d'un paragraphe du corps. */
|
|
24
26
|
textOf(para: number): string;
|
|
@@ -37,6 +39,7 @@ export interface Completer {
|
|
|
37
39
|
refresh(): void;
|
|
38
40
|
close(): void;
|
|
39
41
|
open(): boolean;
|
|
42
|
+
destroy(): void;
|
|
40
43
|
}
|
|
41
44
|
/** Ce qu'on est en train de taper, et ce qu'on a le droit d'y proposer. */
|
|
42
45
|
interface Context {
|
|
@@ -45,8 +45,8 @@ export interface LibraryExtras {
|
|
|
45
45
|
/** keep the built-in snippets next to the host's (default true) */
|
|
46
46
|
builtinSnippets?: boolean;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
export declare function libraryEntries(tags: Tag[]): LibEntry[];
|
|
48
|
+
/** Each editor supplies its own library. */
|
|
49
|
+
export declare function libraryEntries(tags: Tag[], extras?: LibraryExtras): LibEntry[];
|
|
50
50
|
/** Filtre sans accent ni casse — on cherche « majore », on trouve « Majoré ». */
|
|
51
51
|
export declare const fold: (s: string) => string;
|
|
52
52
|
export declare function filterEntries(all: LibEntry[], kind: string, query: string): LibEntry[];
|