@arbidocs/blocks 0.4.97 → 0.4.98

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 (31) hide show
  1. package/dist/{chunk-RSUOOMPT.js → chunk-6B2AWE3I.js} +3 -3
  2. package/dist/{chunk-RSUOOMPT.js.map → chunk-6B2AWE3I.js.map} +1 -1
  3. package/dist/{chunk-QIEEFBZ5.js → chunk-FIEAWH4K.js} +354 -69
  4. package/dist/chunk-FIEAWH4K.js.map +1 -0
  5. package/dist/{chunk-YH6SSJDW.js → chunk-LZ5AFAWC.js} +3 -3
  6. package/dist/{chunk-YH6SSJDW.js.map → chunk-LZ5AFAWC.js.map} +1 -1
  7. package/dist/{chunk-HGJGALLN.cjs → chunk-MIMVRMKC.cjs} +359 -67
  8. package/dist/chunk-MIMVRMKC.cjs.map +1 -0
  9. package/dist/{chunk-GVOTXXZG.cjs → chunk-MUYZP5FB.cjs} +5 -5
  10. package/dist/{chunk-GVOTXXZG.cjs.map → chunk-MUYZP5FB.cjs.map} +1 -1
  11. package/dist/{chunk-EHB7J6SR.cjs → chunk-VJO66VVF.cjs} +5 -5
  12. package/dist/{chunk-EHB7J6SR.cjs.map → chunk-VJO66VVF.cjs.map} +1 -1
  13. package/dist/connect/docx.cjs +6 -6
  14. package/dist/connect/docx.js +4 -4
  15. package/dist/connect/index.cjs +3 -3
  16. package/dist/connect/index.js +2 -2
  17. package/dist/docx/NativeDocxEditor.d.ts +7 -0
  18. package/dist/docx/RibbonMenu.d.ts +3 -1
  19. package/dist/docx/index.cjs +52 -24
  20. package/dist/docx/index.d.ts +2 -0
  21. package/dist/docx/index.js +3 -3
  22. package/dist/docx/template/HouseTemplate.d.ts +64 -0
  23. package/dist/docx/template/HouseTemplatePanel.d.ts +6 -0
  24. package/dist/docx/template/QuickParts.d.ts +7 -0
  25. package/dist/docx/wordStyles.d.ts +3 -0
  26. package/dist/index.cjs +41 -41
  27. package/dist/index.js +2 -2
  28. package/package.json +4 -4
  29. package/src/docx/styles.css +102 -0
  30. package/dist/chunk-HGJGALLN.cjs.map +0 -1
  31. package/dist/chunk-QIEEFBZ5.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useConnection } from './chunk-OYMWV45N.js';
3
- import { NativeDocxEditor, loadDocxFonts } from './chunk-QIEEFBZ5.js';
3
+ import { NativeDocxEditor, loadDocxFonts } from './chunk-FIEAWH4K.js';
4
4
  import { useMemo } from 'react';
5
5
  import { useQueryClient, useQuery } from '@tanstack/react-query';
6
6
  import { useArbi, notify, arbiQueryKeys } from '@arbidocs/react';
@@ -88,5 +88,5 @@ function useConnectedNativeDocxAdapter(fontBaseUrl = "/native-docx/fonts") {
88
88
  }
89
89
 
90
90
  export { ConnectedNativeDocxEditor, useConnectedNativeDocxAdapter };
