@stll/folio-vue 0.22.3 → 0.24.0
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 +24 -0
- package/dist/components/DocxEditor/types.d.ts +5 -3
- package/dist/composables/useDocxEditor.d.ts +1 -0
- package/dist/composables/useFontLifecycle.d.ts +1 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +1 -1
- package/dist/folio-vue.css +1 -156
- package/dist/index.cjs +1 -1
- package/dist/index.js +1220 -1215
- package/dist/{useZoom-D8Wi1XkB.js → useZoom-BA92aWwm.js} +171 -164
- package/dist/{useZoom-CkbPWZ64.cjs → useZoom-Bv8t7dYu.cjs} +1 -1
- package/dist/utils/embeddedFonts.d.ts +1 -1
- package/package.json +11 -12
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @stll/folio-vue
|
|
2
|
+
|
|
3
|
+
Vue 3 adapter for the folio document editor.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add @stll/folio-vue vue@^3.3.0 \
|
|
9
|
+
prosemirror-commands@^1.7.1 prosemirror-dropcursor@^1.8.2 prosemirror-gapcursor@^1.4.1 prosemirror-history@^1.5.0 \
|
|
10
|
+
prosemirror-inputrules@^1.5.0 prosemirror-keymap@^1.2.3 prosemirror-model@^1.25.9 prosemirror-state@^1.4.4 \
|
|
11
|
+
prosemirror-tables@^1.8.5 prosemirror-transform@^1.12.0 prosemirror-view@^1.42.6 y-prosemirror@^1.3.7 \
|
|
12
|
+
y-protocols@^1.0.6 yjs@^13.6.31
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
ProseMirror and Yjs packages are required peers, including the collaboration
|
|
16
|
+
packages `y-prosemirror` and `y-protocols`. Install one compatible copy of each in the host
|
|
17
|
+
application so schemas, plugins, editor states, and collaborative documents share
|
|
18
|
+
the same runtime. The command above includes the complete editor peer closure.
|
|
19
|
+
|
|
20
|
+
Import `DocxEditor` from `@stll/folio-vue` and load
|
|
21
|
+
`@stll/folio-vue/editor.css` once in your application.
|
|
22
|
+
|
|
23
|
+
Keyboard shortcuts default to the editor root. Set `keyboardShortcuts="document"`
|
|
24
|
+
only when this editor should own shortcuts across the host page.
|
|
@@ -3,7 +3,7 @@ import { PageRendererName } from '@stll/folio-core/display-list/editor/pageRende
|
|
|
3
3
|
import { Plugin } from 'prosemirror-state';
|
|
4
4
|
import { EditorView } from 'prosemirror-view';
|
|
5
5
|
import { XmlFragment } from 'yjs';
|
|
6
|
-
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentNavigationTarget, FolioPendingSuggestionLoadResult, FolioPendingSuggestionRecord, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioReviewChange } from '@stll/folio-core/ai-edits';
|
|
6
|
+
import { FolioAIEditApplyMode, FolioUndefinedReferencePolicy, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentNavigationTarget, FolioPendingSuggestionLoadResult, FolioPendingSuggestionRecord, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioReviewChange } from '@stll/folio-core/ai-edits';
|
|
7
7
|
import { ContentControlFilter, SetContentControlContentInput, SetContentControlValueInput } from '@stll/folio-core/content-controls';
|
|
8
8
|
import { FolioEditor } from '@stll/folio-core/controller/folioEditor';
|
|
9
9
|
import { DocxCompatibility } from '@stll/folio-core/docx/compatibility';
|
|
@@ -164,9 +164,9 @@ export type DocxEditorProps = {
|
|
|
164
164
|
* replace (Cmd/Ctrl+F, Cmd/Ctrl+H), hyperlink (Cmd/Ctrl+K), `File > Open`
|
|
165
165
|
* (Cmd/Ctrl+O) and zoom (Cmd/Ctrl+0, +, -). Editing keymaps inside the
|
|
166
166
|
* document body are unaffected.
|
|
167
|
-
* - `"document"`: every press on the page
|
|
167
|
+
* - `"document"`: every press on the page; for a page whose only
|
|
168
168
|
* surface is the editor.
|
|
169
|
-
* - `"editor"
|
|
169
|
+
* - `"editor"` (default): only a press whose target is inside this editor, so a host
|
|
170
170
|
* that docks the editor beside other panes keeps its own bindings
|
|
171
171
|
* elsewhere.
|
|
172
172
|
* - `"none"`: the editor answers no page-level press. The host dispatches
|
|
@@ -349,6 +349,7 @@ export type DocxEditorCollaboration = {
|
|
|
349
349
|
yXmlFragment: XmlFragment;
|
|
350
350
|
};
|
|
351
351
|
export type DocxEditorApplyDocumentOperationsOptions = {
|
|
352
|
+
undefinedReferences: FolioUndefinedReferencePolicy;
|
|
352
353
|
snapshot: FolioAIEditSnapshot;
|
|
353
354
|
batch: FolioDocumentOperationBatch;
|
|
354
355
|
author?: string;
|
|
@@ -438,6 +439,7 @@ export type DocxEditorRef = {
|
|
|
438
439
|
undoDocumentOperations: (undoHandle: FolioDocumentOperationUndoHandle) => FolioDocumentOperationUndoResult;
|
|
439
440
|
/** Apply AI-authored operations against a previously created block snapshot. */
|
|
440
441
|
applyAIEditOperations: (options: {
|
|
442
|
+
undefinedReferences: FolioUndefinedReferencePolicy;
|
|
441
443
|
snapshot: FolioAIEditSnapshot;
|
|
442
444
|
operations: FolioAIEditOperation[];
|
|
443
445
|
mode?: FolioAIEditApplyMode;
|
|
@@ -116,6 +116,7 @@ export type HeaderFooterSelectionState = {
|
|
|
116
116
|
to: number;
|
|
117
117
|
};
|
|
118
118
|
export type UseDocxEditorReturn = {
|
|
119
|
+
setEmbeddedFontFamilies: (families: ReadonlyMap<string, string> | null) => void;
|
|
119
120
|
/** The headless controller (imperative API + layout access + events). */
|
|
120
121
|
editor: FolioEditor;
|
|
121
122
|
/** Off-screen ProseMirror EditorView, or null before mount. */
|
|
@@ -8,6 +8,7 @@ export type UseFontLifecycleOptions = {
|
|
|
8
8
|
} | null;
|
|
9
9
|
fonts: () => ReadonlyArray<FontDefinition> | undefined;
|
|
10
10
|
remeasure: () => void;
|
|
11
|
+
setEmbeddedFontFamilies: (families: ReadonlyMap<string, string> | null) => void;
|
|
11
12
|
};
|
|
12
13
|
export type FontLifecycleDependencies = {
|
|
13
14
|
loadEmbedded: (buffer: ArrayBuffer) => Promise<LoadedEmbeddedFonts>;
|
package/dist/composables.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useFindReplace-ZCrdvwEk.cjs"),t=require("./useZoom-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useFindReplace-ZCrdvwEk.cjs"),t=require("./useZoom-Bv8t7dYu.cjs");let n=require("vue"),r=require("prosemirror-history"),i=require("@stll/folio-core/utils/clipboard"),a=require("@stll/folio-core/managers/ClipboardManager"),o=require("@stll/folio-core/managers/TableSelectionManager"),s=require("@stll/folio-core/prosemirror/utils/visualLineNavigation"),c=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges");function l(e={}){let{onCopy:t,onCut:r,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c}=e,l=(0,n.ref)(!1),u=(0,n.ref)(null),d=c?{onError:c}:{};async function f(e){if(l.value)return!1;l.value=!0;try{let n=await(0,i.copyRuns)(e.runs,d);return n&&t?.(e),n}finally{l.value=!1}}async function p(e){if(l.value||!s)return!1;l.value=!0;try{let t=await(0,i.copyRuns)(e.runs,d);return t&&r?.(e),t}finally{l.value=!1}}async function m(e=!1){if(l.value||!s)return null;l.value=!0;try{if(navigator.clipboard&&navigator.clipboard.read){let t=await navigator.clipboard.read(),n=``,r=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(r=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,i.parseClipboardHtml)(n,r,o);return u.value=s,a?.(s,e),s}return null}catch(e){return c?.(e instanceof Error?e:Error(String(e))),null}finally{l.value=!1}}return{copy:f,cut:p,paste:m,isProcessing:l,lastPastedContent:u}}function u({isOpen:e,onClose:t,align:r=`left`}){let i=(0,n.ref)(null),a=(0,n.ref)(null),o=(0,n.ref)({position:`fixed`,top:`0px`,left:`0px`,zIndex:1e4});function s(e,t){o.value={position:`fixed`,top:e+`px`,left:t+`px`,zIndex:1e4}}function c(e){let n=e.target;n instanceof Node&&i.value&&!i.value.contains(n)&&a.value&&!a.value.contains(n)&&t()}function l(e){e.key===`Escape`&&t()}function u(e){let n=e.target;n instanceof Node&&a.value&&a.value.contains(n)||t()}function d(){document.addEventListener(`mousedown`,c),document.addEventListener(`keydown`,l),window.addEventListener(`scroll`,u,!0)}function f(){document.removeEventListener(`mousedown`,c),document.removeEventListener(`keydown`,l),window.removeEventListener(`scroll`,u,!0)}(0,n.watch)(e,e=>{if(!e){f();return}let t=i.value;if(!t)return;let n=t.getBoundingClientRect();r===`right`?requestAnimationFrame(()=>{let e=a.value;if(e){let t=e.getBoundingClientRect();s(n.bottom+4,n.right-t.width)}else s(n.bottom+4,n.left)}):s(n.bottom+4,n.left),d()}),(0,n.onScopeDispose)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function d(e,t){let i=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,r.undoDepth)(n.state)>0:!1}),a=(0,n.computed)(()=>{t.value;let n=e.value;return n?(0,r.redoDepth)(n.state)>0:!1});function o(){let t=e.value;return t?(0,r.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,r.redo)(t.state,t.dispatch):!1}return{canUndo:i,canRedo:a,undo:o,redo:s}}var f={backgroundColor:`rgba(26, 115, 232, 0.3)`,borderRadius:0,zIndex:0,opacity:1,mixBlendMode:`multiply`};function p(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return[];let n=t.getRangeAt(0);if(e&&!e.contains(n.commonAncestorContainer))return[];let r=0,i=0;if(e){let t=e.getBoundingClientRect();r=t.left+e.scrollLeft,i=t.top+e.scrollTop}let a=[];for(let e of n.getClientRects())e.width===0&&e.height===0||a.push({left:e.left-r,top:e.top-i,width:e.width,height:e.height});return a}function m(e,t=2){if(e.length<=1)return e;let n=[...e].sort((e,n)=>Math.abs(e.top-n.top)<t?e.left-n.left:e.top-n.top),r=n[0];if(!r)return e;let i=[],a={...r};for(let e=1;e<n.length;e++){let r=n[e];if(!r)continue;let o=Math.abs(r.top-a.top)<t,s=r.left<=a.left+a.width+t;if(o&&s){let e=Math.max(a.left+a.width,r.left+r.width);a.width=e-a.left,a.height=Math.max(a.height,r.height)}else i.push(a),a={...r}}return i.push(a),i}function h(e){return m(p(e))}function g(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function _(e){let t=window.getSelection();return!t||t.rangeCount===0?!1:e.contains(t.getRangeAt(0).commonAncestorContainer)}var v=`docx-selection-styles`,y=null;function b(){y&&=(y.remove(),null),document.getElementById(v)?.remove()}function x(e=f){b();let t=`
|
|
2
2
|
/* DOCX Editor Selection Highlighting */
|
|
3
3
|
|
|
4
4
|
.docx-editor [contenteditable="true"]::selection,
|
package/dist/composables.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./useFindReplace-CL8Rbc3y.js";
|
|
2
|
-
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./useZoom-
|
|
2
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./useZoom-BA92aWwm.js";
|
|
3
3
|
import { computed as d, onBeforeUnmount as f, onMounted as p, onScopeDispose as m, ref as h, watch as g } from "vue";
|
|
4
4
|
import { redo as _, redoDepth as v, undo as y, undoDepth as b } from "prosemirror-history";
|
|
5
5
|
import { copyRuns as x, parseClipboardHtml as S, runsToClipboardContent as C } from "@stll/folio-core/utils/clipboard";
|