@yoopta/lists 2.0.1 → 4.0.0-rc.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Akhmed Ibragimov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # `@yoopta/code`
1
+ # `yoopta-lists`
2
2
 
3
3
  > TODO: description
4
4
 
5
5
  ## Usage
6
6
 
7
7
  ```
8
- const blockquote = require('@yoopta/code');
8
+ const lists = require('yoopta-lists');
9
9
 
10
10
  // TODO: DEMONSTRATE API
11
11
  ```
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { PluginElementRenderProps } from '@yoopta/editor';
3
+ declare const BulletedListRender: ({ attributes, element, children }: PluginElementRenderProps<unknown>) => JSX.Element;
4
+ export { BulletedListRender };
5
+ //# sourceMappingURL=BulletedList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BulletedList.d.ts","sourceRoot":"","sources":["../../src/elements/BulletedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,QAAA,MAAM,kBAAkB,sCAAuC,yBAAyB,OAAO,CAAC,gBAa/F,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { PluginElementRenderProps } from '@yoopta/editor';
3
+ declare const NumberedListRender: ({ attributes, children, blockId, element }: PluginElementRenderProps<unknown>) => JSX.Element;
4
+ export { NumberedListRender };
5
+ //# sourceMappingURL=NumberedList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberedList.d.ts","sourceRoot":"","sources":["../../src/elements/NumberedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,wBAAwB,EAGzB,MAAM,gBAAgB,CAAC;AAExB,QAAA,MAAM,kBAAkB,+CAAgD,yBAAyB,OAAO,CAAC,gBAwBxG,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { PluginElementRenderProps } from '@yoopta/editor';
3
+ declare const TodoListRender: ({ attributes, element, children }: PluginElementRenderProps) => JSX.Element;
4
+ export { TodoListRender };
5
+ //# sourceMappingURL=TodoList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TodoList.d.ts","sourceRoot":"","sources":["../../src/elements/TodoList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,QAAA,MAAM,cAAc,sCAAuC,wBAAwB,gBAalF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { YooEditor, PluginEventHandlerOptions } from '@yoopta/editor';
2
+ import { Editor } from 'slate';
3
+ export declare function onKeyDown(editor: YooEditor, slate: Editor, { hotkeys, defaultBlock }: PluginEventHandlerOptions): (event: any) => void;
4
+ //# sourceMappingURL=onKeyDown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onKeyDown.d.ts","sourceRoot":"","sources":["../../src/events/onKeyDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,yBAAyB,EAK1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAiB,MAAM,OAAO,CAAC;AAK9C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,yBAAyB,wBAoF/G"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- import Lists, { BulletedList, NumberedList, TodoList } from './Lists';
2
- export default Lists;
3
- export { NumberedList, BulletedList, TodoList };
1
+ import { LISTS } from './plugin';
2
+ import { NumberedListElement, BulletedListElement, TodoListElement } from './types';
3
+ import './styles.css';
4
+ declare module 'slate' {
5
+ interface CustomTypes {
6
+ Element: NumberedListElement | BulletedListElement | TodoListElement;
7
+ }
8
+ }
9
+ export default LISTS;
10
+ declare const NumberedList: import("@yoopta/editor").YooptaPlugin<"numbered-list", import("./types").ListElementProps, Record<string, unknown>>;
11
+ declare const BulletedList: import("@yoopta/editor").YooptaPlugin<"bulleted-list", BulletedListElement, Record<string, unknown>>;
12
+ declare const TodoList: import("@yoopta/editor").YooptaPlugin<"todo-list", import("./types").TodoListElementProps, Record<string, unknown>>;
13
+ export { NumberedListElement, BulletedListElement, TodoListElement, NumberedList, BulletedList, TodoList, };
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,cAAc,CAAC;AAEtB,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,WAAW;QACnB,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,eAAe,CAAC;KACtE;CACF;AAED,eAAe,KAAK,CAAC;AAErB,QAAA,MAAM,YAAY,qHAAqB,CAAC;AACxC,QAAA,MAAM,YAAY,sGAAqB,CAAC;AACxC,QAAA,MAAM,QAAQ,qHAAiB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EAEf,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{createYooptaPlugin as i,generateId as n,getElementByPath as s,getElementClassname as r,cx as a}from"@yoopta/editor";import{Element as l,Editor as o,Transforms as d,Path as c}from"slate";import{ReactEditor as p}from"slate-react";function h(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}var m="mfUTTw6O";h(".mfUTTw6O{color:inherit;font-size:16px;letter-spacing:-.003em;line-height:28px;list-style-position:inside;padding-bottom:2px;padding-left:0;padding-top:2px;position:relative}.qvO-1a-q{align-items:center;display:flex;flex-grow:0;flex-shrink:0;justify-content:center;margin-right:2px;min-height:calc(1.5em + 6px);user-select:none;width:24px}.xPshFZ5Y{box-sizing:border-box;color:#000;display:inline;flex-shrink:0;font-size:16px;font-style:normal;font-weight:400;line-height:28px;min-width:28px;padding:0 6px 0 4px;word-break:break-word}");const u=({attributes:t,children:i,HTMLAttributes:n})=>e("li",Object.assign({className:m,draggable:!1},n,t,{children:i}));u.displayName="ListItem";const g="list-item",f=i({type:g,renderer:e=>u,extendEditor(e){const{normalizeNode:t}=e;return e.normalizeNode=i=>{const[n,s]=i;if(l.isElement(n)&&n.type===g){const t=n.children[0];l.isElement(t)&&!o.isInline(e,t)&&d.unwrapNodes(e,{at:s.concat(0)})}t(i)},e},shortcut:"-",defineElement:()=>({id:n(),type:"list-item",children:[{text:""}],nodeType:"block"}),placeholder:null,events:{onKeyDown:(e,{hotkeys:t,defaultNode:i})=>r=>{if(!e.selection)return;if(s(e,e.selection.anchor.path,"lowest").type!==g)return;const a=o.above(e,{at:e.selection.anchor,match:e=>l.isElement(e)&&e.type===g});if(!a)return;const{anchor:p}=e.selection,[h,m]=a,[u,y]=o.parent(e,m),b=o.string(e,m),v=o.isEnd(e,p,m),x=o.isStart(e,p,m),N=m.length-1,k=2===N,E=1===N;if(t.isShiftEnter(r))return r.preventDefault(),void e.insertText("\n");if(t.isEnter(r)){if(r.preventDefault(),""===b.trim()){d.unwrapNodes(e,{match:e=>!o.isEditor(e)&&l.isElement(e)&&e.type===u.type,split:!0});const t=N>1?{id:n(),type:g,children:[{text:""}]}:i;return void d.setNodes(e,t,{at:e.selection})}if(!v&&!x)return d.splitNodes(e),void d.setNodes(e,{id:n()});const t=Object.assign(Object.assign({},h),{id:n(),children:[{text:""}]});d.insertNodes(e,t)}else if(t.isBackspace(r)){const[,t]=o.first(e,y),n=0===c.compare(e.selection.anchor.path,t);x&&n&&(r.preventDefault(),d.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===u.type,split:!0}),d.setNodes(e,i,{at:e.selection}))}else{if(t.isTab(r)){if(r.preventDefault(),k)return;const t=Object.assign(Object.assign({},u),{id:n(),type:u.type,children:[f.getPlugin.defineElement()]});return d.wrapNodes(e,t,{at:m}),void d.setNodes(e,{data:{depth:N+1,skipDrag:!0}},{match:e=>l.isElement(e)&&e.type===u.type})}if(t.isShiftTab(r)){if(r.preventDefault(),E)return;return d.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===u.type,split:!0}),void d.setNodes(e,{data:{depth:N-1,skipDrag:!0}},{match:e=>l.isElement(e)&&e.type===u.type})}}}},exports:{markdown:{serialize:(e,t)=>`- ${t}`},html:{serialize:(e,t)=>`<li>${t}</li>`,deserialize:{nodeName:"LI"}}}});var y="cN2XzHcO";h(".cN2XzHcO{margin:2px 0;padding-left:18px}");const b=({attributes:t,children:i,element:n,HTMLAttributes:s})=>e("ol",Object.assign({draggable:!1},s,t,{className:r({element:n,HTMLAttributes:s,className:y})},{children:i})),v=i({type:"numbered-list",renderer:e=>b,childPlugin:f,shortcut:"1.",defineElement:()=>({id:n(),type:"numbered-list",children:[f.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),createElement:(e,t)=>{var i,n;const s=f.getPlugin.defineElement();d.unwrapNodes(e,{match:e=>{var t;return!o.isEditor(e)&&l.isElement(e)&&"list-item"!==e.type&&"todo-list-item"!==e.type&&(null===(t=e.data)||void 0===t?void 0:t.depth)>=1},split:!0}),d.setNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor});const r=Object.assign(Object.assign({},v.getPlugin.defineElement()),t);d.wrapNodes(e,r,{at:null===(n=e.selection)||void 0===n?void 0:n.anchor})},exports:{markdown:{serialize:(e,t)=>`${t}\n`},html:{serialize:(e,t)=>{var i;return`<ol style="padding-left: ${(null===(i=e.data)||void 0===i?void 0:i.depth)?15*e.data.depth:15}px;">${t}</ol>`},deserialize:{nodeName:"OL"}}},options:{searchString:"order number list",displayLabel:"NumberedList"}});var x="wVFRrWWa";h(".wVFRrWWa{margin:2px 0;padding-left:18px}");const N=({attributes:t,children:i,element:n,HTMLAttributes:s})=>e("ul",Object.assign({draggable:!1},s,{className:r({element:n,HTMLAttributes:s,className:x})},t,{children:i})),k=i({type:"bulleted-list",renderer:e=>N,shortcut:"-",childPlugin:f,defineElement:()=>({id:n(),type:"bulleted-list",children:[f.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),createElement:(e,t)=>{var i,n;const s=f.getPlugin.defineElement();d.unwrapNodes(e,{match:e=>{var t;return!o.isEditor(e)&&l.isElement(e)&&"list-item"!==e.type&&"todo-list-item"!==e.type&&(null===(t=e.data)||void 0===t?void 0:t.depth)>=1},split:!0}),d.setNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor});const r=Object.assign(Object.assign({},k.getPlugin.defineElement()),t);d.wrapNodes(e,r,{at:null===(n=e.selection)||void 0===n?void 0:n.anchor})},exports:{markdown:{serialize:(e,t)=>`- ${t}`},html:{serialize:(e,t)=>{var i;return`<ul style="padding-left: ${(null===(i=e.data)||void 0===i?void 0:i.depth)?15*e.data.depth:15}px;">${t}</ul>`},deserialize:{nodeName:"UL"}}},options:{searchString:"bullet list",displayLabel:"BulletedList"}});var E="zLPFpe0C",w="cJeUAnzK",T="YT2kDg7r",z="GzvUWhTl",O="YiyH9UVU";h('.zLPFpe0C{fill:inherit;align-items:flex-start;color:#292929;color:inherit;display:flex;font-size:16px;letter-spacing:-.003em;line-height:24px;margin-bottom:1px;margin-top:1px;padding-bottom:2px;padding-left:2px;padding-top:2px;width:100%}.cJeUAnzK{text-decoration:line-through}.YT2kDg7r{align-items:center;display:flex;flex-grow:0;flex-shrink:0;justify-content:center;margin-right:2px;min-height:30px;user-select:none;width:24px}.YT2kDg7r+.YT2kDg7r{margin-top:1em}.GzvUWhTl{align-items:center;-webkit-appearance:none;appearance:none;border:.1em solid;color:currentColor;cursor:pointer;display:flex;flex-grow:0;flex-shrink:0;height:1.15em;height:16px;place-content:center;justify-content:center;position:relative;transition:background .2s ease-out 0s;width:1.15em;width:16px}.GzvUWhTl:before{background-color:CanvasText;clip-path:polygon(14% 44%,0 65%,50% 100%,100% 16%,80% 0,43% 62%);color:inherit;content:"";height:.65em;transform:scale(0);transform-origin:bottom left;transition:transform .12s ease-in-out;width:.65em}.GzvUWhTl:checked:before{transform:scale(1)}.YiyH9UVU{caret-color:#37352f;max-width:100%;min-width:1px;opacity:1;padding:3px 2px;text-align:left;white-space:pre-wrap;word-break:break-word}');const j="todo-list-item",L=i({type:j,renderer:i=>function({attributes:n,children:s,element:r,HTMLAttributes:o}){const c=r.data.checked;return t("div",Object.assign({draggable:!1},n,o,{className:a(E,{[w]:c})},{children:[e("label",Object.assign({className:T,contentEditable:!1,style:{userSelect:"none"}},{children:e("input",{type:"checkbox",checked:c,className:z,onChange:e=>{const t=p.findPath(i,r);d.setNodes(i,{data:{checked:e.target.checked}},{at:t,match:e=>l.isElement(e)&&e.type===j})}})})),e("span",Object.assign({className:O},{children:s}))]}))},placeholder:null,defineElement:()=>({id:n(),type:"todo-list-item",children:[{text:""}],nodeType:"block",data:{checked:!1}}),events:{onKeyDown:(e,{hotkeys:t,defaultNode:i})=>r=>{var a;if(!e.selection)return;if(s(e,e.selection.anchor.path,"lowest").type!==j)return;const p=o.above(e,{at:null===(a=e.selection)||void 0===a?void 0:a.anchor.path,match:e=>l.isElement(e)&&e.type===j});if(!p)return;const[h,m]=p,[u,g]=o.parent(e,m),f=o.string(e,m),y=o.isEnd(e,e.selection.anchor,m),b=o.isStart(e,e.selection.anchor,m),v=m.length-1,x=2===v,N=1===v;if(t.isShiftEnter(r))return r.preventDefault(),void e.insertText("\n");if(t.isEnter(r)){if(r.preventDefault(),""===f.trim()){d.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===u.type,split:!0});const t=v>1?{id:n(),type:j,children:[{text:""}],options:{checked:!1}}:i;return void d.setNodes(e,t,{at:e.selection})}if(!y&&!b)return d.splitNodes(e),void d.setNodes(e,{id:n(),data:{checked:!1}},{match:e=>l.isElement(e)&&e.type===j});const t=Object.assign(Object.assign({},h),{id:n(),children:[{text:""}],data:{checked:!1}});d.insertNodes(e,t,{select:!0})}else{if(t.isCmdEnter(r))return r.preventDefault(),void d.setNodes(e,{data:{checked:!h.data.checked}},{at:m,match:e=>l.isElement(e)&&e.type===j});if(t.isBackspace(r)){const[,t]=o.first(e,g),n=0===c.compare(e.selection.anchor.path,t);b&&n&&(r.preventDefault(),d.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===u.type,split:!0}),d.setNodes(e,i,{at:e.selection}))}else if(t.isTab(r)){if(r.preventDefault(),x)return;const t=Object.assign(Object.assign({},u),{id:n(),type:u.type,children:[L.getPlugin.defineElement()]});d.wrapNodes(e,t,{at:m})}else if(t.isShiftTab(r)){if(r.preventDefault(),N)return;d.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===u.type,split:!0})}else;}}},options:{checked:!1},exports:{markdown:{serialize:(e,t)=>`[${e.data.checked?"x":" "}] ${t}\n`},html:{serialize:(e,t)=>`<div>[${e.data.checked?"x":" "}] ${t}</div>`}}});var D="Mzo1TbSt";h(".Mzo1TbSt{padding-left:18px}");const P=({attributes:t,element:i,children:n,HTMLAttributes:s})=>e("div",Object.assign({draggable:!1},s,t,{className:r({element:i,HTMLAttributes:s,className:D})},{children:n})),S=i({type:"todo-list",renderer:e=>P,childPlugin:L,shortcut:"[]",defineElement:()=>({id:n(),type:"todo-list",children:[L.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),createElement:(e,t)=>{var i,n;const s=L.getPlugin.defineElement();d.unwrapNodes(e,{match:e=>{var t;return!o.isEditor(e)&&l.isElement(e)&&"list-item"!==e.type&&"todo-list-item"!==e.type&&(null===(t=e.data)||void 0===t?void 0:t.depth)>=1},split:!0}),d.setNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.anchor});const r=Object.assign(Object.assign({},S.getPlugin.defineElement()),t);d.wrapNodes(e,r,{at:null===(n=e.selection)||void 0===n?void 0:n.anchor})},exports:{markdown:{serialize:(e,t)=>`${t}`},html:{serialize:(e,t)=>{var i;return`<div style="padding-left: ${(null===(i=e.data)||void 0===i?void 0:i.depth)?15*e.data.depth:15}px;">${t}</div>`}}},options:{searchString:"todo check list",displayLabel:"TodoList"}}),$={NumberedList:v,BulletedList:k,TodoList:S};export{k as BulletedList,v as NumberedList,S as TodoList,$ as default};
1
+ import{findPluginBlockBySelectionPath as e,buildBlockData as t,buildBlockElement as s,YooptaPlugin as o}from"@yoopta/editor";import{jsxs as i,jsx as n}from"react/jsx-runtime";import{Editor as r,Element as l}from"slate";function p(o,i,{hotkeys:n,defaultBlock:p}){return d=>{r.withoutNormalizing(i,(()=>{var a;const c=e(o);if(!i.selection||!c)return;const m=i.selection,{anchor:u}=m;if(n.isEnter(d)){d.preventDefault();const e=r.above(i,{at:u,match:e=>!r.isEditor(e)&&l.isElement(e)&&("numbered-list"===e.type||"bulleted-list"===e.type||"todo-list"===e.type),mode:"highest"});if(!e)return;const[n,m]=e,y=(null===(a=n.props)||void 0===a?void 0:a.position)||0,h=r.isEnd(i,u,m),x=r.isStart(i,u,m),f=r.string(i,m),b=0===c.meta.depth,v=f.trim().length>0;if(!v){if(b){const e=c.meta.order;return o.deleteBlock({blockId:c.id}),void o.insertBlock(p,{at:[e],focus:!0})}return void o.decreaseBlockDepth({blockId:c.id})}if(x){const e=t({type:c.type,meta:{order:c.meta.order,depth:c.meta.depth},value:[s({type:n.type,props:{nodeType:"block",position:y-1}})]});return void o.insertBlock(e,{at:[c.meta.order],focus:!1})}if(v&&!x&&!h)return void o.splitBlock({slate:i,focus:!0});const g=t({type:c.type,meta:{order:c.meta.order+1,depth:c.meta.depth},value:[s({type:n.type,props:{nodeType:"block",position:y+1}})]});o.insertBlock(g,{at:[c.meta.order+1],focus:!0})}else;}))}}const d={BulletedList:new o({type:"BulletedList",elements:{"bulleted-list":{render:({attributes:e,element:t,children:s})=>i("div",Object.assign({"data-element-type":t.type,className:"flex items-center pl-4 space-x-2 py-[3px] text-[16px]"},e,{children:[n("span",Object.assign({className:"min-w-[10px] w-auto",contentEditable:!1},{children:"•"})),n("span",Object.assign({className:"flex-grow"},{children:s}))]}))}},options:{displayLabel:"BulletedList",shortcuts:["-"]},events:{onKeyDown:p}}),NumberedList:new o({type:"NumberedList",elements:{"numbered-list":{render:({attributes:e,children:t,blockId:s,element:o})=>{return i("div",Object.assign({"data-element-type":o.type},e,{className:"flex items-center pl-4 space-x-2 py-[3px] text-[16px]"},{children:[i("span",Object.assign({className:"min-w-[10px] w-auto"},{children:[("number"==typeof(null===(r=o.props)||void 0===r?void 0:r.position)?null===(l=o.props)||void 0===l?void 0:l.position:0)+1,"."]})),n("span",Object.assign({className:"flex-grow"},{children:t}))]}));var r,l},props:{nodeType:"block",position:0}}},options:{displayLabel:"Numbered List",shortcuts:["1."]},events:{onKeyDown:p}}),TodoList:new o({type:"TodoList",elements:{"todo-list":{render:({attributes:e,element:t,children:s})=>{const{checked:o=!1}=t.props||{};return i("div",Object.assign({"data-element-type":t.type,className:"flex items-center pl-4 space-x-2 py-[3px] text-[16px]"},e,{children:[n("input",{type:"checkbox",className:"form-checkbox min-w-[10px] w-auto",checked:o}),n("div",Object.assign({className:"flex-grow"},{children:s}))]}))},props:{checked:!1}}},options:{displayLabel:"Todo List",shortcuts:["[]"]},events:{onKeyDown:p}})};!function(e,t){void 0===t&&(t={});var s=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===s&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".\\!block{display:block!important}.block{display:block}.flex{display:flex}.w-auto{width:auto}.min-w-\\[10px\\]{min-width:10px}.flex-grow{flex-grow:1}.items-center{align-items:center}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.py-\\[3px\\]{padding-bottom:3px;padding-top:3px}.pl-4{padding-left:1rem}.text-\\[16px\\]{font-size:16px}");const a=d.NumberedList,c=d.BulletedList,m=d.TodoList;export{c as BulletedList,a as NumberedList,m as TodoList,d as default};
@@ -0,0 +1,5 @@
1
+ import { YooptaPlugin } from '@yoopta/editor';
2
+ import { BulletedListElement } from '../types';
3
+ declare const BulletedList: YooptaPlugin<"bulleted-list", BulletedListElement, Record<string, unknown>>;
4
+ export { BulletedList };
5
+ //# sourceMappingURL=BulletedList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BulletedList.d.ts","sourceRoot":"","sources":["../../src/plugin/BulletedList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,mBAAmB,EAA0B,MAAM,UAAU,CAAC;AAEvE,QAAA,MAAM,YAAY,6EAchB,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { YooptaPlugin } from '@yoopta/editor';
2
+ import { ListElementProps } from '../types';
3
+ declare const NumberedList: YooptaPlugin<"numbered-list", ListElementProps, Record<string, unknown>>;
4
+ export { NumberedList };
5
+ //# sourceMappingURL=NumberedList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberedList.d.ts","sourceRoot":"","sources":["../../src/plugin/NumberedList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,QAAA,MAAM,YAAY,0EAkBhB,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { YooptaPlugin } from '@yoopta/editor';
2
+ import { TodoListElementProps } from '../types';
3
+ declare const TodoList: YooptaPlugin<"todo-list", TodoListElementProps, Record<string, unknown>>;
4
+ export { TodoList };
5
+ //# sourceMappingURL=TodoList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TodoList.d.ts","sourceRoot":"","sources":["../../src/plugin/TodoList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,oBAAoB,EAAsB,MAAM,UAAU,CAAC;AAEpE,QAAA,MAAM,QAAQ,0EAiBZ,CAAC;AAEH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const LISTS: {
2
+ BulletedList: import("@yoopta/editor").YooptaPlugin<"bulleted-list", import("..").BulletedListElement, Record<string, unknown>>;
3
+ NumberedList: import("@yoopta/editor").YooptaPlugin<"numbered-list", import("../types").ListElementProps, Record<string, unknown>>;
4
+ TodoList: import("@yoopta/editor").YooptaPlugin<"todo-list", import("../types").TodoListElementProps, Record<string, unknown>>;
5
+ };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK;;;;CAIjB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,25 +1,14 @@
1
- import { Modify, YooptaBaseElement, YooptaPluginBaseOptions, YooptaRenderHTMLAttributes } from '@yoopta/editor';
2
- export type ListOptions = {
3
- depth: number;
4
- skipDrag: boolean;
5
- skipSettings: boolean;
6
- } & YooptaPluginBaseOptions & YooptaRenderHTMLAttributes;
7
- export type TodoListItemOptions = {
1
+ import { SlateElement } from '@yoopta/editor';
2
+ export type BulletedListPluginKeys = 'bulleted-list';
3
+ export type NumberedListPluginKeys = 'numbered-list';
4
+ export type TodoListPluginKeys = 'todo-list';
5
+ export type ListElementProps = {
6
+ position: number;
7
+ };
8
+ export type NumberedListElement = SlateElement<'numbered-list', ListElementProps>;
9
+ export type BulletedListElement = SlateElement<'bulleted-list', ListElementProps>;
10
+ export type TodoListElement = SlateElement<'todo-list', TodoListElementProps>;
11
+ export type TodoListElementProps = {
8
12
  checked: boolean;
9
13
  };
10
- export type ListChildItemElement = YooptaBaseElement<'list-item'>;
11
- export type TodoListChildItemElement = Modify<YooptaBaseElement<'todo-list-item'>, {
12
- data: TodoListItemOptions;
13
- }>;
14
- export type TodoListElement = Modify<YooptaBaseElement<'todo-list'>, {
15
- children: TodoListChildItemElement[];
16
- data: ListOptions;
17
- }>;
18
- export type BulletedListElement = Modify<YooptaBaseElement<'bulleted-list'>, {
19
- children: ListChildItemElement[];
20
- data: ListOptions;
21
- }>;
22
- export type NumberedListElement = Modify<YooptaBaseElement<'numbered-list'>, {
23
- children: ListChildItemElement[];
24
- data: ListOptions;
25
- }>;
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACrD,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACrD,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAClF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;AAE9E,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/lists",
3
- "version": "2.0.1",
3
+ "version": "4.0.0-rc.1",
4
4
  "description": "> TODO: description",
5
5
  "author": "Darginec05 <devopsbanda@gmail.com>",
6
6
  "homepage": "https://github.com/Darginec05/Editor-Yoopta#readme",
@@ -14,11 +14,11 @@
14
14
  "dist/"
15
15
  ],
