@stll/folio-vue 0.6.0 → 0.7.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.
@@ -2,7 +2,7 @@ import { CSSProperties, VNodeChild } from 'vue';
2
2
  import { Plugin } from 'prosemirror-state';
3
3
  import { EditorView } from 'prosemirror-view';
4
4
  import { XmlFragment } from 'yjs';
5
- import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioReviewChange } from '@stll/folio-core/ai-edits';
5
+ import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioCommentAnchor, FolioDocumentNavigationTarget, FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, FolioReviewChange } from '@stll/folio-core/ai-edits';
6
6
  import { ContentControlFilter, SetContentControlContentInput, SetContentControlValueInput } from '@stll/folio-core/content-controls';
7
7
  import { FolioEditor } from '@stll/folio-core/controller/folioEditor';
8
8
  import { DocxCompatibility } from '@stll/folio-core/docx/compatibility';
@@ -411,6 +411,8 @@ export type DocxEditorRef = {
411
411
  * accept. Without `snapshot`, falls back to a fresh-from-live-doc snapshot.
412
412
  */
413
413
  scrollToBlock: (blockId: string, snapshot?: FolioAIEditSnapshot) => boolean;
414
+ /** Resolve a stable block or text-range target and reveal it in the editor. */
415
+ showInDocument: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => boolean;
414
416
  /**
415
417
  * The tracked changes (insertions and deletions) present in the live
416
418
  * document, read from the current ProseMirror `state.doc`. Empty array
@@ -433,6 +435,8 @@ export type DocxEditorRef = {
433
435
  * out of range or the layout hasn't been computed yet.
434
436
  */
435
437
  getPageText: (page: number) => string | null;
438
+ /** Resolve a stable block or text range to its real 1-based rendered page. */
439
+ getTargetPage: (target: FolioDocumentNavigationTarget, snapshot?: FolioAIEditSnapshot) => number | null;
436
440
  /**
437
441
  * List every block-level content control in the live document, filtered by
438
442
  * tag / alias / id / sdtType. Returns the modeled SdtProperties projection
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useZoom-BB6hSMvM.cjs");let t=require("vue"),n=require("prosemirror-history"),r=require("@stll/folio-core/utils/clipboard"),i=require("@stll/folio-core/managers/ClipboardManager"),a=require("@stll/folio-core/managers/TableSelectionManager"),o=require("@stll/folio-core/prosemirror/utils/visualLineNavigation"),s=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges");function c(e={}){let{onCopy:n,onCut:i,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c}=e,l=(0,t.ref)(!1),u=(0,t.ref)(null),d=c?{onError:c}:{};async function f(e){if(l.value)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&n?.(e),t}finally{l.value=!1}}async function p(e){if(l.value||!s)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&i?.(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=``,i=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(i=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,r.parseClipboardHtml)(n,i,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 l({isOpen:e,onClose:n,align:r=`left`}){let i=(0,t.ref)(null),a=(0,t.ref)(null),o=(0,t.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 t=e.target;t instanceof Node&&i.value&&!i.value.contains(t)&&a.value&&!a.value.contains(t)&&n()}function l(e){e.key===`Escape`&&n()}function u(e){let t=e.target;t instanceof Node&&a.value&&a.value.contains(t)||n()}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,t.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,t.onScopeDispose)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function u(e,r){let i=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.undoDepth)(t.state)>0:!1}),a=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.redoDepth)(t.state)>0:!1});function o(){let t=e.value;return t?(0,n.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,n.redo)(t.state,t.dispatch):!1}return{canUndo:i,canRedo:a,undo:o,redo:s}}var d={backgroundColor:`rgba(26, 115, 232, 0.3)`,borderRadius:0,zIndex:0,opacity:1,mixBlendMode:`multiply`};function f(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 p(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 m(e){return p(f(e))}function h(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function g(e){let t=window.getSelection();return!t||t.rangeCount===0?!1:e.contains(t.getRangeAt(0).commonAncestorContainer)}var _=`docx-selection-styles`,v=null;function y(){v&&=(v.remove(),null),document.getElementById(_)?.remove()}function b(e=d){y();let t=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useZoom-C7jhL696.cjs");let t=require("vue"),n=require("prosemirror-history"),r=require("@stll/folio-core/utils/clipboard"),i=require("@stll/folio-core/managers/ClipboardManager"),a=require("@stll/folio-core/managers/TableSelectionManager"),o=require("@stll/folio-core/prosemirror/utils/visualLineNavigation"),s=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges");function c(e={}){let{onCopy:n,onCut:i,onPaste:a,cleanWordFormatting:o=!0,editable:s=!0,onError:c}=e,l=(0,t.ref)(!1),u=(0,t.ref)(null),d=c?{onError:c}:{};async function f(e){if(l.value)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&n?.(e),t}finally{l.value=!1}}async function p(e){if(l.value||!s)return!1;l.value=!0;try{let t=await(0,r.copyRuns)(e.runs,d);return t&&i?.(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=``,i=``;for(let e of t)e.types.includes(`text/html`)&&(n=await(await e.getType(`text/html`)).text()),e.types.includes(`text/plain`)&&(i=await(await e.getType(`text/plain`)).text());e&&(n=``);let s=(0,r.parseClipboardHtml)(n,i,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 l({isOpen:e,onClose:n,align:r=`left`}){let i=(0,t.ref)(null),a=(0,t.ref)(null),o=(0,t.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 t=e.target;t instanceof Node&&i.value&&!i.value.contains(t)&&a.value&&!a.value.contains(t)&&n()}function l(e){e.key===`Escape`&&n()}function u(e){let t=e.target;t instanceof Node&&a.value&&a.value.contains(t)||n()}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,t.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,t.onScopeDispose)(f);function p(e){e.preventDefault(),e.stopPropagation()}return{containerRef:i,dropdownRef:a,dropdownStyle:o,handleMouseDown:p}}function u(e,r){let i=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.undoDepth)(t.state)>0:!1}),a=(0,t.computed)(()=>{r.value;let t=e.value;return t?(0,n.redoDepth)(t.state)>0:!1});function o(){let t=e.value;return t?(0,n.undo)(t.state,t.dispatch):!1}function s(){let t=e.value;return t?(0,n.redo)(t.state,t.dispatch):!1}return{canUndo:i,canRedo:a,undo:o,redo:s}}var d={backgroundColor:`rgba(26, 115, 232, 0.3)`,borderRadius:0,zIndex:0,opacity:1,mixBlendMode:`multiply`};function f(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 p(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 m(e){return p(f(e))}function h(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function g(e){let t=window.getSelection();return!t||t.rangeCount===0?!1:e.contains(t.getRangeAt(0).commonAncestorContainer)}var _=`docx-selection-styles`,v=null;function y(){v&&=(v.remove(),null),document.getElementById(_)?.remove()}function b(e=d){y();let t=`
2
2
  /* DOCX Editor Selection Highlighting */
3
3
 
4
4
  .docx-editor [contenteditable="true"]::selection,
@@ -1,4 +1,4 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "./useZoom-BxDANpqb.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./useZoom-zJvuJlUd.js";
2
2
  import { computed as o, onBeforeUnmount as s, onMounted as c, onScopeDispose as l, ref as u, watch as d } from "vue";
3
3
  import { redo as f, redoDepth as p, undo as m, undoDepth as h } from "prosemirror-history";
4
4
  import { copyRuns as g, parseClipboardHtml as _, runsToClipboardContent as v } from "@stll/folio-core/utils/clipboard";