91
- //# sourceMappingURL=chunk-YH6SSJDW.js.map
92
- //# sourceMappingURL=chunk-YH6SSJDW.js.map
91
+ //# sourceMappingURL=chunk-LZ5AFAWC.js.map
92
+ //# sourceMappingURL=chunk-LZ5AFAWC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":[],"mappings":";;;;;;;AAYO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,uBAAO,GAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwB,aAAA,EAAc;AACzE,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,EAAE,IAAA,EA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AA,GAAU;AAAA,OAC1D,CAAE,CAAA;AAAA,MACF,YAAA,EAAc,OAAO,EAAA,EAAI,OAAA,KAAY;AACnC,QAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,kBAAA,CAAmB,EAAE,CAAC,CAAA,SAAA,CAAA,EAAa;AAAA,UAChF,MAAA,EAAQ,MAAA;AAAA,UACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,UAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-YH6SSJDW.js","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/ConnectedNativeDocxEditor.tsx"],"names":[],"mappings":";;;;;;;AAYO,SAAS,yBAAA,CAA0B;AAAA,EACxC,WAAA,GAAc,oBAAA;AAAA,EACd,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,MAAM,OAAA,GAAU,8BAA8B,WAAW,CAAA;AACzD,EAAA,uBAAO,GAAA,CAAC,gBAAA,EAAA,EAAkB,GAAG,KAAA,EAAO,OAAA,EAAkB,CAAA;AACxD;AAEO,SAAS,6BAAA,CAA8B,cAAc,oBAAA,EAAsB;AAChF,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,MAAA,EAAQ,IAAA,EAAM,mBAAA,KAAwB,aAAA,EAAc;AACzE,EAAA,MAAM,UAAU,cAAA,EAAe;AAC/B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAQ,GAAI,QAAA,CAAS;AAAA,IACjC,UAAU,CAAC,qBAAA,EAAuB,MAAA,EAAQ,IAAA,EAAM,YAAY,WAAW,CAAA;AAAA,IACvE,OAAA,EAAS,IAAA,CAAK,UAAA,IAAc,CAAC,CAAC,WAAA;AAAA,IAC9B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AAC,CAAA,SAAA,CAAA,EAAa;AAAA,UAChF,MAAA,EAAQ,MAAA;AAAA,UACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,UAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,aAAa,OAAA,CAAQ,WAAA;AAAA,YACrB,YAAY,OAAA,CAAQ,SAAA;AAAA,YACpB,eAAe,OAAA,CAAQ;AAAA,WACxB;AAAA,SACF,CAAA;AACD,QAAA,MAAM,QAAA,GAAY,MAAM,QAAA,CAAS,IAAA,EAAK;AACtC,QAAA,MAAA,CAAO,QAAQ,oBAAoB,CAAA;AACnC,QAAA,OAAO,EAAE,WAAA,EAAa,QAAA,CAAS,YAAA,IAAgB,EAAC,EAAE;AAAA,MACpD,CAAA;AAAA,MACA,cAAA,EAAgB,OAAO,UAAA,KAAA,CAAgB,MAAM,KAAK,SAAA,CAAU,WAAA,CAAY,UAAU,CAAA,EAAG;AAAA,KACvF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,IAAA,EAAM,MAAM,OAAA,EAAS,mBAAA,EAAqB,WAAA,EAAa,OAAA,EAAS,WAAW;AAAA,GAC5F;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-LZ5AFAWC.js","sourcesContent":["import { useMemo } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useArbi, notify, arbiQueryKeys } from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport {\n NativeDocxEditor,\n type NativeDocxAdapter,\n type NativeDocxEditorProps,\n} from '../docx/NativeDocxEditor'\nimport { loadDocxFonts } from '../docx/fonts'\n\n/** Native Word widget bound to the standard blocks connection and SDK session. */\nexport function ConnectedNativeDocxEditor({\n fontBaseUrl = '/native-docx/fonts',\n ...props\n}: Omit<NativeDocxEditorProps, 'adapter'> & { fontBaseUrl?: string }) {\n const adapter = useConnectedNativeDocxAdapter(fontBaseUrl)\n return <NativeDocxEditor {...props} adapter={adapter} />\n}\n\nexport function useConnectedNativeDocxAdapter(fontBaseUrl = '/native-docx/fonts') {\n const arbi = useArbi()\n const { workspaceId, apiUrl, user, ensureWorkspaceOpen } = useConnection()\n const queries = useQueryClient()\n const { data: members } = useQuery({\n queryKey: ['native-docx-members', apiUrl, user?.externalId, workspaceId],\n enabled: arbi.isLoggedIn && !!workspaceId,\n queryFn: async () => {\n await ensureWorkspaceOpen()\n return arbi.workspaces.listUsers()\n },\n })\n const adapter = useMemo<NativeDocxAdapter>(\n () => ({\n request: async (path, options) => {\n await ensureWorkspaceOpen()\n return arbi.editor.request(path, options)\n },\n open: async (id) => {\n await ensureWorkspaceOpen()\n return (\n await arbi.editor.request(`/${encodeURIComponent(id)}/session`, { method: 'POST' })\n ).json()\n },\n save: async (id, state) =>\n (\n await arbi.editor.request(`/${encodeURIComponent(id)}/save`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ state }),\n })\n ).json(),\n loadFonts: () => loadDocxFonts(fontBaseUrl),\n baseUrl: apiUrl,\n author: user?.name || 'You',\n onVersionSaved: async (id) => {\n if (!workspaceId) return\n const key = arbiQueryKeys.documents(workspaceId)\n try {\n const documents = await arbi.documents.get([id])\n if (!documents.length) throw new Error('The saved version is not available yet.')\n queries.setQueryData<Awaited<ReturnType<typeof arbi.documents.list>>>(key, (previous) => [\n ...documents,\n ...(previous || []).filter(\n (doc) => !documents.some((saved) => saved.external_id === doc.external_id)\n ),\n ])\n } catch {\n await queries.invalidateQueries({ queryKey: key })\n }\n },\n notify: (message, kind) => notify[kind](message),\n mentions: members?.map(({ user: member }) => ({\n id: member.external_id,\n name: [member.given_name, member.family_name].filter(Boolean).join(' '),\n kind: member.external_id.startsWith('agt-') ? 'agent' : 'human',\n })),\n requestAgent: async (id, request) => {\n const response = await arbi.editor.request(`/${encodeURIComponent(id)}/mentions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n comment_id: request.commentId,\n instruction: request.instruction,\n request_id: request.requestId,\n recipient_ids: request.recipientIds,\n }),\n })\n const delivery = (await response.json()) as { response_ids: string[] }\n notify.success('Mention delivered.')\n return { responseIds: delivery.response_ids || [] }\n },\n getAgentStatus: async (responseId) => (await arbi.assistant.getResponse(responseId)).status,\n }),\n [arbi, apiUrl, user?.name, members, ensureWorkspaceOpen, fontBaseUrl, queries, workspaceId]\n )\n return adapter\n}\n"]}
@@ -11,6 +11,7 @@ var ui = require('@arbidocs/react/ui');
11
11
  var lucideReact = require('lucide-react');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