16
16
  "peerDependencies": {
17
- "@yoopta/editor": ">=1.9.18-rc",
17
+ "@yoopta/editor": ">=4.0.0-rc.0",
18
18
  "react": ">=17.0.2",
19
19
  "react-dom": ">=17.0.2",
20
- "slate": ">=0.72.3",
21
- "slate-react": ">=0.95.0"
20
+ "slate": ">=0.99.0",
21
+ "slate-react": ">=0.99.0"
22
22
  },
23
23
  "publishConfig": {
24
24
  "registry": "https://registry.yarnpkg.com"
@@ -28,9 +28,13 @@
28
28
  "url": "git+https://github.com/Darginec05/Editor-Yoopta.git"
29
29
  },
30
30
  "scripts": {
31
- "test": "node ./__tests__/yoopta-code.test.js"
31
+ "test": "node ./__tests__/yoopta-lists.test.js",
32
+ "start": "rollup --config rollup.config.js --watch --bundleConfigAsCjs --environment NODE_ENV:development",
33
+ "prepublishOnly": "yarn build",
34
+ "build": "rollup --config rollup.config.js --bundleConfigAsCjs --environment NODE_ENV:production"
32
35
  },
33
36
  "bugs": {
34
37
  "url": "https://github.com/Darginec05/Editor-Yoopta/issues"
35
- }
38
+ },
39
+ "gitHead": "c46f09afdb5f60f98f2065e24305a9d02ed57ca7"
36
40
  }
