@lexical/react 0.39.1-nightly.20251229.0 → 0.39.1-nightly.20251231.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.
|
@@ -309,7 +309,7 @@ function getBlockElement(anchorElem, editor, event, useEdgeAsDefault = false) {
|
|
|
309
309
|
});
|
|
310
310
|
return blockElem;
|
|
311
311
|
}
|
|
312
|
-
function setMenuPosition(targetElem, floatingElem, anchorElem) {
|
|
312
|
+
function setMenuPosition(targetElem, floatingElem, anchorElem, zoomLevel) {
|
|
313
313
|
if (!targetElem) {
|
|
314
314
|
floatingElem.style.display = 'none';
|
|
315
315
|
return;
|
|
@@ -325,7 +325,7 @@ function setMenuPosition(targetElem, floatingElem, anchorElem) {
|
|
|
325
325
|
// middle
|
|
326
326
|
targetCalculateHeight = targetRect.bottom - targetRect.top;
|
|
327
327
|
}
|
|
328
|
-
const top = targetRect.top + (targetCalculateHeight - (floatingElemRect.height || targetCalculateHeight)) / 2 - anchorElementRect.top + anchorElem.scrollTop;
|
|
328
|
+
const top = (targetRect.top + (targetCalculateHeight - (floatingElemRect.height || targetCalculateHeight)) / 2 - anchorElementRect.top + anchorElem.scrollTop) / zoomLevel;
|
|
329
329
|
const left = SPACE;
|
|
330
330
|
floatingElem.style.display = 'flex';
|
|
331
331
|
floatingElem.style.opacity = '1';
|
|
@@ -412,8 +412,9 @@ function useDraggableBlockMenu(editor, anchorElem, menuRef, targetLineRef, isEdi
|
|
|
412
412
|
};
|
|
413
413
|
}, [scrollerElem, anchorElem, editor, isOnMenu, setDraggableBlockElem]);
|
|
414
414
|
react.useEffect(() => {
|
|
415
|
+
const zoomLevel = utils.calculateZoomLevel(document.getElementsByClassName('ContentEditable__root')[0], true);
|
|
415
416
|
if (menuRef.current) {
|
|
416
|
-
setMenuPosition(draggableBlockElem, menuRef.current, anchorElem);
|
|
417
|
+
setMenuPosition(draggableBlockElem, menuRef.current, anchorElem, zoomLevel);
|
|
417
418
|
}
|
|
418
419
|
}, [anchorElem, draggableBlockElem, menuRef]);
|
|
419
420
|
react.useEffect(() => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
10
|
import { eventFiles } from '@lexical/rich-text';
|
|
11
|
-
import { mergeRegister, isHTMLElement
|
|
11
|
+
import { calculateZoomLevel, mergeRegister, isHTMLElement } from '@lexical/utils';
|
|
12
12
|
import { DRAGOVER_COMMAND, COMMAND_PRIORITY_LOW, DROP_COMMAND, COMMAND_PRIORITY_HIGH, $getNodeByKey, $getNearestNodeFromDOMNode, $getRoot } from 'lexical';
|
|
13
13
|
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
14
14
|
import { createPortal } from 'react-dom';
|
|
@@ -307,7 +307,7 @@ function getBlockElement(anchorElem, editor, event, useEdgeAsDefault = false) {
|
|
|
307
307
|
});
|
|
308
308
|
return blockElem;
|
|
309
309
|
}
|
|
310
|
-
function setMenuPosition(targetElem, floatingElem, anchorElem) {
|
|
310
|
+
function setMenuPosition(targetElem, floatingElem, anchorElem, zoomLevel) {
|
|
311
311
|
if (!targetElem) {
|
|
312
312
|
floatingElem.style.display = 'none';
|
|
313
313
|
return;
|
|
@@ -323,7 +323,7 @@ function setMenuPosition(targetElem, floatingElem, anchorElem) {
|
|
|
323
323
|
// middle
|
|
324
324
|
targetCalculateHeight = targetRect.bottom - targetRect.top;
|
|
325
325
|
}
|
|
326
|
-
const top = targetRect.top + (targetCalculateHeight - (floatingElemRect.height || targetCalculateHeight)) / 2 - anchorElementRect.top + anchorElem.scrollTop;
|
|
326
|
+
const top = (targetRect.top + (targetCalculateHeight - (floatingElemRect.height || targetCalculateHeight)) / 2 - anchorElementRect.top + anchorElem.scrollTop) / zoomLevel;
|
|
327
327
|
const left = SPACE;
|
|
328
328
|
floatingElem.style.display = 'flex';
|
|
329
329
|
floatingElem.style.opacity = '1';
|
|
@@ -410,8 +410,9 @@ function useDraggableBlockMenu(editor, anchorElem, menuRef, targetLineRef, isEdi
|
|
|
410
410
|
};
|
|
411
411
|
}, [scrollerElem, anchorElem, editor, isOnMenu, setDraggableBlockElem]);
|
|
412
412
|
useEffect(() => {
|
|
413
|
+
const zoomLevel = calculateZoomLevel(document.getElementsByClassName('ContentEditable__root')[0], true);
|
|
413
414
|
if (menuRef.current) {
|
|
414
|
-
setMenuPosition(draggableBlockElem, menuRef.current, anchorElem);
|
|
415
|
+
setMenuPosition(draggableBlockElem, menuRef.current, anchorElem, zoomLevel);
|
|
415
416
|
}
|
|
416
417
|
}, [anchorElem, draggableBlockElem, menuRef]);
|
|
417
418
|
useEffect(() => {
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var t=require("@lexical/react/LexicalComposerContext"),e=require("@lexical/rich-text"),n=require("@lexical/utils"),r=require("lexical"),o=require("react"),i=require("react-dom"),s=require("react/jsx-runtime");class l{_x;_y;constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}equals({x:t,y:e}){return this.x===t&&this.y===e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}}class a{_left;_top;_right;_bottom;constructor(t,e,n,r){const[o,i]=e<=r?[e,r]:[r,e],[s,l]=t<=n?[t,n]:[n,t];this._top=o,this._right=l,this._left=s,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:t,left:e,bottom:n,right:r}){return t===this._top&&n===this._bottom&&e===this._left&&r===this._right}contains(t){if(t instanceof l){const{x:e,y:n}=t,r=n<this._top,o=n>this._bottom,i=e<this._left,s=e>this._right;return{reason:{isOnBottomSide:o,isOnLeftSide:i,isOnRightSide:s,isOnTopSide:r},result:!(r||o||i||s)}}{const{top:e,left:n,bottom:r,right:o}=t;return e>=this._top&&e<=this._bottom&&r>=this._top&&r<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}}intersectsWith(t){const{left:e,top:n,width:r,height:o}=t,{left:i,top:s,width:l,height:a}=this;return(e+r>=i+l?e+r:i+l)-(e<=i?e:i)<=r+l&&(n+o>=s+a?n+o:s+a)-(n<=s?n:s)<=o+a}generateNewRect({left:t=this.left,top:e=this.top,right:n=this.right,bottom:r=this.bottom}){return new a(t,e,n,r)}static fromLTRB(t,e,n,r){return new a(t,e,n,r)}static fromLWTH(t,e,n,r){return new a(t,n,t+e,n+r)}static fromPoints(t,e){const{y:n,x:r}=t,{y:o,x:i}=e;return a.fromLTRB(r,n,i,o)}static fromDOM(t){const{top:e,width:n,left:r,height:o}=t.getBoundingClientRect();return a.fromLWTH(r,n,e,o)}}const c="application/x-lexical-drag-block";let u=1/0;function g(t){const e=(t,e)=>t?parseFloat(window.getComputedStyle(t)[e]):0,{marginTop:n,marginBottom:r}=window.getComputedStyle(t),o=e(t.previousElementSibling,"marginBottom"),i=e(t.nextElementSibling,"marginTop"),s=Math.max(parseFloat(n),o);return{marginBottom:Math.max(parseFloat(r),i),marginTop:s}}function h(t,e,o,i=!1){const s=t.getBoundingClientRect(),c=function(t){return t.getEditorState().read(()=>r.$getRoot().getChildrenKeys())}(e);let h=null;return e.getEditorState().read(()=>{if(i){const[t,r]=[e.getElementByKey(c[0]),e.getElementByKey(c[c.length-1])],[i,s]=[null!=t?t.getBoundingClientRect():void 0,null!=r?r.getBoundingClientRect():void 0];if(i&&s){const e=n.calculateZoomLevel(t),l=n.calculateZoomLevel(r);if(o.y/e<i.top?h=t:o.y/l>s.bottom&&(h=r),h)return}}let t=0===(r=c.length)?1/0:u>=0&&u<r?u:Math.floor(r/2);var r;let m=0;for(;t>=0&&t<c.length;){const r=c[t],i=e.getElementByKey(r);if(null===i)break;const f=n.calculateZoomLevel(i),p=new l(o.x/f,o.y/f),d=a.fromDOM(i),{marginTop:_,marginBottom:y}=g(i),x=d.generateNewRect({bottom:d.bottom+y,left:s.left,right:s.right,top:d.top-_}),{result:b,reason:{isOnTopSide:
|
|
9
|
+
"use strict";var t=require("@lexical/react/LexicalComposerContext"),e=require("@lexical/rich-text"),n=require("@lexical/utils"),r=require("lexical"),o=require("react"),i=require("react-dom"),s=require("react/jsx-runtime");class l{_x;_y;constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}equals({x:t,y:e}){return this.x===t&&this.y===e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}}class a{_left;_top;_right;_bottom;constructor(t,e,n,r){const[o,i]=e<=r?[e,r]:[r,e],[s,l]=t<=n?[t,n]:[n,t];this._top=o,this._right=l,this._left=s,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:t,left:e,bottom:n,right:r}){return t===this._top&&n===this._bottom&&e===this._left&&r===this._right}contains(t){if(t instanceof l){const{x:e,y:n}=t,r=n<this._top,o=n>this._bottom,i=e<this._left,s=e>this._right;return{reason:{isOnBottomSide:o,isOnLeftSide:i,isOnRightSide:s,isOnTopSide:r},result:!(r||o||i||s)}}{const{top:e,left:n,bottom:r,right:o}=t;return e>=this._top&&e<=this._bottom&&r>=this._top&&r<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}}intersectsWith(t){const{left:e,top:n,width:r,height:o}=t,{left:i,top:s,width:l,height:a}=this;return(e+r>=i+l?e+r:i+l)-(e<=i?e:i)<=r+l&&(n+o>=s+a?n+o:s+a)-(n<=s?n:s)<=o+a}generateNewRect({left:t=this.left,top:e=this.top,right:n=this.right,bottom:r=this.bottom}){return new a(t,e,n,r)}static fromLTRB(t,e,n,r){return new a(t,e,n,r)}static fromLWTH(t,e,n,r){return new a(t,n,t+e,n+r)}static fromPoints(t,e){const{y:n,x:r}=t,{y:o,x:i}=e;return a.fromLTRB(r,n,i,o)}static fromDOM(t){const{top:e,width:n,left:r,height:o}=t.getBoundingClientRect();return a.fromLWTH(r,n,e,o)}}const c="application/x-lexical-drag-block";let u=1/0;function g(t){const e=(t,e)=>t?parseFloat(window.getComputedStyle(t)[e]):0,{marginTop:n,marginBottom:r}=window.getComputedStyle(t),o=e(t.previousElementSibling,"marginBottom"),i=e(t.nextElementSibling,"marginTop"),s=Math.max(parseFloat(n),o);return{marginBottom:Math.max(parseFloat(r),i),marginTop:s}}function h(t,e,o,i=!1){const s=t.getBoundingClientRect(),c=function(t){return t.getEditorState().read(()=>r.$getRoot().getChildrenKeys())}(e);let h=null;return e.getEditorState().read(()=>{if(i){const[t,r]=[e.getElementByKey(c[0]),e.getElementByKey(c[c.length-1])],[i,s]=[null!=t?t.getBoundingClientRect():void 0,null!=r?r.getBoundingClientRect():void 0];if(i&&s){const e=n.calculateZoomLevel(t),l=n.calculateZoomLevel(r);if(o.y/e<i.top?h=t:o.y/l>s.bottom&&(h=r),h)return}}let t=0===(r=c.length)?1/0:u>=0&&u<r?u:Math.floor(r/2);var r;let m=0;for(;t>=0&&t<c.length;){const r=c[t],i=e.getElementByKey(r);if(null===i)break;const f=n.calculateZoomLevel(i),p=new l(o.x/f,o.y/f),d=a.fromDOM(i),{marginTop:_,marginBottom:y}=g(i),x=d.generateNewRect({bottom:d.bottom+y,left:s.left,right:s.right,top:d.top-_}),{result:b,reason:{isOnTopSide:C,isOnBottomSide:T}}=x.contains(p);if(b){h=i,u=t;break}0===m&&(m=C?-1:T?1:1/0),t+=m}}),h}function m(t,l,a,u,m,f,p,d,_){const y=l.parentElement,x=o.useRef(!1),[b,C]=o.useState(null),T=o.useCallback(t=>{C(t),_&&_(t)},[_]);return o.useEffect(()=>{function e(e){const r=e.target;if(!n.isHTMLElement(r))return void T(null);if(d(r))return;const o=h(l,t,e);T(o)}function r(){T(null)}return null!=y&&(y.addEventListener("mousemove",e),y.addEventListener("mouseleave",r)),()=>{null!=y&&(y.removeEventListener("mousemove",e),y.removeEventListener("mouseleave",r))}},[y,l,t,d,T]),o.useEffect(()=>{const t=n.calculateZoomLevel(document.getElementsByClassName("ContentEditable__root")[0],!0);a.current&&function(t,e,n,r){if(!t)return void(e.style.display="none");const o=t.getBoundingClientRect(),i=window.getComputedStyle(t),s=e.getBoundingClientRect(),l=n.getBoundingClientRect();let a=parseInt(i.lineHeight,10);isNaN(a)&&(a=o.bottom-o.top);const c=(o.top+(a-(s.height||a))/2-l.top+n.scrollTop)/r;e.style.display="flex",e.style.opacity="1",e.style.transform=`translate(4px, ${c}px)`}(b,a.current,l,t)},[l,b,a]),o.useEffect(()=>{function o(r){if(!x.current)return!1;const[o]=e.eventFiles(r);if(o)return!1;const{pageY:i,target:s}=r;if(!n.isHTMLElement(s))return!1;const a=h(l,t,r,!0),c=u.current;return null!==a&&null!==c&&(function(t,e,n,r){const{top:o,height:i}=e.getBoundingClientRect(),{top:s,width:l}=r.getBoundingClientRect(),{marginTop:a,marginBottom:c}=g(e);let u=o;n>=o?u+=i+c/2:u-=a/2;const h=u-s-2+r.scrollTop;t.style.transform=`translate(24px, ${h}px)`,t.style.width=l-48+"px",t.style.opacity=".4"}(c,a,i/n.calculateZoomLevel(s),l),r.preventDefault(),!0)}return n.mergeRegister(t.registerCommand(r.DRAGOVER_COMMAND,t=>o(t),r.COMMAND_PRIORITY_LOW),t.registerCommand(r.DROP_COMMAND,o=>function(o){if(!x.current)return!1;const[i]=e.eventFiles(o);if(i)return!1;const{target:s,dataTransfer:a,pageY:u}=o,g=null!=a?a.getData(c):"",m=r.$getNodeByKey(g);if(!m)return!1;if(!n.isHTMLElement(s))return!1;const f=h(l,t,o,!0);if(!f)return!1;const p=r.$getNearestNodeFromDOMNode(f);if(!p)return!1;if(p===m)return!0;const d=f.getBoundingClientRect().top;return u/n.calculateZoomLevel(s)>=d?p.insertAfter(m):p.insertBefore(m),T(null),!0}(o),r.COMMAND_PRIORITY_HIGH))},[l,t,u,T]),i.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{draggable:!0,onDragStart:function(e){const n=e.dataTransfer;if(!n||!b)return;!function(t,e){const{transform:n}=e.style;e.style.transform="translateZ(0)",t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=n})}(n,b);let o="";t.update(()=>{const t=r.$getNearestNodeFromDOMNode(b);t&&(o=t.getKey())}),x.current=!0,n.setData(c,o)},onDragEnd:function(){var t;x.current=!1,(t=u.current)&&(t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)")},children:m&&f}),p]}),l)}exports.DraggableBlockPlugin_EXPERIMENTAL=function({anchorElem:e=document.body,menuRef:n,targetLineRef:r,menuComponent:o,targetLineComponent:i,isOnMenu:s,onElementChanged:l}){const[a]=t.useLexicalComposerContext();return m(a,e,n,r,a._editable,o,i,s,l)};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{eventFiles as e}from"@lexical/rich-text";import{
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{eventFiles as e}from"@lexical/rich-text";import{calculateZoomLevel as n,mergeRegister as r,isHTMLElement as o}from"@lexical/utils";import{DRAGOVER_COMMAND as i,COMMAND_PRIORITY_LOW as s,DROP_COMMAND as l,COMMAND_PRIORITY_HIGH as a,$getNodeByKey as c,$getNearestNodeFromDOMNode as u,$getRoot as h}from"lexical";import{useRef as m,useState as g,useCallback as f,useEffect as p}from"react";import{createPortal as d}from"react-dom";import{jsxs as y,Fragment as _,jsx as x}from"react/jsx-runtime";class b{_x;_y;constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}equals({x:t,y:e}){return this.x===t&&this.y===e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}}class B{_left;_top;_right;_bottom;constructor(t,e,n,r){const[o,i]=e<=r?[e,r]:[r,e],[s,l]=t<=n?[t,n]:[n,t];this._top=o,this._right=l,this._left=s,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:t,left:e,bottom:n,right:r}){return t===this._top&&n===this._bottom&&e===this._left&&r===this._right}contains(t){if(t instanceof b){const{x:e,y:n}=t,r=n<this._top,o=n>this._bottom,i=e<this._left,s=e>this._right;return{reason:{isOnBottomSide:o,isOnLeftSide:i,isOnRightSide:s,isOnTopSide:r},result:!(r||o||i||s)}}{const{top:e,left:n,bottom:r,right:o}=t;return e>=this._top&&e<=this._bottom&&r>=this._top&&r<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}}intersectsWith(t){const{left:e,top:n,width:r,height:o}=t,{left:i,top:s,width:l,height:a}=this;return(e+r>=i+l?e+r:i+l)-(e<=i?e:i)<=r+l&&(n+o>=s+a?n+o:s+a)-(n<=s?n:s)<=o+a}generateNewRect({left:t=this.left,top:e=this.top,right:n=this.right,bottom:r=this.bottom}){return new B(t,e,n,r)}static fromLTRB(t,e,n,r){return new B(t,e,n,r)}static fromLWTH(t,e,n,r){return new B(t,n,t+e,n+r)}static fromPoints(t,e){const{y:n,x:r}=t,{y:o,x:i}=e;return B.fromLTRB(r,n,i,o)}static fromDOM(t){const{top:e,width:n,left:r,height:o}=t.getBoundingClientRect();return B.fromLWTH(r,n,e,o)}}const T="application/x-lexical-drag-block";let C=1/0;function w(t){const e=(t,e)=>t?parseFloat(window.getComputedStyle(t)[e]):0,{marginTop:n,marginBottom:r}=window.getComputedStyle(t),o=e(t.previousElementSibling,"marginBottom"),i=e(t.nextElementSibling,"marginTop"),s=Math.max(parseFloat(n),o);return{marginBottom:Math.max(parseFloat(r),i),marginTop:s}}function v(t,e,r,o=!1){const i=t.getBoundingClientRect(),s=function(t){return t.getEditorState().read(()=>h().getChildrenKeys())}(e);let l=null;return e.getEditorState().read(()=>{if(o){const[t,o]=[e.getElementByKey(s[0]),e.getElementByKey(s[s.length-1])],[i,a]=[null!=t?t.getBoundingClientRect():void 0,null!=o?o.getBoundingClientRect():void 0];if(i&&a){const e=n(t),s=n(o);if(r.y/e<i.top?l=t:r.y/s>a.bottom&&(l=o),l)return}}let t=0===(a=s.length)?1/0:C>=0&&C<a?C:Math.floor(a/2);var a;let c=0;for(;t>=0&&t<s.length;){const o=s[t],a=e.getElementByKey(o);if(null===a)break;const u=n(a),h=new b(r.x/u,r.y/u),m=B.fromDOM(a),{marginTop:g,marginBottom:f}=w(a),p=m.generateNewRect({bottom:m.bottom+f,left:i.left,right:i.right,top:m.top-g}),{result:d,reason:{isOnTopSide:y,isOnBottomSide:_}}=p.contains(h);if(d){l=a,C=t;break}0===c&&(c=y?-1:_?1:1/0),t+=c}}),l}function D(t,h,b,B,C,D,E,R,S){const M=h.parentElement,L=m(!1),[O,K]=g(null),N=f(t=>{K(t),S&&S(t)},[S]);return p(()=>{function e(e){const n=e.target;if(!o(n))return void N(null);if(R(n))return;const r=v(h,t,e);N(r)}function n(){N(null)}return null!=M&&(M.addEventListener("mousemove",e),M.addEventListener("mouseleave",n)),()=>{null!=M&&(M.removeEventListener("mousemove",e),M.removeEventListener("mouseleave",n))}},[M,h,t,R,N]),p(()=>{const t=n(document.getElementsByClassName("ContentEditable__root")[0],!0);b.current&&function(t,e,n,r){if(!t)return void(e.style.display="none");const o=t.getBoundingClientRect(),i=window.getComputedStyle(t),s=e.getBoundingClientRect(),l=n.getBoundingClientRect();let a=parseInt(i.lineHeight,10);isNaN(a)&&(a=o.bottom-o.top);const c=(o.top+(a-(s.height||a))/2-l.top+n.scrollTop)/r;e.style.display="flex",e.style.opacity="1",e.style.transform=`translate(4px, ${c}px)`}(O,b.current,h,t)},[h,O,b]),p(()=>{function m(r){if(!L.current)return!1;const[i]=e(r);if(i)return!1;const{pageY:s,target:l}=r;if(!o(l))return!1;const a=v(h,t,r,!0),c=B.current;return null!==a&&null!==c&&(function(t,e,n,r){const{top:o,height:i}=e.getBoundingClientRect(),{top:s,width:l}=r.getBoundingClientRect(),{marginTop:a,marginBottom:c}=w(e);let u=o;n>=o?u+=i+c/2:u-=a/2;const h=u-s-2+r.scrollTop;t.style.transform=`translate(24px, ${h}px)`,t.style.width=l-48+"px",t.style.opacity=".4"}(c,a,s/n(l),h),r.preventDefault(),!0)}return r(t.registerCommand(i,t=>m(t),s),t.registerCommand(l,r=>function(r){if(!L.current)return!1;const[i]=e(r);if(i)return!1;const{target:s,dataTransfer:l,pageY:a}=r,m=null!=l?l.getData(T):"",g=c(m);if(!g)return!1;if(!o(s))return!1;const f=v(h,t,r,!0);if(!f)return!1;const p=u(f);if(!p)return!1;if(p===g)return!0;const d=f.getBoundingClientRect().top;return a/n(s)>=d?p.insertAfter(g):p.insertBefore(g),N(null),!0}(r),a))},[h,t,B,N]),d(y(_,{children:[x("div",{draggable:!0,onDragStart:function(e){const n=e.dataTransfer;if(!n||!O)return;!function(t,e){const{transform:n}=e.style;e.style.transform="translateZ(0)",t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=n})}(n,O);let r="";t.update(()=>{const t=u(O);t&&(r=t.getKey())}),L.current=!0,n.setData(T,r)},onDragEnd:function(){var t;L.current=!1,(t=B.current)&&(t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)")},children:C&&D}),E]}),h)}function E({anchorElem:e=document.body,menuRef:n,targetLineRef:r,menuComponent:o,targetLineComponent:i,isOnMenu:s,onElementChanged:l}){const[a]=t();return D(a,e,n,r,a._editable,o,i,s,l)}export{E as DraggableBlockPlugin_EXPERIMENTAL};
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.39.1-nightly.
|
|
11
|
+
"version": "0.39.1-nightly.20251231.0",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@floating-ui/react": "^0.27.16",
|
|
14
|
-
"@lexical/devtools-core": "0.39.1-nightly.
|
|
15
|
-
"@lexical/dragon": "0.39.1-nightly.
|
|
16
|
-
"@lexical/extension": "0.39.1-nightly.
|
|
17
|
-
"@lexical/hashtag": "0.39.1-nightly.
|
|
18
|
-
"@lexical/history": "0.39.1-nightly.
|
|
19
|
-
"@lexical/link": "0.39.1-nightly.
|
|
20
|
-
"@lexical/list": "0.39.1-nightly.
|
|
21
|
-
"@lexical/mark": "0.39.1-nightly.
|
|
22
|
-
"@lexical/markdown": "0.39.1-nightly.
|
|
23
|
-
"@lexical/overflow": "0.39.1-nightly.
|
|
24
|
-
"@lexical/plain-text": "0.39.1-nightly.
|
|
25
|
-
"@lexical/rich-text": "0.39.1-nightly.
|
|
26
|
-
"@lexical/table": "0.39.1-nightly.
|
|
27
|
-
"@lexical/text": "0.39.1-nightly.
|
|
28
|
-
"@lexical/utils": "0.39.1-nightly.
|
|
29
|
-
"@lexical/yjs": "0.39.1-nightly.
|
|
30
|
-
"lexical": "0.39.1-nightly.
|
|
14
|
+
"@lexical/devtools-core": "0.39.1-nightly.20251231.0",
|
|
15
|
+
"@lexical/dragon": "0.39.1-nightly.20251231.0",
|
|
16
|
+
"@lexical/extension": "0.39.1-nightly.20251231.0",
|
|
17
|
+
"@lexical/hashtag": "0.39.1-nightly.20251231.0",
|
|
18
|
+
"@lexical/history": "0.39.1-nightly.20251231.0",
|
|
19
|
+
"@lexical/link": "0.39.1-nightly.20251231.0",
|
|
20
|
+
"@lexical/list": "0.39.1-nightly.20251231.0",
|
|
21
|
+
"@lexical/mark": "0.39.1-nightly.20251231.0",
|
|
22
|
+
"@lexical/markdown": "0.39.1-nightly.20251231.0",
|
|
23
|
+
"@lexical/overflow": "0.39.1-nightly.20251231.0",
|
|
24
|
+
"@lexical/plain-text": "0.39.1-nightly.20251231.0",
|
|
25
|
+
"@lexical/rich-text": "0.39.1-nightly.20251231.0",
|
|
26
|
+
"@lexical/table": "0.39.1-nightly.20251231.0",
|
|
27
|
+
"@lexical/text": "0.39.1-nightly.20251231.0",
|
|
28
|
+
"@lexical/utils": "0.39.1-nightly.20251231.0",
|
|
29
|
+
"@lexical/yjs": "0.39.1-nightly.20251231.0",
|
|
30
|
+
"lexical": "0.39.1-nightly.20251231.0",
|
|
31
31
|
"react-error-boundary": "^6.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|