@eigenpal/docx-editor-core 1.3.0 → 1.3.1
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/dist/chunk-4MYKVWNF.js +1 -0
- package/dist/{chunk-Q5B5GKXD.mjs → chunk-55XWETY4.mjs} +1 -1
- package/dist/chunk-6QO4O52Y.mjs +1 -0
- package/dist/chunk-DE2V4X3B.mjs +1 -0
- package/dist/{chunk-TJRROR6U.js → chunk-DG2CMDSM.js} +1 -1
- package/dist/chunk-HPJBZL37.mjs +1 -0
- package/dist/{chunk-TURYWKNS.js → chunk-J3YFJDZD.js} +1 -1
- package/dist/chunk-JHTURDPX.mjs +1 -0
- package/dist/chunk-LX35TFGF.mjs +1 -0
- package/dist/chunk-NRWQ65NX.js +1 -0
- package/dist/{chunk-WDBZ3QVB.js → chunk-QLAIOTQB.js} +1 -1
- package/dist/chunk-RSU4HTC6.js +1 -0
- package/dist/{chunk-L6YTCHOQ.mjs → chunk-W7CQRQZ6.mjs} +1 -1
- package/dist/chunk-YGWUKRFD.mjs +1 -0
- package/dist/chunk-YM7SMTYY.js +1 -0
- package/dist/chunk-YPKIQMPR.js +1 -0
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/editor/index.d.mts +128 -0
- package/dist/editor/index.d.ts +128 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/{footnotes-BtVc6VFl.d.mts → footnotes-BZ24OTAT.d.mts} +11 -1
- package/dist/{footnotes-DcUMWXul.d.ts → footnotes-DMsicPGd.d.ts} +11 -1
- package/dist/{headerFooterLayout-4E-S4Aay.d.ts → headerFooterLayout-AtAOhM8E.d.ts} +18 -2
- package/dist/{headerFooterLayout-DlJLWmpR.d.mts → headerFooterLayout-CU6hvszp.d.mts} +18 -2
- package/dist/layout-bridge/clickToPositionDom.js +1 -1
- package/dist/layout-bridge/clickToPositionDom.mjs +1 -1
- package/dist/layout-bridge/index.d.mts +109 -5
- package/dist/layout-bridge/index.d.ts +109 -5
- package/dist/layout-bridge/index.js +1 -1
- package/dist/layout-bridge/index.mjs +1 -1
- package/dist/layout-bridge/measuring/index.d.mts +5 -95
- package/dist/layout-bridge/measuring/index.d.ts +5 -95
- package/dist/layout-bridge/measuring/index.js +1 -1
- package/dist/layout-bridge/measuring/index.mjs +1 -1
- package/dist/layout-bridge/tableInsertHover.js +1 -1
- package/dist/layout-bridge/tableInsertHover.mjs +1 -1
- package/dist/layout-engine/index.js +1 -1
- package/dist/layout-engine/index.mjs +1 -1
- package/dist/layout-painter/index.d.mts +2 -2
- package/dist/layout-painter/index.d.ts +2 -2
- package/dist/layout-painter/index.js +1 -1
- package/dist/layout-painter/index.mjs +1 -1
- package/dist/layout-painter/renderPage.d.mts +8 -3
- package/dist/layout-painter/renderPage.d.ts +8 -3
- package/dist/layout-painter/renderPage.js +1 -1
- package/dist/layout-painter/renderPage.mjs +1 -1
- package/dist/measureBlocksPipeline-BMqbRFQB.d.mts +96 -0
- package/dist/measureBlocksPipeline-iYNzAH-o.d.ts +96 -0
- package/dist/prosemirror/applyFormatting.d.mts +67 -0
- package/dist/prosemirror/applyFormatting.d.ts +67 -0
- package/dist/prosemirror/applyFormatting.js +1 -0
- package/dist/prosemirror/applyFormatting.mjs +1 -0
- package/dist/prosemirror/commentIdAllocator.d.mts +50 -0
- package/dist/prosemirror/commentIdAllocator.d.ts +50 -0
- package/dist/prosemirror/commentIdAllocator.js +1 -0
- package/dist/prosemirror/commentIdAllocator.mjs +1 -0
- package/dist/prosemirror/commentOps.d.mts +46 -0
- package/dist/prosemirror/commentOps.d.ts +46 -0
- package/dist/prosemirror/commentOps.js +1 -0
- package/dist/prosemirror/commentOps.mjs +1 -0
- package/dist/prosemirror/imageCommit.d.mts +35 -0
- package/dist/prosemirror/imageCommit.d.ts +35 -0
- package/dist/prosemirror/imageCommit.js +1 -0
- package/dist/prosemirror/imageCommit.mjs +1 -0
- package/dist/prosemirror/paraText.d.mts +52 -0
- package/dist/prosemirror/paraText.d.ts +52 -0
- package/dist/prosemirror/paraText.js +1 -0
- package/dist/prosemirror/paraText.mjs +1 -0
- package/dist/prosemirror/queries.d.mts +65 -0
- package/dist/prosemirror/queries.d.ts +65 -0
- package/dist/prosemirror/queries.js +2 -0
- package/dist/prosemirror/queries.mjs +2 -0
- package/dist/prosemirror/tableResize.d.mts +58 -0
- package/dist/prosemirror/tableResize.d.ts +58 -0
- package/dist/prosemirror/tableResize.js +1 -0
- package/dist/prosemirror/tableResize.mjs +1 -0
- package/dist/utils/autoScroll.d.mts +24 -0
- package/dist/utils/autoScroll.d.ts +24 -0
- package/dist/utils/autoScroll.js +1 -0
- package/dist/utils/autoScroll.mjs +1 -0
- package/package.json +73 -1
- package/dist/chunk-72KLR6TJ.mjs +0 -1
- package/dist/chunk-7JQVKJRN.mjs +0 -1
- package/dist/chunk-7WGN2OBZ.js +0 -1
- package/dist/chunk-JUMHC5Z6.mjs +0 -1
- package/dist/chunk-MEVZCB56.mjs +0 -1
- package/dist/chunk-T4RYVPAB.js +0 -1
- package/dist/chunk-XWC67YLW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'../chunk-QYUPLKLP.mjs';var d=-1;function i(){let e=1;return {next:()=>e++,seedAbove(t){t>=e&&(e=t+1);}}}function a(e,t,n){let o=0;for(let r of t??[])o=Math.max(o,r.id);n&&n.state.doc.descendants(r=>{for(let m of r.marks)m.attrs.revisionId!=null&&(o=Math.max(o,m.attrs.revisionId));}),e.seedAbove(o);}export{d as PENDING_COMMENT_ID,i as createCommentIdAllocator,a as seedCommentAllocator};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { e as Comment } from '../content-3xF4WDE8.mjs';
|
|
3
|
+
import { CommentIdAllocator } from './commentIdAllocator.mjs';
|
|
4
|
+
import '../formatting-BH4hcZiq.mjs';
|
|
5
|
+
import '../colors-C3vA7HUU.mjs';
|
|
6
|
+
import '../docx/wrapTypes.mjs';
|
|
7
|
+
import '../watermark-DAcnAs_J.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Comment + tracked-change (proposeChange) PM transaction builders shared by
|
|
11
|
+
* the React and Vue adapters. They locate the target range, apply the mark(s),
|
|
12
|
+
* dispatch, and return a result. ID allocation lives in `commentIdAllocator.ts`
|
|
13
|
+
* and is injected. Adapter-specific state mutation, event emission, and sidebar
|
|
14
|
+
* UI stay in each adapter.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Build a Comment object with a freshly-allocated ID. */
|
|
18
|
+
declare function createComment(allocator: CommentIdAllocator, text: string, authorName: string, parentId?: number): Comment;
|
|
19
|
+
interface AddCommentOptions {
|
|
20
|
+
paraId: string;
|
|
21
|
+
text: string;
|
|
22
|
+
author: string;
|
|
23
|
+
search?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Locate the comment range (paragraph, narrowed by `search`), add the comment
|
|
27
|
+
* mark, dispatch, and return the created Comment. Returns null when the schema
|
|
28
|
+
* lacks a comment mark or the range can't be resolved. The caller owns adding
|
|
29
|
+
* the comment to its own state and showing the sidebar.
|
|
30
|
+
*/
|
|
31
|
+
declare function addCommentToRange(view: EditorView, options: AddCommentOptions, allocator: CommentIdAllocator): Comment | null;
|
|
32
|
+
interface ProposeChangeOptions {
|
|
33
|
+
paraId: string;
|
|
34
|
+
search: string;
|
|
35
|
+
replaceWith: string;
|
|
36
|
+
author: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Apply a tracked change (insertion / deletion / replace) to the located range.
|
|
40
|
+
* `search === ''` means a pure insertion at the paragraph end; `replaceWith ===
|
|
41
|
+
* ''` means a pure deletion. Refuses to layer onto an existing tracked change.
|
|
42
|
+
* Returns true when a change was dispatched, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
declare function applyProposedChange(view: EditorView, options: ProposeChangeOptions, allocator: CommentIdAllocator): boolean;
|
|
45
|
+
|
|
46
|
+
export { type AddCommentOptions, type ProposeChangeOptions, addCommentToRange, applyProposedChange, createComment };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { e as Comment } from '../content-C8fc_tL6.js';
|
|
3
|
+
import { CommentIdAllocator } from './commentIdAllocator.js';
|
|
4
|
+
import '../formatting-_OXU8gLB.js';
|
|
5
|
+
import '../colors-C3vA7HUU.js';
|
|
6
|
+
import '../docx/wrapTypes.js';
|
|
7
|
+
import '../watermark-DAcnAs_J.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Comment + tracked-change (proposeChange) PM transaction builders shared by
|
|
11
|
+
* the React and Vue adapters. They locate the target range, apply the mark(s),
|
|
12
|
+
* dispatch, and return a result. ID allocation lives in `commentIdAllocator.ts`
|
|
13
|
+
* and is injected. Adapter-specific state mutation, event emission, and sidebar
|
|
14
|
+
* UI stay in each adapter.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Build a Comment object with a freshly-allocated ID. */
|
|
18
|
+
declare function createComment(allocator: CommentIdAllocator, text: string, authorName: string, parentId?: number): Comment;
|
|
19
|
+
interface AddCommentOptions {
|
|
20
|
+
paraId: string;
|
|
21
|
+
text: string;
|
|
22
|
+
author: string;
|
|
23
|
+
search?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Locate the comment range (paragraph, narrowed by `search`), add the comment
|
|
27
|
+
* mark, dispatch, and return the created Comment. Returns null when the schema
|
|
28
|
+
* lacks a comment mark or the range can't be resolved. The caller owns adding
|
|
29
|
+
* the comment to its own state and showing the sidebar.
|
|
30
|
+
*/
|
|
31
|
+
declare function addCommentToRange(view: EditorView, options: AddCommentOptions, allocator: CommentIdAllocator): Comment | null;
|
|
32
|
+
interface ProposeChangeOptions {
|
|
33
|
+
paraId: string;
|
|
34
|
+
search: string;
|
|
35
|
+
replaceWith: string;
|
|
36
|
+
author: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Apply a tracked change (insertion / deletion / replace) to the located range.
|
|
40
|
+
* `search === ''` means a pure insertion at the paragraph end; `replaceWith ===
|
|
41
|
+
* ''` means a pure deletion. Refuses to layer onto an existing tracked change.
|
|
42
|
+
* Returns true when a change was dispatched, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
declare function applyProposedChange(view: EditorView, options: ProposeChangeOptions, allocator: CommentIdAllocator): boolean;
|
|
45
|
+
|
|
46
|
+
export { type AddCommentOptions, type ProposeChangeOptions, addCommentToRange, applyProposedChange, createComment };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkNRWQ65NX_js=require('../chunk-NRWQ65NX.js');require('../chunk-DC7S76ZX.js');function C(e,t,c,r){return {id:e.next(),author:c,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:t}]}]}],...r!==void 0&&{parentId:r}}}function y(e,t,c){let{schema:r}=e.state;if(!r.marks.comment)return null;let n=chunkNRWQ65NX_js.a(e.state.doc,t.paraId);if(!n)return null;let s=n.from+1,m=n.to-1;if(t.search){let o=chunkNRWQ65NX_js.d(e.state.doc,n.from,n.to,t.search);if(!o)return null;s=o.from,m=o.to;}if(s>=m)return null;let a=C(c,t.text,t.author);return e.dispatch(e.state.tr.addMark(s,m,r.marks.comment.create({commentId:a.id}))),a}function A(e,t,c){let{schema:r}=e.state;if(!r.marks.deletion||!r.marks.insertion)return false;let n=chunkNRWQ65NX_js.a(e.state.doc,t.paraId);if(!n)return false;let s=t.search==="",m=t.replaceWith==="";if(s&&m)return false;let a,o;if(s)a=n.to-1,o=n.to-1;else {let i=chunkNRWQ65NX_js.d(e.state.doc,n.from,n.to,t.search);if(!i)return false;a=i.from,o=i.to;}if(a<o){let i=false;if(e.state.doc.nodesBetween(a,o,I=>{for(let h of I.marks)if(h.type===r.marks.insertion||h.type===r.marks.deletion)return i=true,false;return true}),i)return false}let u=c.next(),p=new Date().toISOString(),g=r.marks.deletion.create({revisionId:u,author:t.author,date:p}),x=r.marks.insertion.create({revisionId:u,author:t.author,date:p}),d=e.state.tr;return s||(d=d.addMark(a,o,g)),m||(d=d.insert(o,r.text(t.replaceWith,[x]))),e.dispatch(d),true}exports.addCommentToRange=y;exports.applyProposedChange=A;exports.createComment=C;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a,d}from'../chunk-HPJBZL37.mjs';import'../chunk-QYUPLKLP.mjs';function C(e,t,c,r){return {id:e.next(),author:c,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:t}]}]}],...r!==void 0&&{parentId:r}}}function y(e,t,c){let{schema:r}=e.state;if(!r.marks.comment)return null;let n=a(e.state.doc,t.paraId);if(!n)return null;let s=n.from+1,m=n.to-1;if(t.search){let o=d(e.state.doc,n.from,n.to,t.search);if(!o)return null;s=o.from,m=o.to;}if(s>=m)return null;let a$1=C(c,t.text,t.author);return e.dispatch(e.state.tr.addMark(s,m,r.marks.comment.create({commentId:a$1.id}))),a$1}function A(e,t,c){let{schema:r}=e.state;if(!r.marks.deletion||!r.marks.insertion)return false;let n=a(e.state.doc,t.paraId);if(!n)return false;let s=t.search==="",m=t.replaceWith==="";if(s&&m)return false;let a$1,o;if(s)a$1=n.to-1,o=n.to-1;else {let i=d(e.state.doc,n.from,n.to,t.search);if(!i)return false;a$1=i.from,o=i.to;}if(a$1<o){let i=false;if(e.state.doc.nodesBetween(a$1,o,I=>{for(let h of I.marks)if(h.type===r.marks.insertion||h.type===r.marks.deletion)return i=true,false;return true}),i)return false}let u=c.next(),p=new Date().toISOString(),g=r.marks.deletion.create({revisionId:u,author:t.author,date:p}),x=r.marks.insertion.create({revisionId:u,author:t.author,date:p}),d$1=e.state.tr;return s||(d$1=d$1.addMark(a$1,o,g)),m||(d$1=d$1.insert(o,r.text(t.replaceWith,[x]))),e.dispatch(d$1),true}export{y as addCommentToRange,A as applyProposedChange,C as createComment};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Image resize / drag-move PM commits shared by the React and Vue adapters.
|
|
6
|
+
*
|
|
7
|
+
* The float-vs-inline fork is identical across adapters; only the DOM lookups
|
|
8
|
+
* differ (which `.layout-page-content` the drop landed in; how the inline drop
|
|
9
|
+
* position is hit-tested). Those stay in each adapter, which passes the
|
|
10
|
+
* resolved EMU offsets (float) or drop position (inline) into the pure commits
|
|
11
|
+
* here. Each commit dispatches and returns the PM position the caller should
|
|
12
|
+
* re-select as a NodeSelection (or null on no-op / failure).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** True when the image is floating (anchored) rather than inline. */
|
|
16
|
+
declare function isFloatingImage(node: Node): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Resize commit: set the image node's `width`/`height`. Returns `pmPos` to
|
|
19
|
+
* re-select, or null if the position no longer holds an image.
|
|
20
|
+
*/
|
|
21
|
+
declare function commitImageResize(view: EditorView, pmPos: number, newWidth: number, newHeight: number): number | null;
|
|
22
|
+
/**
|
|
23
|
+
* Floating drag commit: rewrite the anchor's margin-relative `position`
|
|
24
|
+
* offsets (in EMU) so the image lands at the drop point while staying
|
|
25
|
+
* floating. Returns `pmPos` to re-select, or null on no-op / failure.
|
|
26
|
+
*/
|
|
27
|
+
declare function commitImageFloatMove(view: EditorView, pmPos: number, hOffsetEmu: number, vOffsetEmu: number): number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Inline drag commit: move the image node to `dropPos` via a delete + insert
|
|
30
|
+
* pair. Returns the PM position to re-select, or null when the drop is a
|
|
31
|
+
* no-op (same slot) or fails.
|
|
32
|
+
*/
|
|
33
|
+
declare function commitImageInlineMove(view: EditorView, pmPos: number, dropPos: number): number | null;
|
|
34
|
+
|
|
35
|
+
export { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Image resize / drag-move PM commits shared by the React and Vue adapters.
|
|
6
|
+
*
|
|
7
|
+
* The float-vs-inline fork is identical across adapters; only the DOM lookups
|
|
8
|
+
* differ (which `.layout-page-content` the drop landed in; how the inline drop
|
|
9
|
+
* position is hit-tested). Those stay in each adapter, which passes the
|
|
10
|
+
* resolved EMU offsets (float) or drop position (inline) into the pure commits
|
|
11
|
+
* here. Each commit dispatches and returns the PM position the caller should
|
|
12
|
+
* re-select as a NodeSelection (or null on no-op / failure).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** True when the image is floating (anchored) rather than inline. */
|
|
16
|
+
declare function isFloatingImage(node: Node): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Resize commit: set the image node's `width`/`height`. Returns `pmPos` to
|
|
19
|
+
* re-select, or null if the position no longer holds an image.
|
|
20
|
+
*/
|
|
21
|
+
declare function commitImageResize(view: EditorView, pmPos: number, newWidth: number, newHeight: number): number | null;
|
|
22
|
+
/**
|
|
23
|
+
* Floating drag commit: rewrite the anchor's margin-relative `position`
|
|
24
|
+
* offsets (in EMU) so the image lands at the drop point while staying
|
|
25
|
+
* floating. Returns `pmPos` to re-select, or null on no-op / failure.
|
|
26
|
+
*/
|
|
27
|
+
declare function commitImageFloatMove(view: EditorView, pmPos: number, hOffsetEmu: number, vOffsetEmu: number): number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Inline drag commit: move the image node to `dropPos` via a delete + insert
|
|
30
|
+
* pair. Returns the PM position to re-select, or null when the drop is a
|
|
31
|
+
* no-op (same slot) or fails.
|
|
32
|
+
*/
|
|
33
|
+
declare function commitImageInlineMove(view: EditorView, pmPos: number, dropPos: number): number | null;
|
|
34
|
+
|
|
35
|
+
export { commitImageFloatMove, commitImageInlineMove, commitImageResize, isFloatingImage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('../chunk-DC7S76ZX.js');function a(e){let t=e.attrs.wrapType;return e.attrs.displayMode==="float"||(t?["square","tight","through"].includes(t):false)}function o(e,t){let r=e.state.doc.nodeAt(t);return !r||r.type.name!=="image"?null:r}function l(e,t,r,i){try{let n=o(e,t);return n?(e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,width:r,height:i})),t):null}catch{return null}}function d(e,t,r,i){try{let n=o(e,t);if(!n)return null;let u={horizontal:{posOffset:r,relativeTo:"margin"},vertical:{posOffset:i,relativeTo:"margin"}};return e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,position:u})),t}catch{return null}}function c(e,t,r){try{let i=o(e,t);if(!i||r===t||r===t+1)return null;let n=e.state.tr;if(r<=t)return n=n.delete(t,t+i.nodeSize),n=n.insert(r,i),e.dispatch(n),r;n=n.delete(t,t+i.nodeSize);let u=Math.min(r-i.nodeSize,n.doc.content.size);return n=n.insert(u,i),e.dispatch(n),Math.min(u,e.state.doc.content.size-1)}catch{return null}}exports.commitImageFloatMove=d;exports.commitImageInlineMove=c;exports.commitImageResize=l;exports.isFloatingImage=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'../chunk-QYUPLKLP.mjs';function a(e){let t=e.attrs.wrapType;return e.attrs.displayMode==="float"||(t?["square","tight","through"].includes(t):false)}function o(e,t){let r=e.state.doc.nodeAt(t);return !r||r.type.name!=="image"?null:r}function l(e,t,r,i){try{let n=o(e,t);return n?(e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,width:r,height:i})),t):null}catch{return null}}function d(e,t,r,i){try{let n=o(e,t);if(!n)return null;let u={horizontal:{posOffset:r,relativeTo:"margin"},vertical:{posOffset:i,relativeTo:"margin"}};return e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,position:u})),t}catch{return null}}function c(e,t,r){try{let i=o(e,t);if(!i||r===t||r===t+1)return null;let n=e.state.tr;if(r<=t)return n=n.delete(t,t+i.nodeSize),n=n.insert(r,i),e.dispatch(n),r;n=n.delete(t,t+i.nodeSize);let u=Math.min(r-i.nodeSize,n.doc.content.size);return n=n.insert(u,i),e.dispatch(n),Math.min(u,e.state.doc.content.size-1)}catch{return null}}export{d as commitImageFloatMove,c as commitImageInlineMove,l as commitImageResize,a as isFloatingImage};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure ProseMirror paragraph/text lookup helpers shared by the React and
|
|
5
|
+
* Vue adapters.
|
|
6
|
+
*
|
|
7
|
+
* "Vanilla view" text extraction skips text inside `insertion` marks
|
|
8
|
+
* (tracked-change additions that aren't accepted yet) so the agent's view
|
|
9
|
+
* of the document matches what `addComment` / `proposeChange` can anchor
|
|
10
|
+
* to. Tracked deletions stay included — they're still in the doc until
|
|
11
|
+
* accepted.
|
|
12
|
+
*
|
|
13
|
+
* Previously duplicated at
|
|
14
|
+
* `packages/react/src/components/DocxEditor/internals/{pmAnchors,vanillaText}.ts`
|
|
15
|
+
* and `packages/vue/src/utils/paraTextHelpers.ts`. Both adapters now
|
|
16
|
+
* re-export from here.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* PM position range for a paragraph identified by Word `w14:paraId`.
|
|
21
|
+
* Stable across edits — inverse of `formatContentForLLM`'s `[paraId]` line tag.
|
|
22
|
+
*
|
|
23
|
+
* Returns inclusive `from` (position before the textblock) and exclusive
|
|
24
|
+
* `to` (`from + nodeSize`). Text content lives in `[from + 1, to - 1]`.
|
|
25
|
+
*/
|
|
26
|
+
declare function findParaIdRange(doc: Node, paraId: string): {
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
} | null;
|
|
30
|
+
/** Text of a single PM node (typically a paragraph), vanilla view. */
|
|
31
|
+
declare function getVanillaNodeText(node: Node): string;
|
|
32
|
+
/** Text between two doc positions, vanilla view. */
|
|
33
|
+
declare function getVanillaTextBetween(doc: Node, from: number, to: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Find `searchText` within a PM paragraph range and return its position.
|
|
36
|
+
*
|
|
37
|
+
* Returns null if:
|
|
38
|
+
* - searchText is empty
|
|
39
|
+
* - searchText is not found
|
|
40
|
+
* - searchText appears more than once (ambiguous; caller disambiguates)
|
|
41
|
+
*
|
|
42
|
+
* The fullText is built from PM text nodes only and matches the vanilla
|
|
43
|
+
* view the agent reads via `read_document`: tracked insertions are
|
|
44
|
+
* excluded (not in the doc yet), tracked deletions are included (still
|
|
45
|
+
* in the doc until accepted), and comment markers are stripped.
|
|
46
|
+
*/
|
|
47
|
+
declare function findTextInPmParagraph(doc: Node, paragraphFrom: number, paragraphTo: number, searchText: string): {
|
|
48
|
+
from: number;
|
|
49
|
+
to: number;
|
|
50
|
+
} | null;
|
|
51
|
+
|
|
52
|
+
export { findParaIdRange, findTextInPmParagraph, getVanillaNodeText, getVanillaTextBetween };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure ProseMirror paragraph/text lookup helpers shared by the React and
|
|
5
|
+
* Vue adapters.
|
|
6
|
+
*
|
|
7
|
+
* "Vanilla view" text extraction skips text inside `insertion` marks
|
|
8
|
+
* (tracked-change additions that aren't accepted yet) so the agent's view
|
|
9
|
+
* of the document matches what `addComment` / `proposeChange` can anchor
|
|
10
|
+
* to. Tracked deletions stay included — they're still in the doc until
|
|
11
|
+
* accepted.
|
|
12
|
+
*
|
|
13
|
+
* Previously duplicated at
|
|
14
|
+
* `packages/react/src/components/DocxEditor/internals/{pmAnchors,vanillaText}.ts`
|
|
15
|
+
* and `packages/vue/src/utils/paraTextHelpers.ts`. Both adapters now
|
|
16
|
+
* re-export from here.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* PM position range for a paragraph identified by Word `w14:paraId`.
|
|
21
|
+
* Stable across edits — inverse of `formatContentForLLM`'s `[paraId]` line tag.
|
|
22
|
+
*
|
|
23
|
+
* Returns inclusive `from` (position before the textblock) and exclusive
|
|
24
|
+
* `to` (`from + nodeSize`). Text content lives in `[from + 1, to - 1]`.
|
|
25
|
+
*/
|
|
26
|
+
declare function findParaIdRange(doc: Node, paraId: string): {
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
} | null;
|
|
30
|
+
/** Text of a single PM node (typically a paragraph), vanilla view. */
|
|
31
|
+
declare function getVanillaNodeText(node: Node): string;
|
|
32
|
+
/** Text between two doc positions, vanilla view. */
|
|
33
|
+
declare function getVanillaTextBetween(doc: Node, from: number, to: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Find `searchText` within a PM paragraph range and return its position.
|
|
36
|
+
*
|
|
37
|
+
* Returns null if:
|
|
38
|
+
* - searchText is empty
|
|
39
|
+
* - searchText is not found
|
|
40
|
+
* - searchText appears more than once (ambiguous; caller disambiguates)
|
|
41
|
+
*
|
|
42
|
+
* The fullText is built from PM text nodes only and matches the vanilla
|
|
43
|
+
* view the agent reads via `read_document`: tracked insertions are
|
|
44
|
+
* excluded (not in the doc yet), tracked deletions are included (still
|
|
45
|
+
* in the doc until accepted), and comment markers are stripped.
|
|
46
|
+
*/
|
|
47
|
+
declare function findTextInPmParagraph(doc: Node, paragraphFrom: number, paragraphTo: number, searchText: string): {
|
|
48
|
+
from: number;
|
|
49
|
+
to: number;
|
|
50
|
+
} | null;
|
|
51
|
+
|
|
52
|
+
export { findParaIdRange, findTextInPmParagraph, getVanillaNodeText, getVanillaTextBetween };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkNRWQ65NX_js=require('../chunk-NRWQ65NX.js');require('../chunk-DC7S76ZX.js');Object.defineProperty(exports,"findParaIdRange",{enumerable:true,get:function(){return chunkNRWQ65NX_js.a}});Object.defineProperty(exports,"findTextInPmParagraph",{enumerable:true,get:function(){return chunkNRWQ65NX_js.d}});Object.defineProperty(exports,"getVanillaNodeText",{enumerable:true,get:function(){return chunkNRWQ65NX_js.b}});Object.defineProperty(exports,"getVanillaTextBetween",{enumerable:true,get:function(){return chunkNRWQ65NX_js.c}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as findParaIdRange,d as findTextInPmParagraph,b as getVanillaNodeText,c as getVanillaTextBetween}from'../chunk-HPJBZL37.mjs';import'../chunk-QYUPLKLP.mjs';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { Layout } from '../layout-engine/types.mjs';
|
|
3
|
+
import '../content-3xF4WDE8.mjs';
|
|
4
|
+
import '../formatting-BH4hcZiq.mjs';
|
|
5
|
+
import '../colors-C3vA7HUU.mjs';
|
|
6
|
+
import '../docx/wrapTypes.mjs';
|
|
7
|
+
import '../watermark-DAcnAs_J.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pure ref-API query helpers — read-only inspectors over the PM document
|
|
11
|
+
* and the paginated layout. Back the adapters' `findInDocument`,
|
|
12
|
+
* `getSelectionInfo`, and `getPageContent` ref methods.
|
|
13
|
+
*
|
|
14
|
+
* Every function takes the PM view (or layout + view) as a parameter
|
|
15
|
+
* instead of closing over a framework ref, so the React and Vue adapters
|
|
16
|
+
* (and the future vanilla wrapper) share one implementation.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface FindInDocumentMatch {
|
|
20
|
+
paraId: string;
|
|
21
|
+
match: string;
|
|
22
|
+
before: string;
|
|
23
|
+
after: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Walk the PM doc looking for `query`. Returns up to `limit` matches —
|
|
27
|
+
* one per paragraph (rejects paragraphs where the query appears more
|
|
28
|
+
* than once, mirroring `findTextInPmParagraph`'s ambiguity guard so the
|
|
29
|
+
* LLM gets a clearer error than a silent mistarget).
|
|
30
|
+
*/
|
|
31
|
+
declare function findInDocument(view: EditorView | null, query: string, opts?: {
|
|
32
|
+
caseSensitive?: boolean;
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): FindInDocumentMatch[];
|
|
35
|
+
interface SelectionInfo {
|
|
36
|
+
paraId: string | null;
|
|
37
|
+
selectedText: string;
|
|
38
|
+
paragraphText: string;
|
|
39
|
+
before: string;
|
|
40
|
+
after: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Describe the current selection in agent-readable form — paraId of the
|
|
44
|
+
* containing paragraph, the selected text, the full paragraph text, and
|
|
45
|
+
* the leading/trailing slices. Vanilla view: insertion-marked text never
|
|
46
|
+
* appears, matching what the agent reads and can anchor against.
|
|
47
|
+
*/
|
|
48
|
+
declare function getSelectionInfo(view: EditorView | null): SelectionInfo | null;
|
|
49
|
+
interface PageContent {
|
|
50
|
+
pageNumber: number;
|
|
51
|
+
text: string;
|
|
52
|
+
paragraphs: Array<{
|
|
53
|
+
paraId: string;
|
|
54
|
+
text: string;
|
|
55
|
+
styleId?: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Collect paragraphs visible on `pageNumber` (1-indexed) from the
|
|
60
|
+
* paginated `layout`. Dedupes by paraId so paragraphs split across page
|
|
61
|
+
* boundaries are reported once.
|
|
62
|
+
*/
|
|
63
|
+
declare function getPageContent(view: EditorView | null, layout: Layout | null, pageNumber: number): PageContent | null;
|
|
64
|
+
|
|
65
|
+
export { type FindInDocumentMatch, type PageContent, type SelectionInfo, findInDocument, getPageContent, getSelectionInfo };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { Layout } from '../layout-engine/types.js';
|
|
3
|
+
import '../content-C8fc_tL6.js';
|
|
4
|
+
import '../formatting-_OXU8gLB.js';
|
|
5
|
+
import '../colors-C3vA7HUU.js';
|
|
6
|
+
import '../docx/wrapTypes.js';
|
|
7
|
+
import '../watermark-DAcnAs_J.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pure ref-API query helpers — read-only inspectors over the PM document
|
|
11
|
+
* and the paginated layout. Back the adapters' `findInDocument`,
|
|
12
|
+
* `getSelectionInfo`, and `getPageContent` ref methods.
|
|
13
|
+
*
|
|
14
|
+
* Every function takes the PM view (or layout + view) as a parameter
|
|
15
|
+
* instead of closing over a framework ref, so the React and Vue adapters
|
|
16
|
+
* (and the future vanilla wrapper) share one implementation.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface FindInDocumentMatch {
|
|
20
|
+
paraId: string;
|
|
21
|
+
match: string;
|
|
22
|
+
before: string;
|
|
23
|
+
after: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Walk the PM doc looking for `query`. Returns up to `limit` matches —
|
|
27
|
+
* one per paragraph (rejects paragraphs where the query appears more
|
|
28
|
+
* than once, mirroring `findTextInPmParagraph`'s ambiguity guard so the
|
|
29
|
+
* LLM gets a clearer error than a silent mistarget).
|
|
30
|
+
*/
|
|
31
|
+
declare function findInDocument(view: EditorView | null, query: string, opts?: {
|
|
32
|
+
caseSensitive?: boolean;
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): FindInDocumentMatch[];
|
|
35
|
+
interface SelectionInfo {
|
|
36
|
+
paraId: string | null;
|
|
37
|
+
selectedText: string;
|
|
38
|
+
paragraphText: string;
|
|
39
|
+
before: string;
|
|
40
|
+
after: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Describe the current selection in agent-readable form — paraId of the
|
|
44
|
+
* containing paragraph, the selected text, the full paragraph text, and
|
|
45
|
+
* the leading/trailing slices. Vanilla view: insertion-marked text never
|
|
46
|
+
* appears, matching what the agent reads and can anchor against.
|
|
47
|
+
*/
|
|
48
|
+
declare function getSelectionInfo(view: EditorView | null): SelectionInfo | null;
|
|
49
|
+
interface PageContent {
|
|
50
|
+
pageNumber: number;
|
|
51
|
+
text: string;
|
|
52
|
+
paragraphs: Array<{
|
|
53
|
+
paraId: string;
|
|
54
|
+
text: string;
|
|
55
|
+
styleId?: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Collect paragraphs visible on `pageNumber` (1-indexed) from the
|
|
60
|
+
* paginated `layout`. Dedupes by paraId so paragraphs split across page
|
|
61
|
+
* boundaries are reported once.
|
|
62
|
+
*/
|
|
63
|
+
declare function getPageContent(view: EditorView | null, layout: Layout | null, pageNumber: number): PageContent | null;
|
|
64
|
+
|
|
65
|
+
export { type FindInDocumentMatch, type PageContent, type SelectionInfo, findInDocument, getPageContent, getSelectionInfo };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkNRWQ65NX_js=require('../chunk-NRWQ65NX.js');require('../chunk-DC7S76ZX.js');function x(l,t,c){if(!l||!t)return [];let o=c?.caseSensitive??false,r=c?.limit??20,s=o?t:t.toLowerCase(),f=[];return l.state.doc.descendants(n=>{if(f.length>=r)return false;if(!n.isTextblock)return true;let d=n.attrs?.paraId;if(!d)return false;let e=chunkNRWQ65NX_js.b(n),i=o?e:e.toLowerCase(),a=i.indexOf(s);if(a===-1||i.indexOf(s,a+1)!==-1)return false;let g=40;return f.push({paraId:d,match:e.slice(a,a+t.length),before:e.slice(Math.max(0,a-g),a),after:e.slice(a+t.length,a+t.length+g)}),false}),f}function h(l){if(!l)return null;let{selection:t,doc:c}=l.state,o=t.$from,r=o.depth;for(;r>0&&!o.node(r).isTextblock;)r--;let s=r>0?o.node(r):null;if(!s)return null;let f=s.attrs?.paraId??null,n=o.start(r),d=n+s.content.size,e=chunkNRWQ65NX_js.c(c,n,t.from),i=chunkNRWQ65NX_js.c(c,t.from,t.to),a=chunkNRWQ65NX_js.c(c,t.to,d);return {paraId:f,selectedText:i,paragraphText:e+i+a,before:e,after:a}}function I(l,t,c){if(!t||!l)return null;let o=t.pages[c-1];if(!o)return null;let r=new Set,s=[];for(let n of o.fragments){if(n.kind!=="paragraph")continue;let d=n.pmStart;if(d==null)continue;let e=l.state.doc.nodeAt(d);if(!e||!e.isTextblock)continue;let i=e.attrs?.paraId;!i||r.has(i)||(r.add(i),s.push({paraId:i,text:chunkNRWQ65NX_js.b(e),styleId:e.attrs?.styleId??void 0}));}let f=s.map(n=>`[${n.paraId}] ${n.text}`).join(`
|
|
2
|
+
`);return {pageNumber:c,text:f,paragraphs:s}}exports.findInDocument=x;exports.getPageContent=I;exports.getSelectionInfo=h;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'../chunk-HPJBZL37.mjs';import'../chunk-QYUPLKLP.mjs';function x(l,t,c){if(!l||!t)return [];let o=c?.caseSensitive??false,r=c?.limit??20,s=o?t:t.toLowerCase(),f=[];return l.state.doc.descendants(n=>{if(f.length>=r)return false;if(!n.isTextblock)return true;let d=n.attrs?.paraId;if(!d)return false;let e=b(n),i=o?e:e.toLowerCase(),a=i.indexOf(s);if(a===-1||i.indexOf(s,a+1)!==-1)return false;let g=40;return f.push({paraId:d,match:e.slice(a,a+t.length),before:e.slice(Math.max(0,a-g),a),after:e.slice(a+t.length,a+t.length+g)}),false}),f}function h(l){if(!l)return null;let{selection:t,doc:c$1}=l.state,o=t.$from,r=o.depth;for(;r>0&&!o.node(r).isTextblock;)r--;let s=r>0?o.node(r):null;if(!s)return null;let f=s.attrs?.paraId??null,n=o.start(r),d=n+s.content.size,e=c(c$1,n,t.from),i=c(c$1,t.from,t.to),a=c(c$1,t.to,d);return {paraId:f,selectedText:i,paragraphText:e+i+a,before:e,after:a}}function I(l,t,c){if(!t||!l)return null;let o=t.pages[c-1];if(!o)return null;let r=new Set,s=[];for(let n of o.fragments){if(n.kind!=="paragraph")continue;let d=n.pmStart;if(d==null)continue;let e=l.state.doc.nodeAt(d);if(!e||!e.isTextblock)continue;let i=e.attrs?.paraId;!i||r.has(i)||(r.add(i),s.push({paraId:i,text:b(e),styleId:e.attrs?.styleId??void 0}));}let f=s.map(n=>`[${n.paraId}] ${n.text}`).join(`
|
|
2
|
+
`);return {pageNumber:c,text:f,paragraphs:s}}export{x as findInDocument,I as getPageContent,h as getSelectionInfo};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Table-resize commit + width-read helpers shared by the React and Vue
|
|
5
|
+
* adapters. Pure `(view, …) → result` over the PM doc — the gesture state
|
|
6
|
+
* machines (which DOM handle is grabbed, pixel deltas, listener wiring) stay
|
|
7
|
+
* in each adapter.
|
|
8
|
+
*
|
|
9
|
+
* Widths and heights are stored in twips (1/20 of a point) on the PM doc,
|
|
10
|
+
* matching OOXML's `w:tblGrid` and `w:tcW` units.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** 1px ≈ 15 twips at 96dpi (20 twips/pt × 72pt/in ÷ 96px/in). */
|
|
14
|
+
declare const TWIPS_PER_PIXEL = 15;
|
|
15
|
+
/** Minimum column width (~0.2"). */
|
|
16
|
+
declare const MIN_CELL_WIDTH_TWIPS = 300;
|
|
17
|
+
/** Minimum row height (~0.14"). */
|
|
18
|
+
declare const MIN_ROW_HEIGHT_TWIPS = 200;
|
|
19
|
+
/** Read the [left, right] column widths at `colIndex` in the table starting at `pmStart`. */
|
|
20
|
+
declare function readColumnWidths(view: EditorView, pmStart: number, colIndex: number): {
|
|
21
|
+
left: number;
|
|
22
|
+
right: number;
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* Read the row height (in twips) for `rowIndex` in the table starting at
|
|
26
|
+
* `pmStart`. Returns null if the row has no explicit height — the caller
|
|
27
|
+
* can fall back to measuring the rendered DOM cell.
|
|
28
|
+
*/
|
|
29
|
+
declare function readRowHeight(view: EditorView, pmStart: number, rowIndex: number): number | null;
|
|
30
|
+
/** Read the last-column width (the one being resized from the table's right edge). */
|
|
31
|
+
declare function readColumnWidthAt(view: EditorView, pmStart: number, colIndex: number): number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Bake a column-resize into the PM doc: update the table's `columnWidths`
|
|
34
|
+
* attr and every cell at `colIdx` / `colIdx + 1` in every row.
|
|
35
|
+
*/
|
|
36
|
+
declare function commitColumnResize(view: EditorView, opts: {
|
|
37
|
+
pmStart: number;
|
|
38
|
+
colIdx: number;
|
|
39
|
+
newLeft: number;
|
|
40
|
+
newRight: number;
|
|
41
|
+
}): void;
|
|
42
|
+
/** Bake a row-resize into the PM doc: update the target row's `height` + `heightRule`. */
|
|
43
|
+
declare function commitRowResize(view: EditorView, opts: {
|
|
44
|
+
pmStart: number;
|
|
45
|
+
rowIdx: number;
|
|
46
|
+
newHeight: number;
|
|
47
|
+
}): void;
|
|
48
|
+
/**
|
|
49
|
+
* Bake a right-edge resize into the PM doc: grow only the last column.
|
|
50
|
+
* Updates `columnWidths[colIdx]` and the cell at `colIdx` in every row.
|
|
51
|
+
*/
|
|
52
|
+
declare function commitRightEdgeResize(view: EditorView, opts: {
|
|
53
|
+
pmStart: number;
|
|
54
|
+
colIdx: number;
|
|
55
|
+
newWidth: number;
|
|
56
|
+
}): void;
|
|
57
|
+
|
|
58
|
+
export { MIN_CELL_WIDTH_TWIPS, MIN_ROW_HEIGHT_TWIPS, TWIPS_PER_PIXEL, commitColumnResize, commitRightEdgeResize, commitRowResize, readColumnWidthAt, readColumnWidths, readRowHeight };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Table-resize commit + width-read helpers shared by the React and Vue
|
|
5
|
+
* adapters. Pure `(view, …) → result` over the PM doc — the gesture state
|
|
6
|
+
* machines (which DOM handle is grabbed, pixel deltas, listener wiring) stay
|
|
7
|
+
* in each adapter.
|
|
8
|
+
*
|
|
9
|
+
* Widths and heights are stored in twips (1/20 of a point) on the PM doc,
|
|
10
|
+
* matching OOXML's `w:tblGrid` and `w:tcW` units.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** 1px ≈ 15 twips at 96dpi (20 twips/pt × 72pt/in ÷ 96px/in). */
|
|
14
|
+
declare const TWIPS_PER_PIXEL = 15;
|
|
15
|
+
/** Minimum column width (~0.2"). */
|
|
16
|
+
declare const MIN_CELL_WIDTH_TWIPS = 300;
|
|
17
|
+
/** Minimum row height (~0.14"). */
|
|
18
|
+
declare const MIN_ROW_HEIGHT_TWIPS = 200;
|
|
19
|
+
/** Read the [left, right] column widths at `colIndex` in the table starting at `pmStart`. */
|
|
20
|
+
declare function readColumnWidths(view: EditorView, pmStart: number, colIndex: number): {
|
|
21
|
+
left: number;
|
|
22
|
+
right: number;
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* Read the row height (in twips) for `rowIndex` in the table starting at
|
|
26
|
+
* `pmStart`. Returns null if the row has no explicit height — the caller
|
|
27
|
+
* can fall back to measuring the rendered DOM cell.
|
|
28
|
+
*/
|
|
29
|
+
declare function readRowHeight(view: EditorView, pmStart: number, rowIndex: number): number | null;
|
|
30
|
+
/** Read the last-column width (the one being resized from the table's right edge). */
|
|
31
|
+
declare function readColumnWidthAt(view: EditorView, pmStart: number, colIndex: number): number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Bake a column-resize into the PM doc: update the table's `columnWidths`
|
|
34
|
+
* attr and every cell at `colIdx` / `colIdx + 1` in every row.
|
|
35
|
+
*/
|
|
36
|
+
declare function commitColumnResize(view: EditorView, opts: {
|
|
37
|
+
pmStart: number;
|
|
38
|
+
colIdx: number;
|
|
39
|
+
newLeft: number;
|
|
40
|
+
newRight: number;
|
|
41
|
+
}): void;
|
|
42
|
+
/** Bake a row-resize into the PM doc: update the target row's `height` + `heightRule`. */
|
|
43
|
+
declare function commitRowResize(view: EditorView, opts: {
|
|
44
|
+
pmStart: number;
|
|
45
|
+
rowIdx: number;
|
|
46
|
+
newHeight: number;
|
|
47
|
+
}): void;
|
|
48
|
+
/**
|
|
49
|
+
* Bake a right-edge resize into the PM doc: grow only the last column.
|
|
50
|
+
* Updates `columnWidths[colIdx]` and the cell at `colIdx` in every row.
|
|
51
|
+
*/
|
|
52
|
+
declare function commitRightEdgeResize(view: EditorView, opts: {
|
|
53
|
+
pmStart: number;
|
|
54
|
+
colIdx: number;
|
|
55
|
+
newWidth: number;
|
|
56
|
+
}): void;
|
|
57
|
+
|
|
58
|
+
export { MIN_CELL_WIDTH_TWIPS, MIN_ROW_HEIGHT_TWIPS, TWIPS_PER_PIXEL, commitColumnResize, commitRightEdgeResize, commitRowResize, readColumnWidthAt, readColumnWidths, readRowHeight };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('../chunk-DC7S76ZX.js');var x=15,g=300,W=200;function f(n,r){try{let o=n.state.doc.resolve(r+1);for(let t=o.depth;t>=0;t--){let e=o.node(t);if(e.type.name==="table")return {node:e,tablePos:o.before(t)}}}catch{}return null}function S(n,r,o){let t=f(n,r);if(!t)return null;let e=t.node.attrs.columnWidths;return !e||e[o]===void 0||e[o+1]===void 0?null:{left:e[o],right:e[o+1]}}function I(n,r,o){let t=f(n,r);if(!t)return null;let e=null,i=0;return t.node.forEach(s=>{if(i===o){let u=s.attrs.height;u&&(e=u);}i++;}),e}function P(n,r,o){let t=f(n,r);if(!t)return null;let e=t.node.attrs.columnWidths;return !e||e[o]===void 0?null:e[o]}function R(n,r){let{pmStart:o,colIdx:t,newLeft:e,newRight:i}=r,s=f(n,o);if(!s)return;let{node:u,tablePos:d}=s,l=n.state.tr,a=[...u.attrs.columnWidths??[]];a[t]=e,a[t+1]=i,l.setNodeMarkup(d,void 0,{...u.attrs,columnWidths:a});let m=d+1;u.forEach(h=>{let p=m+1,c=0;h.forEach(b=>{let w=b.attrs.colspan||1;if(c===t||c===t+1){let E=c===t?e:i;l.setNodeMarkup(l.mapping.map(p),void 0,{...b.attrs,width:E,widthType:"dxa",colwidth:null});}p+=b.nodeSize,c+=w;}),m+=h.nodeSize;}),n.dispatch(l);}function N(n,r){let{pmStart:o,rowIdx:t,newHeight:e}=r,i=f(n,o);if(!i)return;let{node:s,tablePos:u}=i,d=n.state.tr,l=u+1,a=0;s.forEach(m=>{a===t&&d.setNodeMarkup(d.mapping.map(l),void 0,{...m.attrs,height:e,heightRule:"atLeast"}),l+=m.nodeSize,a++;}),n.dispatch(d);}function T(n,r){let{pmStart:o,colIdx:t,newWidth:e}=r,i=f(n,o);if(!i)return;let{node:s,tablePos:u}=i,d=n.state.tr,l=[...s.attrs.columnWidths??[]];l[t]=e,d.setNodeMarkup(u,void 0,{...s.attrs,columnWidths:l});let a=u+1;s.forEach(m=>{let h=a+1,p=0;m.forEach(c=>{let b=c.attrs.colspan||1;p===t&&d.setNodeMarkup(d.mapping.map(h),void 0,{...c.attrs,width:e,widthType:"dxa",colwidth:null}),h+=c.nodeSize,p+=b;}),a+=m.nodeSize;}),n.dispatch(d);}exports.MIN_CELL_WIDTH_TWIPS=g;exports.MIN_ROW_HEIGHT_TWIPS=W;exports.TWIPS_PER_PIXEL=x;exports.commitColumnResize=R;exports.commitRightEdgeResize=T;exports.commitRowResize=N;exports.readColumnWidthAt=P;exports.readColumnWidths=S;exports.readRowHeight=I;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'../chunk-QYUPLKLP.mjs';var x=15,g=300,W=200;function f(n,r){try{let o=n.state.doc.resolve(r+1);for(let t=o.depth;t>=0;t--){let e=o.node(t);if(e.type.name==="table")return {node:e,tablePos:o.before(t)}}}catch{}return null}function S(n,r,o){let t=f(n,r);if(!t)return null;let e=t.node.attrs.columnWidths;return !e||e[o]===void 0||e[o+1]===void 0?null:{left:e[o],right:e[o+1]}}function I(n,r,o){let t=f(n,r);if(!t)return null;let e=null,i=0;return t.node.forEach(s=>{if(i===o){let u=s.attrs.height;u&&(e=u);}i++;}),e}function P(n,r,o){let t=f(n,r);if(!t)return null;let e=t.node.attrs.columnWidths;return !e||e[o]===void 0?null:e[o]}function R(n,r){let{pmStart:o,colIdx:t,newLeft:e,newRight:i}=r,s=f(n,o);if(!s)return;let{node:u,tablePos:d}=s,l=n.state.tr,a=[...u.attrs.columnWidths??[]];a[t]=e,a[t+1]=i,l.setNodeMarkup(d,void 0,{...u.attrs,columnWidths:a});let m=d+1;u.forEach(h=>{let p=m+1,c=0;h.forEach(b=>{let w=b.attrs.colspan||1;if(c===t||c===t+1){let E=c===t?e:i;l.setNodeMarkup(l.mapping.map(p),void 0,{...b.attrs,width:E,widthType:"dxa",colwidth:null});}p+=b.nodeSize,c+=w;}),m+=h.nodeSize;}),n.dispatch(l);}function N(n,r){let{pmStart:o,rowIdx:t,newHeight:e}=r,i=f(n,o);if(!i)return;let{node:s,tablePos:u}=i,d=n.state.tr,l=u+1,a=0;s.forEach(m=>{a===t&&d.setNodeMarkup(d.mapping.map(l),void 0,{...m.attrs,height:e,heightRule:"atLeast"}),l+=m.nodeSize,a++;}),n.dispatch(d);}function T(n,r){let{pmStart:o,colIdx:t,newWidth:e}=r,i=f(n,o);if(!i)return;let{node:s,tablePos:u}=i,d=n.state.tr,l=[...s.attrs.columnWidths??[]];l[t]=e,d.setNodeMarkup(u,void 0,{...s.attrs,columnWidths:l});let a=u+1;s.forEach(m=>{let h=a+1,p=0;m.forEach(c=>{let b=c.attrs.colspan||1;p===t&&d.setNodeMarkup(d.mapping.map(h),void 0,{...c.attrs,width:e,widthType:"dxa",colwidth:null}),h+=c.nodeSize,p+=b;}),a+=m.nodeSize;}),n.dispatch(d);}export{g as MIN_CELL_WIDTH_TWIPS,W as MIN_ROW_HEIGHT_TWIPS,x as TWIPS_PER_PIXEL,R as commitColumnResize,T as commitRightEdgeResize,N as commitRowResize,P as readColumnWidthAt,S as readColumnWidths,I as readRowHeight};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag auto-scroll geometry shared by the React and Vue adapters.
|
|
3
|
+
*
|
|
4
|
+
* When the user drag-selects and the pointer nears the top/bottom edge of the
|
|
5
|
+
* scroll container, the container should auto-scroll at a speed proportional to
|
|
6
|
+
* how deep into the edge zone the pointer is. The per-frame loop and the
|
|
7
|
+
* framework wiring stay in each adapter's hook; this is just the pure delta.
|
|
8
|
+
*/
|
|
9
|
+
/** Pixel distance from the container edge where auto-scroll activates. */
|
|
10
|
+
declare const AUTO_SCROLL_EDGE_ZONE = 40;
|
|
11
|
+
/** Maximum scroll speed in pixels per frame (~60fps). */
|
|
12
|
+
declare const AUTO_SCROLL_MAX_SPEED = 12;
|
|
13
|
+
/**
|
|
14
|
+
* Vertical scroll delta (px/frame) for a pointer at `mouseY` over a container
|
|
15
|
+
* whose viewport spans `rect.top`..`rect.bottom`. Negative scrolls up, positive
|
|
16
|
+
* down, 0 when the pointer is outside both edge zones. Speed ramps linearly
|
|
17
|
+
* from 0 at the edge-zone boundary to `AUTO_SCROLL_MAX_SPEED` at the edge.
|
|
18
|
+
*/
|
|
19
|
+
declare function computeAutoScrollDelta(rect: {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
}, mouseY: number): number;
|
|
23
|
+
|
|
24
|
+
export { AUTO_SCROLL_EDGE_ZONE, AUTO_SCROLL_MAX_SPEED, computeAutoScrollDelta };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag auto-scroll geometry shared by the React and Vue adapters.
|
|
3
|
+
*
|
|
4
|
+
* When the user drag-selects and the pointer nears the top/bottom edge of the
|
|
5
|
+
* scroll container, the container should auto-scroll at a speed proportional to
|
|
6
|
+
* how deep into the edge zone the pointer is. The per-frame loop and the
|
|
7
|
+
* framework wiring stay in each adapter's hook; this is just the pure delta.
|
|
8
|
+
*/
|
|
9
|
+
/** Pixel distance from the container edge where auto-scroll activates. */
|
|
10
|
+
declare const AUTO_SCROLL_EDGE_ZONE = 40;
|
|
11
|
+
/** Maximum scroll speed in pixels per frame (~60fps). */
|
|
12
|
+
declare const AUTO_SCROLL_MAX_SPEED = 12;
|
|
13
|
+
/**
|
|
14
|
+
* Vertical scroll delta (px/frame) for a pointer at `mouseY` over a container
|
|
15
|
+
* whose viewport spans `rect.top`..`rect.bottom`. Negative scrolls up, positive
|
|
16
|
+
* down, 0 when the pointer is outside both edge zones. Speed ramps linearly
|
|
17
|
+
* from 0 at the edge-zone boundary to `AUTO_SCROLL_MAX_SPEED` at the edge.
|
|
18
|
+
*/
|
|
19
|
+
declare function computeAutoScrollDelta(rect: {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
}, mouseY: number): number;
|
|
23
|
+
|
|
24
|
+
export { AUTO_SCROLL_EDGE_ZONE, AUTO_SCROLL_MAX_SPEED, computeAutoScrollDelta };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('../chunk-DC7S76ZX.js');var t=40,L=12;function o(_,E){if(E<_.top+40){let O=Math.max(0,_.top+40-E);return -Math.min(12,O/40*12)}if(E>_.bottom-40){let O=Math.max(0,E-(_.bottom-40));return Math.min(12,O/40*12)}return 0}exports.AUTO_SCROLL_EDGE_ZONE=t;exports.AUTO_SCROLL_MAX_SPEED=L;exports.computeAutoScrollDelta=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'../chunk-QYUPLKLP.mjs';var t=40,L=12;function o(_,E){if(E<_.top+40){let O=Math.max(0,_.top+40-E);return -Math.min(12,O/40*12)}if(E>_.bottom-40){let O=Math.max(0,E-(_.bottom-40));return Math.min(12,O/40*12)}return 0}export{t as AUTO_SCROLL_EDGE_ZONE,L as AUTO_SCROLL_MAX_SPEED,o as computeAutoScrollDelta};
|