@soul-refiner/design-system 2.14.175 → 2.14.176
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom"),o=require("styled-components"),i=require("@udecode/plate-common"),r=require("slate-react"),l=require("../../../feedback/tooltip/tooltip.js"),d=require("./types.js"),a=require("./use-highlights.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(t);const u=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,h=e=>{const t=e.left+window.scrollX+e.width/2;return{top:u()?e.bottom+window.scrollY+8:e.top+window.scrollY-48,left:t}},g="#4A4F55",f="#eaebed",p=({color:t})=>e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M22.7448 12.0754L14.2002 3.6561C14.1825 3.63831 14.1615 3.6242 14.1383 3.61457C14.1151 3.60493 14.0903 3.59998 14.0652 3.59998C14.0401 3.59998 14.0152 3.60493 13.9921 3.61457C13.9689 3.6242 13.9479 3.63831 13.9302 3.6561L8.17507 9.3268C8.13886 9.36273 8.11829 9.41151 8.11783 9.46253C8.11738 9.51354 8.13709 9.56268 8.17266 9.59925L8.17507 9.60166L9.13948 10.5516L6.31377 13.3315C6.27755 13.3674 6.25698 13.4162 6.25653 13.4672C6.25608 13.5182 6.27578 13.5674 6.31136 13.6039L6.31377 13.6063L7.26612 14.5442L2.7069 19.0528H1.3953C1.28922 19.0528 1.20001 19.1396 1.20001 19.2457V20.5766C1.20001 20.6827 1.28681 20.7695 1.39289 20.7695H9.70848C9.75911 20.7695 9.80733 20.7502 9.8435 20.714L11.6783 18.8913L12.6523 19.8509C12.67 19.8687 12.6911 19.8828 12.7142 19.8924C12.7374 19.902 12.7623 19.907 12.7873 19.907C12.8124 19.907 12.8373 19.902 12.8605 19.8924C12.8836 19.8828 12.9047 19.8687 12.9224 19.8509L15.7457 17.0637L16.7125 18.0161C16.7302 18.0339 16.7512 18.048 16.7744 18.0576C16.7976 18.0673 16.8224 18.0722 16.8475 18.0722C16.8726 18.0722 16.8974 18.0673 16.9206 18.0576C16.9438 18.048 16.9648 18.0339 16.9825 18.0161L22.7376 12.3454C22.8196 12.2731 22.8196 12.1525 22.7448 12.0754ZM9.05509 19.0384H5.19265L8.43305 15.8317L10.3643 17.734L9.05509 19.0384ZM12.7873 17.5411L8.65487 13.4689L10.3088 11.8391L14.4413 15.9113L12.7873 17.5411ZM16.8499 15.7063L10.5138 9.46423L14.0652 5.96585L20.4013 12.2104L16.8499 15.7063Z",fill:t,stroke:g,strokeWidth:"0.5",paintOrder:"stroke fill"})}),m=()=>e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M6.4 19L5 17.6L10.6 12L5 6.4L6.4 5L12 10.6L17.6 5L19 6.4L13.4 12L19 17.6L17.6 19L12 13.4L6.4 19Z",fill:g})}),L=()=>e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.0588 2H4C2.89543 2 2 2.89543 2 4V20C2 21.1046 2.89543 22 4 22H15.5039C16.6084 22 17.5039 21.1046 17.5039 20V14.7273H15.5039V20H7.44531V4H14.0588V2ZM5.44531 4V20H4L4 4H5.44531Z",fill:g}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3118 6.73896L12.0089 16.5571H8.20703V12.5444L17.5099 2.7262C17.8898 2.32531 18.5056 2.32532 18.8855 2.72622L21.3118 5.2871C21.6917 5.68802 21.6917 6.33805 21.3118 6.73896ZM10.207 13.3414L18.1977 4.90819L19.2444 6.013L11.1487 14.5571H10.207V13.3414Z",fill:g})]}),v=o.styled.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
transform: translateX(-50%);
|
|
4
4
|
z-index: 9999;
|
|
@@ -10,29 +10,29 @@
|
|
|
10
10
|
border-radius: 8px;
|
|
11
11
|
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);
|
|
12
12
|
pointer-events: auto;
|
|
13
|
-
`,
|
|
13
|
+
`,x=o.styled.button`
|
|
14
14
|
display: inline-flex;
|
|
15
15
|
align-items: center;
|
|
16
16
|
justify-content: center;
|
|
17
17
|
width: 28px;
|
|
18
18
|
height: 28px;
|
|
19
19
|
padding: 2px;
|
|
20
|
-
background: ${e=>e.$active?`var(--color-grey-9, ${
|
|
20
|
+
background: ${e=>e.$active?`var(--color-grey-9, ${f})`:"none"};
|
|
21
21
|
border: none;
|
|
22
22
|
border-radius: 6px;
|
|
23
23
|
cursor: pointer;
|
|
24
24
|
transition: background 0.15s ease;
|
|
25
25
|
|
|
26
26
|
&:hover {
|
|
27
|
-
background: var(--color-grey-9, ${
|
|
27
|
+
background: var(--color-grey-9, ${f});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
&:focus-visible {
|
|
31
31
|
outline: 2px solid var(--color-primary-blue-2, ${"#0076d9"});
|
|
32
32
|
outline-offset: 1px;
|
|
33
33
|
}
|
|
34
|
-
`,
|
|
34
|
+
`,w=o.styled.div`
|
|
35
35
|
width: 1px;
|
|
36
36
|
height: 20px;
|
|
37
37
|
background: var(--color-grey-8, ${"#e5e7eb"});
|
|
38
|
-
`;exports.FloatingHighlightToolbar=({highlights:t,onHighlight:
|
|
38
|
+
`;exports.FloatingHighlightToolbar=({highlights:t,onHighlight:o,onChangeColor:s,onRemoveHighlight:g,onOpenNotes:f})=>{const C=i.useEditorRef(),[b,y]=c.default.useState(null),[E,j]=c.default.useState(!1),R=c.default.useRef(null),H=c.default.useRef(null),k=c.default.useRef(null);c.default.useEffect(()=>j(!0),[]);const M=c.default.useCallback(()=>{const e=window.getSelection();if(!e||e.isCollapsed||!e.rangeCount)return;let t=null;try{t=r.ReactEditor.toDOMNode(C,C)}catch{return}const n=e.getRangeAt(0);if(!t.contains(n.commonAncestorContainer))return;const o=n.getBoundingClientRect();if(0===o.width)return;let i=null;try{i=r.ReactEditor.toSlateRange(C,e,{exactMatch:!1,suppressThrow:!0})}catch{return}i&&y({mode:"add",range:i,position:h(o)})},[C]);if(c.default.useEffect(()=>{const e=()=>{const e=window.getSelection();e&&!e.isCollapsed&&e.rangeCount?M():y(e=>"add"===e?.mode?null:e)};return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[M]),c.default.useEffect(()=>{if(!u())return;let e;const t=t=>{R.current?.contains(t.target)||(e=window.setTimeout(()=>M(),0))};return document.addEventListener("touchend",t),()=>{window.clearTimeout(e),document.removeEventListener("touchend",t)}},[M]),c.default.useEffect(()=>{const e=e=>{const t=e.target;if(!t)return;if(R.current?.contains(t))return;const n=t.closest("[data-highlight-id]");if(!n)return;let o=null;try{o=r.ReactEditor.toDOMNode(C,C)}catch{return}if(!o.contains(n))return;const i=window.getSelection();if(i&&!i.isCollapsed)return;const l=n.getAttribute("data-highlight-id");if(!l)return;const d=n.getBoundingClientRect();k.current=document.activeElement??null,y({mode:"edit",highlightId:l,position:h(d)})};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[C]),c.default.useEffect(()=>{if("edit"===b?.mode){const e=window.requestAnimationFrame(()=>{H.current?.focus()});return()=>window.cancelAnimationFrame(e)}!b&&k.current&&(k.current.focus(),k.current=null)},[b]),c.default.useEffect(()=>{if(!b)return;const e=e=>{"Escape"===e.key&&(y(null),"add"===b.mode&&window.getSelection()?.removeAllRanges())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[b]),c.default.useEffect(()=>{if(!b)return;const e=e=>{if(R.current?.contains(e.target))return;const t=e.target?.closest?.("[data-highlight-id]");"edit"===b.mode&&t?.getAttribute("data-highlight-id")===b.highlightId||y(null)},t=setTimeout(()=>{document.addEventListener("mousedown",e)},100);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[b]),!E||!b)return null;const T="edit"===b.mode?t.find(e=>e.id===b.highlightId)?.color.toUpperCase():null;return n.createPortal(e.jsxs(v,{ref:R,role:"toolbar","aria-label":"Highlight options",style:{top:b.position.top,left:b.position.left},children:[d.HIGHLIGHT_COLORS.map((t,n)=>{const i=T===t.value.toUpperCase();return e.jsx(x,{ref:0===n?H:void 0,type:"button","aria-label":`Highlight ${t.label.toLowerCase()}`,"aria-pressed":i,$active:i,onClick:e=>{var n;e.preventDefault(),e.stopPropagation(),n=t.value,"add"===b.mode?o(n,b.range):"edit"===b.mode&&s&&s(b.highlightId,n),y(null)},children:e.jsx(p,{color:t.iconColor})},t.value)}),e.jsx(l.Tooltip,{content:"edit"===b.mode?"Remove highlight":"Dismiss",place:"top",children:e.jsx(x,{type:"button","aria-label":"edit"===b.mode?"Remove highlight":"Dismiss",onClick:e=>{e.preventDefault(),e.stopPropagation(),"edit"===b.mode&&g?g(b.highlightId):window.getSelection()?.removeAllRanges(),y(null)},children:e.jsx(m,{})})}),f&&e.jsxs(e.Fragment,{children:[e.jsx(w,{}),e.jsx(l.Tooltip,{content:"Add to note",place:"top",children:e.jsx(x,{type:"button","aria-label":"Add to note",onClick:e=>{if(e.preventDefault(),e.stopPropagation(),"add"===b.mode){let e="";try{e=a.extractSnippetFromRange(C,b.range)}catch(e){"production"!==process.env.NODE_ENV&&console.warn("[FloatingHighlightToolbar] failed to extract snippet from range",e)}f({mode:"add",snippetText:e})}else{const e=t.find(e=>e.id===b.highlightId);f({mode:"edit",snippetText:e?.snippetText??"",highlightId:b.highlightId})}y(null)},children:e.jsx(L,{})})})]})]}),document.body)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-highlight-toolbar.d.ts","sourceRoot":"","sources":["../../../../../../src/components/editor/plugins/highlights/floating-highlight-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1D,UAAU,6BAA6B;IAIrC,UAAU,EAAE,aAAa,EAAE,CAAC;IAE5B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAEvD,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEpD,iBAAiB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAazC,WAAW,CAAC,EAAE,CACZ,OAAO,EACH;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACpC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAC3D,IAAI,CAAC;CACX;
|
|
1
|
+
{"version":3,"file":"floating-highlight-toolbar.d.ts","sourceRoot":"","sources":["../../../../../../src/components/editor/plugins/highlights/floating-highlight-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAG1D,UAAU,6BAA6B;IAIrC,UAAU,EAAE,aAAa,EAAE,CAAC;IAE5B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAEvD,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEpD,iBAAiB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAazC,WAAW,CAAC,EAAE,CACZ,OAAO,EACH;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACpC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAC3D,IAAI,CAAC;CACX;AA0CD,eAAO,MAAM,wBAAwB,gFAMlC,6BAA6B,sBAwU/B,CAAC"}
|