package/dist/Lists.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { NumberedList } from './ui/NumberedList';
2
- import { BulletedList } from './ui/BulletedList';
3
- import { TodoList } from './ui/TodoList';
4
- import { YooEditor } from '@yoopta/editor';
5
- import type { ListChildItemElement, TodoListChildItemElement, TodoListElement, BulletedListElement, NumberedListElement } from './types';
6
- declare module 'slate' {
7
- interface CustomTypes {
8
- Editor: YooEditor;
9
- Element: ListChildItemElement | TodoListChildItemElement | TodoListElement | BulletedListElement | NumberedListElement;
10
- }
11
- }
12
- declare const Lists: {
13
- NumberedList: import("@yoopta/editor").YooptaPlugin<import("@yoopta/editor").YooptaPluginBaseOptions, NumberedListElement>;
14
- BulletedList: import("@yoopta/editor").YooptaPlugin<import("@yoopta/editor").YooptaPluginBaseOptions, BulletedListElement>;
15
- TodoList: import("@yoopta/editor").YooptaPlugin<import("@yoopta/editor").YooptaPluginBaseOptions, TodoListElement>;
16
- };
17
- export default Lists;
18
- export { NumberedList, BulletedList, TodoList, TodoListElement, BulletedListElement, NumberedListElement };
@@ -1,4 +0,0 @@
1
- import { YooptaPluginBaseOptions } from '@yoopta/editor';
2
- import type { BulletedListElement } from '../types';
3
- declare const BulletedList: import("@yoopta/editor").YooptaPlugin<YooptaPluginBaseOptions, BulletedListElement>;
4
- export { BulletedList };
@@ -1,3 +0,0 @@
1
- import { ListChildItemElement } from '../types';
2
- declare const ListItemList: import("@yoopta/editor").YooptaPlugin<any, ListChildItemElement>;
3
- export { ListItemList };
@@ -1,4 +0,0 @@
1
- import { YooptaPluginBaseOptions } from '@yoopta/editor';
2
- import type { NumberedListElement } from '../types';
3
- declare const NumberedList: import("@yoopta/editor").YooptaPlugin<YooptaPluginBaseOptions, NumberedListElement>;
4
- export { NumberedList };
@@ -1,4 +0,0 @@
1
- import { YooptaPluginBaseOptions } from '@yoopta/editor';
2
- import { TodoListElement } from '../types';
3
- declare const TodoList: import("@yoopta/editor").YooptaPlugin<YooptaPluginBaseOptions, TodoListElement>;
4
- export { TodoList };
@@ -1,3 +0,0 @@
1
- import { TodoListChildItemElement, TodoListItemOptions } from '../types';
2
- declare const TodoListItem: import("@yoopta/editor").YooptaPlugin<TodoListItemOptions, TodoListChildItemElement>;
3
- export { TodoListItem };