13
  var reactDom = require('react-dom');
14
+ var template = require('@arbidocs/coedit/template');
14
15
  var server = require('react-dom/server');
15
16
  var Y = require('yjs');
16
17
  var coedit = require('@arbidocs/coedit');
@@ -2147,6 +2148,130 @@ function DefinedTermHover({
2147
2148
  document.body
2148
2149
  );
2149
2150
  }
2151
+ var BUILTIN_TEMPLATE_NAME = "ARBI legal template";
2152
+ var templateFileName = (t) => /\.(dotx|dotm|docx|docm)$/i.test(t.name) ? t.name : `${t.name}.dotx`;
2153
+ var builtin;
2154
+ function builtinHouseTemplate() {
2155
+ builtin ??= { bytes: template.defaultLegalTemplate(), name: BUILTIN_TEMPLATE_NAME, source: "builtin" };
2156
+ return builtin;
2157
+ }
2158
+ async function resolveHouseTemplate(host) {
2159
+ if (!host) return builtinHouseTemplate();
2160
+ try {
2161
+ return await host.load();
2162
+ } catch {
2163
+ return builtinHouseTemplate();
2164
+ }
2165
+ }
2166
+ var HouseTemplateContext = React3.createContext(null);
2167
+ var useHouseTemplate = () => React3.useContext(HouseTemplateContext);
2168
+ function HouseTemplateProvider({
2169
+ host,
2170
+ documentId,
2171
+ editable,
2172
+ notify,
2173
+ enabled = true,
2174
+ children
2175
+ }) {
2176
+ const editor = react.useDocxEditor();
2177
+ const [template$1, setTemplate] = React3.useState(builtinHouseTemplate);
2178
+ const [divergence, setDivergence] = React3.useState(null);
2179
+ const [basedOnTemplate, setBasedOnTemplate] = React3.useState(false);
2180
+ const [levels, setLevels] = React3.useState({});
2181
+ const [generation, setGeneration] = React3.useState(0);
2182
+ React3.useEffect(() => {
2183
+ let live = true;
2184
+ void resolveHouseTemplate(host).then((t) => live && setTemplate(t));
2185
+ return () => {
2186
+ live = false;
2187
+ };
2188
+ }, [host]);
2189
+ const blocks = React3.useMemo(() => {
2190
+ try {
2191
+ return template.listBuildingBlocks(template$1.bytes);
2192
+ } catch {
2193
+ return [];
2194
+ }
2195
+ }, [template$1]);
2196
+ React3.useEffect(() => {
2197
+ if (!editor || !enabled) return;
2198
+ let live = true;
2199
+ void editor.save().then((saved) => {
2200
+ if (!live || !saved) return;
2201
+ const bytes = new Uint8Array(saved);
2202
+ setBasedOnTemplate(template.attachedTemplateOf(bytes) === templateFileName(template$1));
2203
+ setLevels(template.linkedLevelStyles(bytes));
2204
+ setDivergence(template.styleDivergence(bytes, template$1.bytes));
2205
+ }).catch(() => live && setDivergence(null));
2206
+ return () => {
2207
+ live = false;
2208
+ };
2209
+ }, [editor, template$1, generation, enabled]);
2210
+ const refresh = React3.useCallback(() => setGeneration((g) => g + 1), []);
2211
+ const insertBlock = React3.useCallback(
2212
+ (name) => {
2213
+ if (!editor || !editable) return false;
2214
+ const fragment = template.buildingBlockFragment(template$1.bytes, name);
2215
+ if (!fragment) return false;
2216
+ try {
2217
+ const result = withDirectEditing(
2218
+ editor,
2219
+ () => editor.exec({ type: "paste", text: "", html: template.fragmentClipboardHtml(fragment) })
2220
+ );
2221
+ if (!result.ok) throw new Error(result.reason ?? "The block could not be inserted here.");
2222
+ refresh();
2223
+ return true;
2224
+ } catch (failure) {
2225
+ notify?.(
2226
+ failure instanceof Error ? failure.message : "Could not insert the block.",
2227
+ "error"
2228
+ );
2229
+ return false;
2230
+ }
2231
+ },
2232
+ [editor, editable, template$1, notify, refresh]
2233
+ );
2234
+ const setAsHouseTemplate = React3.useMemo(
2235
+ () => host?.setFromDocument && documentId ? async () => {
2236
+ try {
2237
+ await host.setFromDocument(documentId);
2238
+ setTemplate(await resolveHouseTemplate(host));
2239
+ notify?.("This document is now the house template for new documents.", "success");
2240
+ } catch (failure) {
2241
+ notify?.(
2242
+ failure instanceof Error ? failure.message : "Could not set the house template.",
2243
+ "error"
2244
+ );
2245
+ }
2246
+ } : void 0,
2247
+ [host, documentId, notify]
2248
+ );
2249
+ const value = React3.useMemo(
2250
+ () => ({
2251
+ template: template$1,
2252
+ blocks,
2253
+ divergence,
2254
+ basedOnTemplate,
2255
+ levels,
2256
+ insertBlock,
2257
+ refresh,
2258
+ setAsHouseTemplate,
2259
+ editable
2260
+ }),
2261
+ [
2262
+ template$1,
2263
+ blocks,
2264
+ divergence,
2265
+ basedOnTemplate,
2266
+ levels,
2267
+ insertBlock,
2268
+ refresh,
2269
+ setAsHouseTemplate,
2270
+ editable
2271
+ ]
2272
+ );
2273
+ return /* @__PURE__ */ jsxRuntime.jsx(HouseTemplateContext.Provider, { value: enabled ? value : null, children });
2274
+ }
2150
2275
  function wordDraftHtml(markdown) {
2151
2276
  const template = document.createElement("template");
2152
2277
  template.innerHTML = server.renderToStaticMarkup(/* @__PURE__ */ jsxRuntime.jsx(ui.AiMarkdown, { children: markdown }));
@@ -2239,7 +2364,8 @@ function RibbonMenu({
2239
2364
  icon,
2240
2365
  children,
2241
2366
  className,
2242
- testId
2367
+ testId,
2368
+ title
2243
2369
  }) {
2244
2370
  const [open, setOpen] = React3.useState(false);
2245
2371
  const element = React3.useRef(null);
@@ -2265,7 +2391,7 @@ function RibbonMenu({
2265
2391
  type: "button",
2266
2392
  className: ["native-docx-ribbon-trigger", className].filter(Boolean).join(" "),
2267
2393
  "aria-label": label,
2268
- title: label,
2394
+ title: title ?? label,
2269
2395
  "aria-expanded": open,
2270
2396
  "data-testid": testId,
2271
2397
  onMouseDown: (event) => event.preventDefault(),
@@ -2322,6 +2448,17 @@ function wordShortcut(event) {
2322
2448
  if (event.shiftKey && !event.altKey && event.code === "KeyN") return "Normal";
2323
2449
  return null;
2324
2450
  }
2451
+ function divergenceSummary(divergence) {
2452
+ if (!divergence) return null;
2453
+ const changed = divergence.styles.filter((s) => s.kind === "changed").map((s) => styleLabel(s.name));
2454
+ const missing = divergence.styles.filter((s) => s.kind === "missing").map((s) => styleLabel(s.name));
2455
+ const parts = [
2456
+ divergence.docDefaults ? "default text formatting" : "",
2457
+ changed.length ? `${changed.length === 1 ? "style" : "styles"} ${changed.slice(0, 6).join(", ")}${changed.length > 6 ? "\u2026" : ""}` : "",
2458
+ missing.length ? `${missing.length} house ${missing.length === 1 ? "style" : "styles"} missing` : ""
2459
+ ].filter(Boolean);
2460
+ return parts.length ? `Differs from the house template: ${parts.join("; ")}.` : null;
2461
+ }
2325
2462
  var FILTER_FROM = 8;
2326
2463
  function previewStyle(option) {
2327
2464
  const { fontFamily, fontSizePt, bold, italic, color } = option.preview;
@@ -2337,6 +2474,10 @@ function previewStyle(option) {
2337
2474
  function Gallery({ close }) {
2338
2475
  const { value, setValue, options, isEnabled } = react.useParagraphStyle();
2339
2476
  const editor = react.useDocxEditor();
2477
+ const house = useHouseTemplate();
2478
+ const changed = new Set(
2479
+ house?.basedOnTemplate ? house.divergence?.styles.filter((s) => s.kind === "changed").map((s) => s.styleId) : []
2480
+ );
2340
2481
  const [query, setQuery] = React3.useState("");
2341
2482
  const quick = React3.useMemo(
2342
2483
  () => QUICK_STYLES.map((name) => findStyle(options, name)).filter(
@@ -2399,7 +2540,7 @@ function Gallery({ close }) {
2399
2540
  id: nav.listboxId,
2400
2541
  "aria-label": "Document styles",
2401
2542
  children: [
2402
- shown.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
2543
+ shown.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
2403
2544
  "li",
2404
2545
  {
2405
2546
  id: chunk7UTB4PHM_cjs.listOptionId(nav.listboxId, index),
@@ -2410,7 +2551,17 @@ function Gallery({ close }) {
2410
2551
  "data-style-id": option.styleId,
2411
2552
  onMouseEnter: () => nav.setSelectedIndex(index),
2412
2553
  onClick: () => isEnabled && apply(option),
2413
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: previewStyle(option), children: styleLabel(option.name) })
2554
+ children: [
2555
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: previewStyle(option), children: styleLabel(option.name) }),
2556
+ changed.has(option.styleId) && /* @__PURE__ */ jsxRuntime.jsx(
2557
+ "span",
2558
+ {
2559
+ className: "native-docx-style-diverged",
2560
+ title: "Defined differently from the house template",
2561
+ "aria-label": "Defined differently from the house template"
2562
+ }
2563
+ )
2564
+ ]
2414
2565
  },
2415
2566
  option.styleId
2416
2567
  )),
@@ -2424,14 +2575,25 @@ function StyleGallery() {
2424
2575
  const { value, options } = react.useParagraphStyle();
2425
2576
  const current = options.find((o) => o.styleId === value);
2426
2577
  const name = current ? styleLabel(current.name) : "Styles";
2578
+ const house = useHouseTemplate();
2579
+ const diverged = house?.basedOnTemplate ? divergenceSummary(house.divergence) : null;
2427
2580
  return /* @__PURE__ */ jsxRuntime.jsx(
2428
2581
  RibbonMenu,
2429
2582
  {
2430
2583
  label: "Styles",
2584
+ title: diverged ? `Styles. ${diverged}` : void 0,
2431
2585
  className: "native-docx-style-trigger",
2432
2586
  testId: "docx-style-trigger",
2433
2587
  icon: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2434
2588
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-style-current", "data-testid": "docx-current-style", children: name }),
2589
+ diverged && /* @__PURE__ */ jsxRuntime.jsx(
2590
+ "span",
2591
+ {
2592
+ className: "native-docx-style-diverged",
2593
+ "data-testid": "docx-style-diverged",
2594
+ "aria-label": diverged
2595
+ }
2596
+ ),
2435
2597
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 12, "aria-hidden": true })
2436
2598
  ] }),
2437
2599
  children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Gallery, { close })
@@ -2500,12 +2662,18 @@ function WordShortcuts({ scope }) {
2500
2662
  const endnote = useInsertNote("endnote");
2501
2663
  const styles = react.useParagraphStyle();
2502
2664
  const editor = react.useDocxEditor();
2503
- const latest = React3.useRef({ footnote, endnote, styles, editor });
2504
- latest.current = { footnote, endnote, styles, editor };
2665
+ const levels = useHouseTemplate()?.levels;
2666
+ const latest = React3.useRef({ footnote, endnote, styles, editor, levels });
2667
+ latest.current = { footnote, endnote, styles, editor, levels };
2505
2668
  React3.useEffect(() => {
2506
2669
  const element = scope.current;
2507
2670
  if (!element) return;
2508
2671
  const onKeyDown = (event) => {
2672
+ if (outlineTab(event)) {
2673
+ event.preventDefault();
2674
+ event.stopPropagation();
2675
+ return;
2676
+ }
2509
2677
  const action = wordShortcut(event);
2510
2678
  if (!action) return;
2511
2679
  const { footnote: footnote2, endnote: endnote2, styles: styles2, editor: editor2 } = latest.current;
@@ -2520,11 +2688,110 @@ function WordShortcuts({ scope }) {
2520
2688
  event.stopPropagation();
2521
2689
  editor2?.surface?.focus();
2522
2690
  };
2691
+ const outlineTab = (event) => {
2692
+ if (event.key !== "Tab" || event.ctrlKey || event.metaKey || event.altKey) return false;
2693
+ const { editor: editor2, levels: levels2, styles: styles2 } = latest.current;
2694
+ const current = editor2?.getSelectionFormatting()?.styleId;
2695
+ const link = current ? levels2?.[current] : void 0;
2696
+ const target = event.shiftKey ? link?.previous : link?.next;
2697
+ if (!target || !editor2 || editorPort(editor2).caret()?.offset !== 0) return false;
2698
+ styles2.setValue(target);
2699
+ return true;
2700
+ };
2523
2701
  element.addEventListener("keydown", onKeyDown, true);
2524
2702
  return () => element.removeEventListener("keydown", onKeyDown, true);
2525
2703
  }, [scope]);
2526
2704
  return null;
2527
2705
  }
2706
+ function QuickParts() {
2707
+ const house = useHouseTemplate();
2708
+ if (!house || house.blocks.length === 0) return null;
2709
+ const categories = [...new Set(house.blocks.map((b) => b.category))];
2710
+ return /* @__PURE__ */ jsxRuntime.jsx(RibbonMenu, { label: "Quick Parts", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Blocks, { size: 16 }), testId: "docx-quick-parts", children: (close) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-quick-parts", "data-testid": "docx-quick-parts-panel", children: [
2711
+ categories.map((category) => /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": category, children: [
2712
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { children: category }),
2713
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { children: house.blocks.filter((b) => b.category === category).map((block) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
2714
+ "button",
2715
+ {
2716
+ type: "button",
2717
+ disabled: !house.editable,
2718
+ title: block.description || block.name,
2719
+ onClick: () => {
2720
+ close();
2721
+ house.insertBlock(block.name);
2722
+ },
2723
+ children: [
2724
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-quick-part-name", children: block.name }),
2725
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-quick-part-preview", children: block.text })
2726
+ ]
2727
+ }
2728
+ ) }, block.name)) })
2729
+ ] }, category)),
2730
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "native-docx-quick-parts-source", children: [
2731
+ "From ",
2732
+ house.template.name
2733
+ ] })
2734
+ ] }) });
2735
+ }
2736
+ var SOURCE = {
2737
+ workspace: "This workspace's house template",
2738
+ deployment: "The house template for all workspaces",
2739
+ builtin: "ARBI\u2019s built-in template (no house template has been set)"
2740
+ };
2741
+ function download(bytes, name) {
2742
+ const isTemplate = !/\.docx$/i.test(name);
2743
+ const url = URL.createObjectURL(
2744
+ new Blob([bytes], {
2745
+ type: isTemplate ? "application/vnd.openxmlformats-officedocument.wordprocessingml.template" : "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
2746
+ })
2747
+ );
2748
+ const a = document.createElement("a");
2749
+ a.href = url;
2750
+ a.download = /\.(dotx|docx)$/i.test(name) ? name : `${name}.dotx`;
2751
+ a.click();
2752
+ setTimeout(() => URL.revokeObjectURL(url), 5e3);
2753
+ }
2754
+ function HouseTemplatePanel() {
2755
+ const house = useHouseTemplate();
2756
+ if (!house) return null;
2757
+ const summary = divergenceSummary(house.divergence);
2758
+ return /* @__PURE__ */ jsxRuntime.jsx(
2759
+ RibbonMenu,
2760
+ {
2761
+ label: "House template",
2762
+ className: "native-docx-style-trigger",
2763
+ testId: "docx-house-template",
2764
+ icon: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2765
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-style-current", children: "House template" }),
2766
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 12, "aria-hidden": true })
2767
+ ] }),
2768
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-house-template", "data-testid": "docx-house-template-panel", children: [
2769
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
2770
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: house.template.name }),
2771
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
2772
+ SOURCE[house.template.source],
2773
+ ". New documents start from it."
2774
+ ] }),
2775
+ /* @__PURE__ */ jsxRuntime.jsx("p", { "data-testid": "docx-house-template-status", children: house.divergence === null ? "Comparing this document\u2019s styles\u2026" : !house.basedOnTemplate ? "This document was not started from the house template." : summary ?? "This document\u2019s styles match the house template." }),
2776
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-house-template-actions", children: [
2777
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: () => download(house.template.bytes, house.template.name), children: [
2778
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { size: 14 }),
2779
+ " Download template"
2780
+ ] }),
2781
+ house.setAsHouseTemplate && /* @__PURE__ */ jsxRuntime.jsx(
2782
+ "button",
2783
+ {
2784
+ type: "button",
2785
+ "data-testid": "docx-set-house-template",
2786
+ onClick: () => void house.setAsHouseTemplate(),
2787
+ children: "Use this document as the house template"
2788
+ }
2789
+ )
2790
+ ] })
2791
+ ] })
2792
+ }
2793
+ );
2794
+ }
2528
2795
  function contentPath(documentId) {
2529
2796
  const match = /^(doc-[A-Za-z0-9]+)@v([1-9][0-9]*)$/.exec(documentId);
2530
2797
  return match ? `/${encodeURIComponent(match[1])}/content?version=${match[2]}` : `/${encodeURIComponent(documentId)}/content`;
@@ -2614,6 +2881,7 @@ function DocxRibbon({
2614
2881
  /* @__PURE__ */ jsxRuntime.jsxs("select", { "aria-label": "Ribbon tab", value: tab, onChange: (event) => setTab(event.target.value), children: [
2615
2882
  /* @__PURE__ */ jsxRuntime.jsx("option", { children: "Home" }),
2616
2883
  /* @__PURE__ */ jsxRuntime.jsx("option", { children: "Insert" }),
2884
+ /* @__PURE__ */ jsxRuntime.jsx("option", { children: "Design" }),
2617
2885
  /* @__PURE__ */ jsxRuntime.jsx("option", { children: "References" }),
2618
2886
  /* @__PURE__ */ jsxRuntime.jsx("option", { children: "Review" })
2619
2887
  ] }),
@@ -2647,8 +2915,10 @@ function DocxRibbon({
2647
2915
  /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.TableInsert, {}),
2648
2916
  /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.ImageInsert, {}),
2649
2917
  /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Link, {}),
2650
- /* @__PURE__ */ jsxRuntime.jsx(DefinedTermButtons, {})
2918
+ /* @__PURE__ */ jsxRuntime.jsx(DefinedTermButtons, {}),
2919
+ /* @__PURE__ */ jsxRuntime.jsx(QuickParts, {})
2651
2920
  ] }),
