@yoopta/code 1.9.0-rc → 1.9.1-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/dist/Code.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/types.d.ts +3 -3
- package/package.json +5 -5
package/dist/Code.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ declare module 'slate' {
|
|
|
6
6
|
Element: CodeElement | CodeChildElement;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
declare const CodeLine: import("@yoopta/editor").
|
|
10
|
-
declare const Code: import("@yoopta/editor").
|
|
9
|
+
declare const CodeLine: import("@yoopta/editor").YooptaPlugin<any, CodeChildElement>;
|
|
10
|
+
declare const Code: import("@yoopta/editor").YooptaPlugin<CodeOptions, CodeElement>;
|
|
11
11
|
export { Code, CodeLine, CodeElement, CodeChildElement };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Node as e,Element as t,Transforms as n,Editor as a,Range as r,Path as i}from"slate";import{cx as s,UI_HELPERS as o,
|
|
1
|
+
import{Node as e,Element as t,Transforms as n,Editor as a,Range as r,Path as i}from"slate";import{cx as s,UI_HELPERS as o,createYooptaPlugin as l,generateId as c,getElementByPath as u}from"@yoopta/editor";import{jsx as d,jsxs as p}from"react/jsx-runtime";import{useEffect as g,useState as b}from"react";import{ReactEditor as f}from"slate-react";const h=({leaf:e,attributes:t,children:n})=>e.token?d("span",Object.assign({},t,{className:`token ${e.token_type}`},{children:n})):null;var m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y={};!function(e){var t=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,a={},r={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(t){return t instanceof i?new i(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++n}),e.__id},clone:function e(t,n){var a,i;switch(n=n||{},r.util.type(t)){case"Object":if(i=r.util.objId(t),n[i])return n[i];for(var s in a={},n[i]=a,t)t.hasOwnProperty(s)&&(a[s]=e(t[s],n));return a;case"Array":return i=r.util.objId(t),n[i]?n[i]:(a=[],n[i]=a,t.forEach((function(t,r){a[r]=e(t,n)})),a);default:return t}},getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,"gi"),""),e.classList.add("language-"+n)},currentScript:function(){if("undefined"==typeof document)return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(a){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(a.stack)||[])[1];if(e){var t=document.getElementsByTagName("script");for(var n in t)if(t[n].src==e)return t[n]}return null}},isActive:function(e,t,n){for(var a="no-"+t;e;){var r=e.classList;if(r.contains(t))return!0;if(r.contains(a))return!1;e=e.parentElement}return!!n}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(e,t){var n=r.util.clone(r.languages[e]);for(var a in t)n[a]=t[a];return n},insertBefore:function(e,t,n,a){var i=(a=a||r.languages)[e],s={};for(var o in i)if(i.hasOwnProperty(o)){if(o==t)for(var l in n)n.hasOwnProperty(l)&&(s[l]=n[l]);n.hasOwnProperty(o)||(s[o]=i[o])}var c=a[e];return a[e]=s,r.languages.DFS(r.languages,(function(t,n){n===c&&t!=e&&(this[t]=s)})),s},DFS:function e(t,n,a,i){i=i||{};var s=r.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],a||o);var l=t[o],c=r.util.type(l);"Object"!==c||i[s(l)]?"Array"!==c||i[s(l)]||(i[s(l)]=!0,e(l,n,o,i)):(i[s(l)]=!0,e(l,n,null,i))}}},plugins:{},highlightAll:function(e,t){r.highlightAllUnder(document,e,t)},highlightAllUnder:function(e,t,n){var a={callback:n,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",a),a.elements=Array.prototype.slice.apply(a.container.querySelectorAll(a.selector)),r.hooks.run("before-all-elements-highlight",a);for(var i,s=0;i=a.elements[s++];)r.highlightElement(i,!0===t,a.callback)},highlightElement:function(t,n,a){var i=r.util.getLanguage(t),s=r.languages[i];r.util.setLanguage(t,i);var o=t.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&r.util.setLanguage(o,i);var l={element:t,language:i,grammar:s,code:t.textContent};function c(e){l.highlightedCode=e,r.hooks.run("before-insert",l),l.element.innerHTML=l.highlightedCode,r.hooks.run("after-highlight",l),r.hooks.run("complete",l),a&&a.call(l.element)}if(r.hooks.run("before-sanity-check",l),(o=l.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!l.code)return r.hooks.run("complete",l),void(a&&a.call(l.element));if(r.hooks.run("before-highlight",l),l.grammar)if(n&&e.Worker){var u=new Worker(r.filename);u.onmessage=function(e){c(e.data)},u.postMessage(JSON.stringify({language:l.language,code:l.code,immediateClose:!0}))}else c(r.highlight(l.code,l.grammar,l.language));else c(r.util.encode(l.code))},highlight:function(e,t,n){var a={code:e,grammar:t,language:n};if(r.hooks.run("before-tokenize",a),!a.grammar)throw new Error('The language "'+a.language+'" has no grammar.');return a.tokens=r.tokenize(a.code,a.grammar),r.hooks.run("after-tokenize",a),i.stringify(r.util.encode(a.tokens),a.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var a in n)t[a]=n[a];delete t.rest}var r=new l;return c(r,r.head,e),o(e,r,t,r.head,0),function(e){var t=[],n=e.head.next;for(;n!==e.tail;)t.push(n.value),n=n.next;return t}(r)},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var a,i=0;a=n[i++];)a(t)}},Token:i};function i(e,t,n,a){this.type=e,this.content=t,this.alias=n,this.length=0|(a||"").length}function s(e,t,n,a){e.lastIndex=t;var r=e.exec(n);if(r&&a&&r[1]){var i=r[1].length;r.index+=i,r[0]=r[0].slice(i)}return r}function o(e,t,n,a,l,d){for(var p in n)if(n.hasOwnProperty(p)&&n[p]){var g=n[p];g=Array.isArray(g)?g:[g];for(var b=0;b<g.length;++b){if(d&&d.cause==p+","+b)return;var f=g[b],h=f.inside,m=!!f.lookbehind,y=!!f.greedy,w=f.alias;if(y&&!f.pattern.global){var k=f.pattern.toString().match(/[imsuy]*$/)[0];f.pattern=RegExp(f.pattern.source,k+"g")}for(var E=f.pattern||f,v=a.next,x=l;v!==t.tail&&!(d&&x>=d.reach);x+=v.value.length,v=v.next){var A=v.value;if(t.length>e.length)return;if(!(A instanceof i)){var S,_=1;if(y){if(!(S=s(E,x,e,m))||S.index>=e.length)break;var F=S.index,T=S.index+S[0].length,N=x;for(N+=v.value.length;F>=N;)N+=(v=v.next).value.length;if(x=N-=v.value.length,v.value instanceof i)continue;for(var R=v;R!==t.tail&&(N<T||"string"==typeof R.value);R=R.next)_++,N+=R.value.length;_--,A=e.slice(x,N),S.index-=x}else if(!(S=s(E,0,A,m)))continue;F=S.index;var I=S[0],O=A.slice(0,F),$=A.slice(F+I.length),L=x+A.length;d&&L>d.reach&&(d.reach=L);var P=v.prev;if(O&&(P=c(t,P,O),x+=O.length),u(t,P,_),v=c(t,P,new i(p,h?r.tokenize(I,h):I,w,I)),$&&c(t,v,$),_>1){var C={cause:p+","+b,reach:L};o(e,t,n,v.prev,x,C),d&&C.reach>d.reach&&(d.reach=C.reach)}}}}}}function l(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function c(e,t,n){var a=t.next,r={value:n,prev:t,next:a};return t.next=r,a.prev=r,e.length++,r}function u(e,t,n){for(var a=t.next,r=0;r<n&&a!==e.tail;r++)a=a.next;t.next=a,a.prev=t,e.length-=r}if(e.Prism=r,i.stringify=function e(t,n){if("string"==typeof t)return t;if(Array.isArray(t)){var a="";return t.forEach((function(t){a+=e(t,n)})),a}var i={type:t.type,content:e(t.content,n),tag:"span",classes:["token",t.type],attributes:{},language:n},s=t.alias;s&&(Array.isArray(s)?Array.prototype.push.apply(i.classes,s):i.classes.push(s)),r.hooks.run("wrap",i);var o="";for(var l in i.attributes)o+=" "+l+'="'+(i.attributes[l]||"").replace(/"/g,""")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'"'+o+">"+i.content+"</"+i.tag+">"},!e.document)return e.addEventListener?(r.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),a=n.language,i=n.code,s=n.immediateClose;e.postMessage(r.highlight(i,r.languages[a],a)),s&&e.close()}),!1),r):r;var d=r.util.currentScript();function p(){r.manual||r.highlightAll()}if(d&&(r.filename=d.src,d.hasAttribute("data-manual")&&(r.manual=!0)),!r.manual){var g=document.readyState;"loading"===g||"interactive"===g&&d&&d.defer?document.addEventListener("DOMContentLoaded",p):window.requestAnimationFrame?window.requestAnimationFrame(p):window.setTimeout(p,16)}return r}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{});
|
|
2
2
|
/**
|
|
3
3
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
4
4
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Modify,
|
|
1
|
+
import { Modify, YooptaBaseElement } from '@yoopta/editor';
|
|
2
2
|
export type CodeOptions = {
|
|
3
3
|
language: string;
|
|
4
4
|
filename?: string;
|
|
5
5
|
};
|
|
6
|
-
export type CodeElement = Modify<
|
|
6
|
+
export type CodeElement = Modify<YooptaBaseElement<'code'>, {
|
|
7
7
|
data: CodeOptions;
|
|
8
8
|
children: CodeChildElement[];
|
|
9
9
|
}>;
|
|
10
|
-
export type CodeChildElement = Modify<
|
|
10
|
+
export type CodeChildElement = Modify<YooptaBaseElement<'code-line'>, {
|
|
11
11
|
data: {
|
|
12
12
|
skipSettings: boolean;
|
|
13
13
|
skipDrag: boolean;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoopta/code",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1-rc",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Darginec05 <devopsbanda@gmail.com>",
|
|
6
|
-
"homepage": "https://github.com/Darginec05/Editor-
|
|
6
|
+
"homepage": "https://github.com/Darginec05/Editor-Yoopta#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"private": false,
|
|
9
9
|
"type": "module",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/Darginec05/Editor-
|
|
28
|
+
"url": "git+https://github.com/Darginec05/Editor-Yoopta.git"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "node ./__tests__/yoopta-code.test.js"
|
|
32
32
|
},
|
|
33
33
|
"bugs": {
|
|
34
|
-
"url": "https://github.com/Darginec05/Editor-
|
|
34
|
+
"url": "https://github.com/Darginec05/Editor-Yoopta/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"prism-material-themes": "^1.0.4",
|
|
38
38
|
"prismjs": "^1.29.0"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|