@soul-refiner/design-system 2.14.128 → 2.14.129
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/components/editor/simple_editor/navbar.js +4 -4
- package/dist/components/editor/simple_editor/simple_editor.js +1 -1
- package/dist/src/components/editor/simple_editor/navbar.d.ts +5 -1
- package/dist/src/components/editor/simple_editor/navbar.d.ts.map +1 -1
- package/dist/src/components/editor/simple_editor/simple_editor.d.ts +5 -1
- package/dist/src/components/editor/simple_editor/simple_editor.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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"),r=require("styled-components"),n=require("@udecode/plate-common"),o=require("@udecode/plate-media"),i=require("../../feedback/tooltip/tooltip.js"),c=require("../navbar/alignment_dropdown.js"),s=require("../navbar/style_dropdown.js"),l=require("../../../icons/basic/bold.js"),d=require("../../../icons/basic/image.js"),a=require("../../../icons/basic/italic.js"),u=require("../../../icons/basic/link.js"),p=require("../../../icons/text/list_ordered.js"),x=require("../../../icons/text/list_unordered.js"),j=require("../../../icons/arrow/redo.js"),g=require("../../../icons/basic/underline.js"),h=require("../../../icons/arrow/undo.js"),y=require("../../../icons/audio_video/microphone.js"),f=require("../constants.js"),v=require("../styles/menu_button.js");function M(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=M(t);const k="undefined"!=typeof window?window.SpeechRecognition||window.webkitSpeechRecognition:void 0,m=r.styled.nav`
|
|
2
2
|
display: flex;
|
|
3
3
|
gap: 12px;
|
|
4
4
|
justify-content: center;
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
box-sizing: border-box;
|
|
10
10
|
border-radius: 8px 8px 0px 0px;
|
|
11
11
|
box-shadow: var(--elevation-1);
|
|
12
|
-
`,
|
|
12
|
+
`,w=r.styled.div`
|
|
13
13
|
display: flex;
|
|
14
14
|
gap: 16px;
|
|
15
15
|
align-items: center;
|
|
16
16
|
width: fit-content;
|
|
17
17
|
flex-shrink: 0;
|
|
18
|
-
`,
|
|
18
|
+
`,R=r.styled.div`
|
|
19
19
|
width: 1px;
|
|
20
20
|
height: 28px;
|
|
21
21
|
background-color: var(--color-grey-9);
|
|
22
|
-
`;exports.EditorBar=({handleUploadImage:t})=>{const
|
|
22
|
+
`;exports.EditorBar=({handleUploadImage:t,showLink:r=!0,showImage:M=!0})=>{const T=n.useEditorRef("main"),L=E.default.useRef(null),[b,A]=E.default.useState(!1),q=E.default.useRef(null),_=E.default.useRef(""),N=n.useEditorSelector(e=>n.isMarkActive(e,f.MARK_BOLD),[]),B=n.useEditorSelector(e=>n.isMarkActive(e,f.MARK_ITALIC),[]),I=n.useEditorSelector(e=>n.isMarkActive(e,f.MARK_UNDERLINE),[]),S=n.useEditorSelector(e=>n.isMarkActive(e,f.MARK_LINK),[]),C=n.useEditorSelector(e=>n.someNode(e,{match:{type:n.getPluginType(e,f.ELEMENT_OL)}}),[]),U=n.useEditorSelector(e=>n.someNode(e,{match:{type:n.getPluginType(e,f.ELEMENT_UL)}}),[]),z=E.default.useRef(T.selection);E.default.useEffect(()=>{T.selection&&(z.current=T.selection)},[T.selection]),E.default.useEffect(()=>()=>{q.current&&(q.current.stop(),q.current=null)},[]);const $=E.default.useCallback(e=>{if(!e)return;const t=z.current;t?(T.select(t),T.insertText(e+" ")):n.insertNode(T,{type:f.ELEMENT_PARAGRAPH,children:[{text:e+" "}]})},[T]);return e.jsxs(m,{"aria-label":"editor-navigation",children:[e.jsxs(w,{children:[e.jsx(i.Tooltip,{content:"Undo",place:"top",children:e.jsx(v.MenuButton,{$active:!1,onClick:()=>T.undo(),children:e.jsx(h.Undo,{size:24,color:"grey-5"})})}),e.jsx(i.Tooltip,{content:"Redo",place:"top",children:e.jsx(v.MenuButton,{$active:!1,onClick:()=>T.redo(),children:e.jsx(j.Redo,{size:24,color:"grey-5"})})})]}),e.jsx(R,{}),e.jsx(w,{children:e.jsx(s.StyleDropdown,{editorRef:T})}),e.jsx(R,{}),e.jsx(w,{children:e.jsx(v.MenuButton,{$active:!1,as:"div",children:e.jsx(c.AlignmentDropdown,{editorRef:T})})}),e.jsx(R,{}),e.jsxs(w,{children:[e.jsx(i.Tooltip,{content:"Bold",place:"top",children:e.jsx(v.MenuButton,{$active:N,onClick:()=>{T&&n.toggleMark(T,{key:f.MARK_BOLD})},children:e.jsx(l.Bold,{size:24,color:"grey-5"})})}),e.jsx(i.Tooltip,{content:"Italic",place:"top",children:e.jsx(v.MenuButton,{$active:B,onClick:()=>{T&&n.toggleMark(T,{key:f.MARK_ITALIC})},children:e.jsx(a.Italic,{size:24,color:"grey-5"})})}),e.jsx(i.Tooltip,{content:"Underline",place:"top",children:e.jsx(v.MenuButton,{$active:I,onClick:()=>{T&&n.toggleMark(T,{key:f.MARK_UNDERLINE})},children:e.jsx(g.Underline,{size:24,color:"grey-5"})})})]}),e.jsx(R,{}),e.jsxs(w,{children:[r&&e.jsx(i.Tooltip,{content:"Link",place:"top",children:e.jsx(v.MenuButton,{$active:S,onClick:()=>{const e=window.prompt("Enter URL:");e&&T&&n.toggleMark(T,{key:f.MARK_LINK,value:{url:e}})},children:e.jsx(u.Link,{size:24,color:"grey-5"})})}),M&&e.jsx(i.Tooltip,{content:"Image",place:"top",children:e.jsx(v.MenuButton,{$active:!1,as:"label",onChange:async()=>{const e=L.current?.files;if(!e)return;const r=await t(e);r&&(o.insertImage(T,r),n.insertNode(T,{type:f.ELEMENT_PARAGRAPH,children:[{text:" "}]}))},children:e.jsxs("div",{children:[e.jsx("input",{accept:"image/*",ref:L,style:{display:"none"},type:"file"}),e.jsx(d.Image,{size:24,color:"grey-5"})]})})}),k&&e.jsx(i.Tooltip,{content:b?"Stop and insert speech":"Speech to text",place:"top",children:e.jsx(v.MenuButton,{$active:b,onClick:()=>{if(!T)return;if(b)return q.current?void q.current.stop():void A(!1);if(q.current&&!b&&(q.current.stop(),q.current=null),!k)return;_.current="";const e=new k;e.continuous=!0,e.interimResults=!1,e.lang=navigator.language||"en-US",e.onresult=e=>{for(let t=e.resultIndex;t<e.results.length;t++){const r=e.results[t];if(r.isFinal&&r.length>0){const e=r[0].transcript;"string"==typeof e&&(_.current+=e)}}},e.onend=()=>{if(q.current===e){q.current=null,A(!1);const e=_.current.trim();_.current="",e&&$(e)}},e.onerror=e=>{console.error("Speech recognition error:",e.error),q.current=null,A(!1),_.current="","not-allowed"!==e.error&&"service-not-allowed"!==e.error||console.warn("Microphone access denied or not available")};try{e.start(),q.current=e,A(!0)}catch{A(!1)}},"aria-pressed":b,children:e.jsx(y.Microphone,{size:24,color:"grey-5"})})})]}),e.jsx(R,{}),e.jsxs(w,{children:[e.jsx(i.Tooltip,{content:"Unordered List",place:"top",children:e.jsx(v.MenuButton,{$active:U,onClick:()=>{T&&n.toggleNodeType(T,{activeType:n.getPluginType(T,f.ELEMENT_UL)})},children:e.jsx(x.ListUnordered,{size:24,color:"grey-5"})})}),e.jsx(i.Tooltip,{content:"Ordered List",place:"top",children:e.jsx(v.MenuButton,{$active:C,onClick:()=>{T&&n.toggleNodeType(T,{activeType:n.getPluginType(T,f.ELEMENT_OL)})},children:e.jsx(p.ListOrdered,{size:24,color:"grey-5"})})})]})]})};
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
& > [data-slate-editor='true'] > * {
|
|
71
71
|
margin: 24px 0px;
|
|
72
72
|
}
|
|
73
|
-
`;exports.SimpleEditor=({editable:r,handleUploadImage:o,onChange:p,validation:x,sx:j,validationMessage:f,placeholder:q="",previousContent:y=[{type:"p",children:[{text:""}]}]})=>{const[
|
|
73
|
+
`;exports.SimpleEditor=({editable:r,handleUploadImage:o,onChange:p,validation:x,sx:j,validationMessage:f,placeholder:q="",previousContent:y=[{type:"p",children:[{text:""}]}],showLink:v=!0,showImage:b=!0})=>{const[w,$]=h.default.useState([]);return e.jsxs(e.Fragment,{children:[e.jsx(s.Modal,{controlledOpen:w.length>0,children:e.jsx(s.Modal.Content,{footer:e.jsx(n.Box,{$display:"flex",$justify:"center",$gap:16,sx:"position: relative; width: 100%;",children:e.jsx(c.Button,{fluid:!0,size:"small",type:"primary",onClick:()=>$([]),children:"Close"})}),header:e.jsx(l.H,{$bold:!0,$color:"grey-2",$fontSize:20,children:"Can't read files"}),children:e.jsx(n.Box,{$align:"flex-start",$display:"flex",$dir:"column",$gap:32,sx:"width: 500px",children:e.jsx(d.P,{$textClampLines:10,children:f})})})}),e.jsx(a.Plate,{id:"main",initialValue:y,onChange:p,plugins:t.plugins,children:e.jsxs(m,{children:[r&&e.jsx(i.EditorBar,{handleUploadImage:async e=>{$([]);const r=[];if(x)for(let o=0;o<e.length;o++){const a=e[o],t=await u.validateFile(a,x);if(t.length>0){r.push(...t);break}}return r?.length>0?($(r),""):await o(e)},showLink:v,showImage:b}),e.jsx(g,{$sx:j,children:e.jsx(a.PlateContent,{id:"main",autoFocus:!0,placeholder:q,readOnly:!r,spellCheck:!0})})]})})]})};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export interface EditorBarProps {
|
|
2
2
|
handleUploadImage: (files: FileList) => Promise<string>;
|
|
3
|
+
/** Show the link button in the toolbar. Defaults to true. */
|
|
4
|
+
showLink?: boolean;
|
|
5
|
+
/** Show the image upload button in the toolbar. Defaults to true. */
|
|
6
|
+
showImage?: boolean;
|
|
3
7
|
}
|
|
4
|
-
export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const EditorBar: ({ handleUploadImage, showLink, showImage, }: EditorBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
9
|
//# sourceMappingURL=navbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/simple_editor/navbar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/simple_editor/navbar.tsx"],"names":[],"mappings":"AAoCA,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAYD,eAAO,MAAM,SAAS,gDAInB,cAAc,4CA+ShB,CAAC"}
|
|
@@ -13,6 +13,10 @@ export interface SimpleEditorProps {
|
|
|
13
13
|
} & DimensionOptions;
|
|
14
14
|
validationMessage?: string;
|
|
15
15
|
previousContent?: TElement[];
|
|
16
|
+
/** Show the link button in the toolbar. Defaults to true. */
|
|
17
|
+
showLink?: boolean;
|
|
18
|
+
/** Show the image upload button in the toolbar. Defaults to true. */
|
|
19
|
+
showImage?: boolean;
|
|
16
20
|
}
|
|
17
|
-
export declare const SimpleEditor: ({ editable, handleUploadImage, onChange, validation, sx, validationMessage, placeholder, previousContent, }: SimpleEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const SimpleEditor: ({ editable, handleUploadImage, onChange, validation, sx, validationMessage, placeholder, previousContent, showLink, showImage, }: SimpleEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
22
|
//# sourceMappingURL=simple_editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple_editor.d.ts","sourceRoot":"","sources":["../../../../../src/components/editor/simple_editor/simple_editor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAuB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMtE,OAAO,EACL,gBAAgB,EAEjB,MAAM,gDAAgD,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,KAA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