2921
+ tab === "Design" && /* @__PURE__ */ jsxRuntime.jsx(HouseTemplatePanel, {}),
2652
2922
  tab === "References" && /* @__PURE__ */ jsxRuntime.jsx(NoteButtons, {}),
2653
2923
  tab === "Review" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2654
2924
  /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.EditingMode, {}),
@@ -2723,11 +2993,16 @@ function NativeDocxEditor({
2723
2993
  async function start() {
2724
2994
  const fonts = await adapter.loadFonts();
2725
2995
  if (isDraft || snapshot) {
2726
- const data = isDraft ? !streamRef.current && drafts.get(documentId) || await (await adapter.request("/prepare", {
2996
+ const data = isDraft ? !streamRef.current && drafts.get(documentId) || (draftContent === "" && adapter.houseTemplate ? await (async () => {
2997
+ const template$1 = await resolveHouseTemplate(adapter.houseTemplate);
2998
+ return template.newFromTemplate(template$1.bytes, {
2999
+ attachedTemplate: templateFileName(template$1)
3000
+ });
3001
+ })() : await (await adapter.request("/prepare", {
2727
3002
  method: "POST",
2728
3003
  headers: { "Content-Type": "application/json" },
2729
3004
  body: JSON.stringify({ content: draftContent })
2730
- })).arrayBuffer() : await (await adapter.request(contentPath(documentId))).arrayBuffer();
3005
+ })).arrayBuffer()) : await (await adapter.request(contentPath(documentId))).arrayBuffer();
2731
3006
  if (!cancelled) {
2732
3007
  setReady({
2733
3008
  document: new Uint8Array(data),
@@ -2989,68 +3264,78 @@ function NativeDocxEditor({
2989
3264
  if (change.source !== "load") changed();
2990
3265
  },
2991
3266
  onFontError: (e) => setError(e.message),
2992
- children: /* @__PURE__ */ jsxRuntime.jsxs(
3267
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2993
3268
  DefinedTermsProvider,
2994
3269
  {
2995
3270
  load: adapter.definitions,
2996
3271
  editable: !stream && !snapshot && ready.canEdit,
2997
3272
  notify: adapter.notify,
2998
- children: [
2999
- /* @__PURE__ */ jsxRuntime.jsx(
3000
- react.DocxEditor.RevisionMarkup,
3001
- {
3002
- insertions: { mark: "underline", color: "blue" },
3003
- deletions: { mark: "strikethrough", color: "red" },
3004
- movedFrom: { mark: "doubleStrikethrough", color: "green" },
3005
- movedTo: { mark: "doubleUnderline", color: "green" },
3006
- trackMoves: true
3007
- }
3008
- ),
3009
- !stream && /* @__PURE__ */ jsxRuntime.jsx(
3010
- DocxRibbon,
3011
- {
3012
- onSave: () => void saveVersion(),
3013
- badge: (
3014
- // Says the document is shared live, in place of a title row above the ribbon.
3015
- ready.room && ready.canEdit && !snapshot ? /* @__PURE__ */ jsxRuntime.jsx("span", { title: "Edits sync live with everyone who has this document open", children: "Co-edit mode" }) : void 0
3273
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
3274
+ HouseTemplateProvider,
3275
+ {
3276
+ enabled: !stream,
3277
+ host: adapter.houseTemplate,
3278
+ documentId: isDraft || snapshot ? void 0 : documentId,
3279
+ editable: !stream && !snapshot && ready.canEdit,
3280
+ notify: adapter.notify,
3281
+ children: [
3282
+ /* @__PURE__ */ jsxRuntime.jsx(
3283
+ react.DocxEditor.RevisionMarkup,
3284
+ {
3285
+ insertions: { mark: "underline", color: "blue" },
3286
+ deletions: { mark: "strikethrough", color: "red" },
3287
+ movedFrom: { mark: "doubleStrikethrough", color: "green" },
3288
+ movedTo: { mark: "doubleUnderline", color: "green" },
3289
+ trackMoves: true
3290
+ }
3291
+ ),
3292
+ !stream && /* @__PURE__ */ jsxRuntime.jsx(
3293
+ DocxRibbon,
3294
+ {
3295
+ onSave: () => void saveVersion(),
3296
+ badge: (
3297
+ // Says the document is shared live, in place of a title row above the ribbon.
3298
+ ready.room && ready.canEdit && !snapshot ? /* @__PURE__ */ jsxRuntime.jsx("span", { title: "Edits sync live with everyone who has this document open", children: "Co-edit mode" }) : void 0
3299
+ )
3300
+ }
3301
+ ),
3302
+ !stream && /* @__PURE__ */ jsxRuntime.jsx(WordShortcuts, { scope: stageRef }),
3303
+ /* @__PURE__ */ jsxRuntime.jsxs(
3304
+ "div",
3305
+ {
3306
+ className: "native-docx-stage",
3307
+ ref: stageRef,
3308
+ onMouseDownCapture: (event) => {
3309
+ if (event.button === 2 && ref.current?.getSelectionPlacement())
3310
+ event.preventDefault();
3311
+ },
3312
+ children: [
3313
+ /* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
3314
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
3315
+ /* @__PURE__ */ jsxRuntime.jsx(
3316
+ DocxMentions,
3317
+ {
3318
+ initialCommentId,
3319
+ mentions: adapter.mentions,
3320
+ notify: adapter.notify,
3321
+ getAgentStatus: adapter.getAgentStatus,
3322
+ requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
3323
+ children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}) }) })
3324
+ }
3325
+ ),
3326
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
3327
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
3328
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
3329
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
3330
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, {})
3331
+ ] }),
3332
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
3333
+ ]
3334
+ }
3016
3335
  )
3017
- }
3018
- ),
3019
- !stream && /* @__PURE__ */ jsxRuntime.jsx(WordShortcuts, { scope: stageRef }),
3020
- /* @__PURE__ */ jsxRuntime.jsxs(
3021
- "div",
3022
- {
3023
- className: "native-docx-stage",
3024
- ref: stageRef,
3025
- onMouseDownCapture: (event) => {
3026
- if (event.button === 2 && ref.current?.getSelectionPlacement())
3027
- event.preventDefault();
3028
- },
3029
- children: [
3030
- /* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
3031
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
3032
- /* @__PURE__ */ jsxRuntime.jsx(
3033
- DocxMentions,
3034
- {
3035
- initialCommentId,
3036
- mentions: adapter.mentions,
3037
- notify: adapter.notify,
3038
- getAgentStatus: adapter.getAgentStatus,
3039
- requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
3040
- children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}) }) })
3041
- }
3042
- ),
3043
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
3044
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
3045
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
3046
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
3047
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, {})
3048
- ] }),
3049
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
3050
- ]
3051
- }
3052
- )
3053
- ]
3336
+ ]
3337
+ }
3338
+ )
3054
3339
  }
