@yoopta/lists 1.9.0-rc

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@yoopta/code`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const blockquote = require('@yoopta/code');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,18 @@
1
+ import { NumberedList } from './ui/NumberedList';
2
+ import { BulletedList } from './ui/BulletedList';
3
+ import { TodoList } from './ui/TodoList';
4
+ import { YoEditor } from '@yoopta/editor';
5
+ import type { ListChildItemElement, TodoListChildItemElement, TodoList as TodoListElement, BulletedList as BulletedListElement, NumberedList as NumberedListElement } from './types';
6
+ declare module 'slate' {
7
+ interface CustomTypes {
8
+ Editor: YoEditor;
9
+ Element: ListChildItemElement | TodoListChildItemElement | TodoListElement | BulletedListElement | NumberedListElement;
10
+ }
11
+ }
12
+ declare const Lists: {
13
+ NumberedList: import("@yoopta/editor").YoptaPlugin<import("./types").ListOptions, NumberedListElement>;
14
+ BulletedList: import("@yoopta/editor").YoptaPlugin<import("./types").ListOptions, BulletedListElement>;
15
+ TodoList: import("@yoopta/editor").YoptaPlugin<import("./types").ListOptions, TodoListElement>;
16
+ };
17
+ export default Lists;
18
+ export { NumberedList, BulletedList, TodoList };
@@ -0,0 +1,3 @@
1
+ import Lists, { BulletedList, NumberedList, TodoList } from './Lists';
2
+ export default Lists;
3
+ export { NumberedList, BulletedList, TodoList };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{createYoptaPlugin as i,generateId as n,getElementByPath as s,cx as r}from"@yoopta/editor";import{Editor as a,Element as l,Transforms as o,Path as d}from"slate";import{ReactEditor as c}from"slate-react";function p(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 h="mfUTTw6O";p(".mfUTTw6O{color:#292929;font-size:16px;letter-spacing:-.003em;line-height:24px;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:24px;min-width:28px;padding:0 6px 0 4px;word-break:break-word}");const m=({attributes:t,children:i})=>e("li",Object.assign({className:h,draggable:!1},t,{children:i}));m.displayName="ListItem";const g="list-item",u=i({type:g,renderer:e=>m,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 c=a.above(e,{at:e.selection.anchor,match:e=>l.isElement(e)&&e.type===g});if(!c)return;const{anchor:p}=e.selection,[h,m]=c,[f,v]=a.parent(e,m),y=a.string(e,m),x=a.isEnd(e,p,m),b=a.isStart(e,p,m),k=m.length-1,E=2===k,N=1===k;if(t.isShiftEnter(r))return r.preventDefault(),void e.insertText("\n");if(t.isEnter(r)){if(r.preventDefault(),""===y.trim()){o.unwrapNodes(e,{match:e=>!a.isEditor(e)&&l.isElement(e)&&e.type===f.type,split:!0});const t=k>1?{id:n(),type:g,children:[{text:""}]}:i;return void o.setNodes(e,t,{at:e.selection})}if(!x&&!b)return o.splitNodes(e),void o.setNodes(e,{id:n()});const t=Object.assign(Object.assign({},h),{id:n(),children:[{text:""}]});o.insertNodes(e,t)}else if(t.isBackspace(r)){const[,t]=a.first(e,v),n=0===d.compare(e.selection.anchor.path,t);b&&n&&(r.preventDefault(),o.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===f.type,split:!0}),o.setNodes(e,i,{at:e.selection}))}else{if(t.isTab(r)){if(r.preventDefault(),E)return;const t=Object.assign(Object.assign({},f),{id:n(),type:f.type,children:[u.getPlugin.defineElement()]});return o.wrapNodes(e,t,{at:m}),void o.setNodes(e,{data:{depth:k+1,skipDrag:!0}},{match:e=>l.isElement(e)&&e.type===f.type})}if(t.isShiftTab(r)){if(r.preventDefault(),N)return;return o.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===f.type,split:!0}),void o.setNodes(e,{data:{depth:k-1,skipDrag:!0}},{match:e=>l.isElement(e)&&e.type===f.type})}}}},exports:{markdown:{serialize:(e,t)=>`- ${t}`},html:{serialize:(e,t)=>(console.log("children",t),`<li>${t}</li>`),deserialize:{nodeName:"LI"}}}});var f="cN2XzHcO";p(".cN2XzHcO{margin:2px 0;padding-left:18px}");const v=({attributes:t,children:i})=>e("ol",Object.assign({draggable:!1},t,{className:f},{children:i})),y=i({type:"numbered-list",renderer:e=>v,childPlugin:u,shortcut:"1.",defineElement:()=>({id:n(),type:"numbered-list",children:[u.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),createElement:e=>{var t,i;const n=u.getPlugin.defineElement();o.unwrapNodes(e,{match:e=>{var t;return!a.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}),o.setNodes(e,n,{at:null===(t=e.selection)||void 0===t?void 0:t.anchor});const s=y.getPlugin.defineElement();o.wrapNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.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"}}}});var x="wVFRrWWa";p(".wVFRrWWa{margin:2px 0;padding-left:18px}");const b=({attributes:t,children:i,element:n})=>e("ul",Object.assign({draggable:!1},t,{className:x},{children:i})),k=i({type:"bulleted-list",renderer:e=>b,shortcut:"-",childPlugin:u,defineElement:()=>({id:n(),type:"bulleted-list",children:[u.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),createElement:e=>{var t,i;const n=u.getPlugin.defineElement();o.unwrapNodes(e,{match:e=>{var t;return!a.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}),o.setNodes(e,n,{at:null===(t=e.selection)||void 0===t?void 0:t.anchor});const s=k.getPlugin.defineElement();o.wrapNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.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"}}}});var E="Mzo1TbSt";p(".Mzo1TbSt{padding-left:18px}");var N="zLPFpe0C",w="cJeUAnzK",T="YT2kDg7r",z="GzvUWhTl",D="YiyH9UVU";p('.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 O="todo-list-item",j=i({type:O,renderer:i=>function({attributes:n,children:s,element:a}){const d=a.data.checked;return t("div",Object.assign({draggable:!1},n,{className:r(N,{[w]:d})},{children:[e("label",Object.assign({className:T,contentEditable:!1,style:{userSelect:"none"}},{children:e("input",{type:"checkbox",checked:d,className:z,onChange:e=>{const t=c.findPath(i,a);o.setNodes(i,{data:{checked:e.target.checked}},{at:t,match:e=>l.isElement(e)&&e.type===O})}})})),e("span",Object.assign({className:D},{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 c;if(!e.selection)return;if(s(e,e.selection.anchor.path,"lowest").type!==O)return;const p=a.above(e,{at:null===(c=e.selection)||void 0===c?void 0:c.anchor.path,match:e=>l.isElement(e)&&e.type===O});if(!p)return;const[h,m]=p,[g,u]=a.parent(e,m),f=a.string(e,m),v=a.isEnd(e,e.selection.anchor,m),y=a.isStart(e,e.selection.anchor,m),x=m.length-1,b=2===x,k=1===x;if(t.isShiftEnter(r))return r.preventDefault(),void e.insertText("\n");if(t.isEnter(r)){if(r.preventDefault(),""===f.trim()){o.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===g.type,split:!0});const t=x>1?{id:n(),type:O,children:[{text:""}],options:{checked:!1}}:i;return void o.setNodes(e,t,{at:e.selection})}if(!v&&!y)return o.splitNodes(e),void o.setNodes(e,{id:n(),data:{checked:!1}},{match:e=>l.isElement(e)&&e.type===O});const t=Object.assign(Object.assign({},h),{id:n(),children:[{text:""}],data:{checked:!1}});o.insertNodes(e,t,{select:!0})}else{if(t.isCmdEnter(r))return r.preventDefault(),void o.setNodes(e,{data:{checked:!h.data.checked}},{at:m,match:e=>l.isElement(e)&&e.type===O});if(t.isBackspace(r)){const[,t]=a.first(e,u),n=0===d.compare(e.selection.anchor.path,t);y&&n&&(r.preventDefault(),o.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===g.type,split:!0}),o.setNodes(e,i,{at:e.selection}))}else if(t.isTab(r)){if(r.preventDefault(),b)return;const t=Object.assign(Object.assign({},g),{id:n(),type:g.type,children:[j.getPlugin.defineElement()]});o.wrapNodes(e,t,{at:m})}else if(t.isShiftTab(r)){if(r.preventDefault(),k)return;o.unwrapNodes(e,{match:e=>l.isElement(e)&&e.type===g.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>`}}}),P=({attributes:t,children:i})=>e("div",Object.assign({draggable:!1},t,{className:E},{children:i})),$=i({type:"todo-list",renderer:e=>P,childPlugin:j,shortcut:"[]",defineElement:()=>({id:n(),type:"todo-list",children:[j.getPlugin.defineElement()],nodeType:"block",data:{depth:1,skipDrag:!0,skipSettings:!0}}),extendEditor:e=>e,createElement:e=>{var t,i;const n=j.getPlugin.defineElement();o.unwrapNodes(e,{match:e=>{var t;return!a.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}),o.setNodes(e,n,{at:null===(t=e.selection)||void 0===t?void 0:t.anchor});const s=$.getPlugin.defineElement();o.wrapNodes(e,s,{at:null===(i=e.selection)||void 0===i?void 0:i.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>`}}}}),S={NumberedList:y,BulletedList:k,TodoList:$};export{k as BulletedList,y as NumberedList,$ as TodoList,S as default};
@@ -0,0 +1,25 @@
1
+ import { Modify, YoptaBaseElement } from '@yoopta/editor';
2
+ export type ListOptions = {
3
+ depth: number;
4
+ skipDrag: boolean;
5
+ skipSettings: boolean;
6
+ };
7
+ export type TodoListItemOptions = {
8
+ checked: boolean;
9
+ };
10
+ export type ListChildItemElement = YoptaBaseElement<'list-item'>;
11
+ export type TodoListChildItemElement = Modify<YoptaBaseElement<'todo-list-item'>, {
12
+ data: TodoListItemOptions;
13
+ }>;
14
+ export type TodoList = Modify<YoptaBaseElement<'todo-list'>, {
15
+ children: TodoListChildItemElement[];
16
+ data: ListOptions;
17
+ }>;
18
+ export type BulletedList = Modify<YoptaBaseElement<'bulleted-list'>, {
19
+ children: ListChildItemElement[];
20
+ data: ListOptions;
21
+ }>;
22
+ export type NumberedList = Modify<YoptaBaseElement<'numbered-list'>, {
23
+ children: ListChildItemElement[];
24
+ data: ListOptions;
25
+ }>;
@@ -0,0 +1,4 @@
1
+ import { YoptaPlugin } from '@yoopta/editor';
2
+ import type { BulletedList, ListOptions } from '../types';
3
+ declare const BulletedList: YoptaPlugin<ListOptions, BulletedList>;
4
+ export { BulletedList };
@@ -0,0 +1,3 @@
1
+ import { ListChildItemElement } from '../types';
2
+ declare const ListItemList: import("@yoopta/editor").YoptaPlugin<any, ListChildItemElement>;
3
+ export { ListItemList };
@@ -0,0 +1,3 @@
1
+ import type { ListOptions, NumberedList } from '../types';
2
+ declare const NumberedList: import("@yoopta/editor").YoptaPlugin<ListOptions, NumberedList>;
3
+ export { NumberedList };
@@ -0,0 +1,3 @@
1
+ import { ListOptions, TodoList } from '../types';
2
+ declare const TodoList: import("@yoopta/editor").YoptaPlugin<ListOptions, TodoList>;
3
+ export { TodoList };
@@ -0,0 +1,3 @@
1
+ import { TodoListChildItemElement, TodoListItemOptions } from '../types';
2
+ declare const TodoListItem: import("@yoopta/editor").YoptaPlugin<TodoListItemOptions, TodoListChildItemElement>;
3
+ export { TodoListItem };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@yoopta/lists",
3
+ "version": "1.9.0-rc",
4
+ "description": "> TODO: description",
5
+ "author": "Darginec05 <devopsbanda@gmail.com>",
6
+ "homepage": "https://github.com/Darginec05/Editor-Yopta#readme",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "type": "module",
10
+ "main": "dist/index.js",
11
+ "module": "dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist/"
15
+ ],
16
+ "peerDependencies": {
17
+ "@yoopta/editor": "1.9.0-rc",
18
+ "react": ">=17.0.2",
19
+ "react-dom": ">=17.0.2",
20
+ "slate": ">=0.72.3",
21
+ "slate-react": ">=0.72.4"
22
+ },
23
+ "publishConfig": {
24
+ "registry": "https://registry.yarnpkg.com"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/Darginec05/Editor-Yopta.git"
29
+ },
30
+ "scripts": {
31
+ "test": "node ./__tests__/yoopta-code.test.js"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/Darginec05/Editor-Yopta/issues"
35
+ }
36
+ }