3055
3340
  )
3056
3341
  }
@@ -3147,6 +3432,7 @@ async function loadFonts(baseUrl) {
3147
3432
  };
3148
3433
  }
3149
3434
 
3435
+ exports.BUILTIN_TEMPLATE_NAME = BUILTIN_TEMPLATE_NAME;
3150
3436
  exports.DEFAULT_DEFINED_TERMS_LABELS = DEFAULT_DEFINED_TERMS_LABELS;
3151
3437
  exports.DEFINED_TERM_TRIGGER = DEFINED_TERM_TRIGGER;
3152
3438
  exports.DefinedTermsProvider = DefinedTermsProvider;
@@ -3155,17 +3441,23 @@ exports.DocxEditorReview = DocxEditorReview;
3155
3441
  exports.DocxMentions = DocxMentions;
3156
3442
  exports.DocxParticipants = DocxParticipants;
3157
3443
  exports.DocxRibbon = DocxRibbon;
3444
+ exports.HouseTemplateProvider = HouseTemplateProvider;
3158
3445
  exports.NativeDocxEditor = NativeDocxEditor;
3446
+ exports.builtinHouseTemplate = builtinHouseTemplate;
3447
+ exports.contentPath = contentPath;
3159
3448
  exports.editorPort = editorPort;
3160
3449
  exports.findDefinitionsSection = findDefinitionsSection;
3161
3450
  exports.insertDefinedTerm = insertDefinedTerm;
3162
3451
  exports.loadDocxFonts = loadDocxFonts;
3163
3452
  exports.normalizeDocxExport = normalizeDocxExport;
3453
+ exports.resolveHouseTemplate = resolveHouseTemplate;
3164
3454
  exports.reviewModule = reviewModule;
3455
+ exports.templateFileName = templateFileName;
3165
3456
  exports.updateDefinitions = updateDefinitions;
3166
3457
  exports.useDefinedTerms = useDefinedTerms;
3458
+ exports.useHouseTemplate = useHouseTemplate;
3167
3459
  exports.useReview = useReview;
3168
3460
  exports.useReviewItem = useReviewItem;
3169
3461
  exports.withDirectEditing = withDirectEditing;
3170
- //# sourceMappingURL=chunk-HGJGALLN.cjs.map
3171
- //# sourceMappingURL=chunk-HGJGALLN.cjs.map
3462
+ //# sourceMappingURL=chunk-MIMVRMKC.cjs.map
3463
+ //# sourceMappingURL=chunk-MIMVRMKC.cjs.map