@react-fabric/lexical 1.0.0-beta.0
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 +21 -0
- package/README.md +10 -0
- package/dist/cjs/_virtual/prism.js +5 -0
- package/dist/cjs/editor/Lexical.module.css +1 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +432 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +21 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +27 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +1139 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +25 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +50 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +245 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +19 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +18 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +471 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +17 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +24 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +1275 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +29 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +29 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +789 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +29 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +26 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +976 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +35 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +35 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2792 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +23 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +55 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +888 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +35 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +66 -0
- package/dist/cjs/node_modules/@mdi/js/mdi.js +8 -0
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +82 -0
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +33 -0
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +101 -0
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +66 -0
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +126 -0
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +174 -0
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +417 -0
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +188 -0
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +14 -0
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +60 -0
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +67 -0
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +130 -0
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +34 -0
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +150 -0
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +62 -0
- package/dist/cjs/node_modules/prismjs/prism.js +1951 -0
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +221 -0
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +156 -0
- package/dist/cjs/packages/lexical/src/editor/theme.js +97 -0
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +451 -0
- package/dist/cjs/packages/lexical/src/index.js +7 -0
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +218 -0
- package/dist/cjs/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +20 -0
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
- package/dist/cjs/packages/lexical/src/utils/index.js +214 -0
- package/dist/esm/_virtual/prism.js +5 -0
- package/dist/esm/editor/Lexical.module.css +1 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +423 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +19 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +18 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +1121 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +21 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +32 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +244 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +18 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +17 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +463 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +17 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +1262 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +23 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +781 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +23 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +18 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +957 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +26 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2754 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +20 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +17 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +839 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +26 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +17 -0
- package/dist/esm/node_modules/@mdi/js/mdi.js +7 -0
- package/dist/esm/node_modules/prismjs/components/prism-c.js +82 -0
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +33 -0
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +101 -0
- package/dist/esm/node_modules/prismjs/components/prism-css.js +66 -0
- package/dist/esm/node_modules/prismjs/components/prism-java.js +126 -0
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +174 -0
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +417 -0
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +188 -0
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +14 -0
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +60 -0
- package/dist/esm/node_modules/prismjs/components/prism-python.js +67 -0
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +130 -0
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +34 -0
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +150 -0
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +62 -0
- package/dist/esm/node_modules/prismjs/prism.js +1951 -0
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +221 -0
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +156 -0
- package/dist/esm/packages/lexical/src/editor/theme.js +97 -0
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +450 -0
- package/dist/esm/packages/lexical/src/index.js +3 -0
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +216 -0
- package/dist/esm/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +20 -0
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
- package/dist/esm/packages/lexical/src/utils/index.js +211 -0
- package/dist/types/components/StickyComponent.d.ts +9 -0
- package/dist/types/editor/LexicalEditor.d.ts +13 -0
- package/dist/types/editor/theme.d.ts +70 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +40 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/nodes/StickyNode.d.ts +35 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -0
- package/dist/types/plugins/StickyPlugin.d.ts +1 -0
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -0
- package/dist/types/utils/index.d.ts +57 -0
- package/package.json +55 -0
- package/src/components/StickyComponent.tsx +271 -0
- package/src/editor/Lexical.module.css +218 -0
- package/src/editor/LexicalEditor.tsx +222 -0
- package/src/editor/theme.ts +93 -0
- package/src/hooks/useFormatWatcher.ts +504 -0
- package/src/index.ts +24 -0
- package/src/nodes/StickyNode.tsx +249 -0
- package/src/plugins/DraggableBlockPlugin.tsx +418 -0
- package/src/plugins/StickyPlugin.ts +38 -0
- package/src/plugins/ToolbarPlugin.tsx +279 -0
- package/src/utils/index.ts +303 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as LexicalUtils_dev from './LexicalUtils.dev.js';
|
|
4
|
+
import * as LexicalUtils_prod from './LexicalUtils.prod.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const mod = process.env.NODE_ENV === 'development' ? LexicalUtils_dev : LexicalUtils_prod;
|
|
15
|
+
const $findMatchingParent = mod.$findMatchingParent;
|
|
16
|
+
const $getNearestBlockElementAncestorOrThrow = mod.$getNearestBlockElementAncestorOrThrow;
|
|
17
|
+
const $getNearestNodeOfType = mod.$getNearestNodeOfType;
|
|
18
|
+
const addClassNamesToElement = mod.addClassNamesToElement;
|
|
19
|
+
const isBlockDomNode = mod.isBlockDomNode;
|
|
20
|
+
const isHTMLAnchorElement = mod.isHTMLAnchorElement;
|
|
21
|
+
const isHTMLElement = mod.isHTMLElement;
|
|
22
|
+
const mergeRegister = mod.mergeRegister;
|
|
23
|
+
const objectKlassEquals = mod.objectKlassEquals;
|
|
24
|
+
const removeClassNamesFromElement = mod.removeClassNamesFromElement;
|
|
25
|
+
|
|
26
|
+
export { $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, addClassNamesToElement, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, mergeRegister, objectKlassEquals, removeClassNamesFromElement };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { $getRoot, $isElementNode, $cloneWithProperties, $setSelection, $getSelection, $getPreviousSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, $splitNode, $createParagraphNode, TextNode } from 'lexical';
|
|
4
|
+
export { $splitNode, isBlockDomNode, isHTMLAnchorElement, isHTMLElement, isInlineDomNode } from 'lexical';
|
|
5
|
+
import { createRectsFromDOMRange } from '../selection/LexicalSelection.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=g((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const h="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,m=h&&"documentMode"in document?document.documentMode:null,v=h&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),y=h&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),w=!(!h||!("InputEvent"in window)||m)&&"getTargetRanges"in new window.InputEvent("input"),E=h&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),P=h&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,S=h&&/Android/.test(navigator.userAgent),x=h&&/^(?=.*Chrome).*/i.test(navigator.userAgent),N=h&&S&&x,A=h&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!x;function L(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function b(...e){return ()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0;}}function T(e){return `${e}px`}const M={attributes:!0,characterData:!0,childList:!0,subtree:!0};function C(e,t,n){let o=null,r=null,l=null,i=[];const s=document.createElement("div");function u(){null===o&&p(182),null===r&&p(183);const{left:l,top:u}=o.getBoundingClientRect(),c=r,f=createRectsFromDOMRange(e,t);s.isConnected||c.append(s);let a=!1;for(let e=0;e<f.length;e++){const t=f[e],n=i[e]||document.createElement("div"),o=n.style;"absolute"!==o.position&&(o.position="absolute",a=!0);const r=T(t.left-l);o.left!==r&&(o.left=r,a=!0);const c=T(t.top-u);o.top!==c&&(n.style.top=c,a=!0);const d=T(t.width);o.width!==d&&(n.style.width=d,a=!0);const g=T(t.height);o.height!==g&&(n.style.height=g,a=!0),n.parentNode!==s&&(s.append(n),a=!0),i[e]=n;}for(;i.length>f.length;)i.pop();a&&n(i);}function c(){r=null,o=null,null!==l&&l.disconnect(),l=null,s.remove();for(const e of i)e.remove();i=[];}const f=e.registerRootListener((function t(){const n=e.getRootElement();if(null===n)return c();const i=n.parentElement;if(!(i instanceof HTMLElement))return c();c(),o=n,r=i,l=new MutationObserver((n=>{const l=e.getRootElement(),i=l&&l.parentElement;if(l!==o||i!==r)return t();for(const e of n)if(!s.contains(e.target))return u()})),l.observe(i,M),u();}));return ()=>{f(),c();}}function B(o,r){let l=null,i=null,s=null,u=null,c=()=>{};function f(f){f.read((()=>{const f=$getSelection();if(!$isRangeSelection(f))return l=null,i=null,s=null,u=null,c(),void(c=()=>{});const{anchor:a,focus:d}=f,g=a.getNode(),h=g.getKey(),m=a.offset,v=d.getNode(),y=v.getKey(),w=d.offset,E=o.getElementByKey(h),P=o.getElementByKey(y),S=null===l||null===E||m!==i||h!==l.getKey()||g!==l&&(!(l instanceof TextNode)||g.updateDOM(l,E,o._config)),x=null===s||null===P||w!==u||y!==s.getKey()||v!==s&&(!(s instanceof TextNode)||v.updateDOM(s,P,o._config));if(S||x){const e=o.getElementByKey(a.getNode().getKey()),t=o.getElementByKey(d.getNode().getKey());if(null!==e&&null!==t&&"SPAN"===e.tagName&&"SPAN"===t.tagName){const n=document.createRange();let l,i,s,u;d.isBefore(a)?(l=t,i=d.offset,s=e,u=a.offset):(l=e,i=a.offset,s=t,u=d.offset);const f=l.firstChild;null===f&&p(181);const g=s.firstChild;null===g&&p(181),n.setStart(f,i),n.setEnd(g,u),c(),c=C(o,n,(e=>{for(const t of e){const e=t.style;"Highlight"!==e.background&&(e.background="Highlight"),"HighlightText"!==e.color&&(e.color="HighlightText"),"-1"!==e.zIndex&&(e.zIndex="-1"),"none"!==e.pointerEvents&&(e.pointerEvents="none"),e.marginTop!==T(-1.5)&&(e.marginTop=T(-1.5)),e.paddingTop!==T(4)&&(e.paddingTop=T(4)),e.paddingBottom!==T(0)&&(e.paddingBottom=T(0));}void 0!==r&&r(e);}));}}l=g,i=m,s=v,u=w;}));}return f(o.getEditorState()),b(o.registerUpdateListener((({editorState:e})=>f(e))),c,(()=>{c();}))}const _=w,K=h,O=S,R=N,I=v,D=A,H=x,z=y,k=P,F=E;function $(e,...t){const n=L(...t);n.length>0&&e.classList.add(...n);}function U(e,...t){const n=L(...t);n.length>0&&e.classList.remove(...n);}function W(e,t){for(const n of t)if(e.type.startsWith(n))return !0;return !1}function j(e,t){const n=e[Symbol.iterator]();return new Promise(((e,o)=>{const r=[],l=()=>{const{done:i,value:s}=n.next();if(i)return e(r);const u=new FileReader;u.addEventListener("error",o),u.addEventListener("load",(()=>{const e=u.result;"string"==typeof e&&r.push({file:s,result:e}),l();})),W(s,t)?u.readAsDataURL(s):l();};l();}))}function V(e,t){const n=[],l=(e||$getRoot()).getLatest(),i=t||$isElementNode(l)&&l.getLastDescendant()||l;let s=l,u=function(e){let t=e,n=0;for(;null!==(t=t.getParent());)n++;return n}(s);for(;null!==s&&!s.is(i);)if(n.push({depth:u,node:s}),$isElementNode(s)&&s.getChildrenSize()>0)s=s.getFirstChild(),u++;else {let e=null;for(;null===e&&null!==s;)e=s.getNextSibling(),null===e?(s=s.getParent(),u--):s=e;}return null!==s&&s.is(i)&&n.push({depth:u,node:s}),n}function q(e){let t=e;if($isElementNode(t)&&t.getChildrenSize()>0)t=t.getLastChild();else {let e=null;for(;null===e&&null!==t;)e=t.getPreviousSibling(),t=null===e?t.getParent():e;}return t}function G(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent();}return null}function J(e){const t=Q(e,(e=>$isElementNode(e)&&!e.isInline()));return $isElementNode(t)||p(4,e.__key),t}const Q=(e,t)=>{let n=e;for(;n!==$getRoot()&&null!=n;){if(t(n))return n;n=n.getParent();}return null};function X(e,t,n,o){const r=e=>e instanceof t;return e.registerNodeTransform(t,(e=>{const t=(e=>{const t=e.getChildren();for(let e=0;e<t.length;e++){const n=t[e];if(r(n))return null}let n=e,o=e;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return {child:o,parent:n};return null})(e);if(null!==t){const{child:r,parent:l}=t;if(r.is(e)){o(l,e);const t=r.getNextSiblings(),i=t.length;if(l.insertAfter(r),0!==i){const e=n(l);r.insertAfter(e);for(let n=0;n<i;n++)e.append(t[n]);}l.canBeEmpty()||0!==l.getChildrenSize()||l.remove();}}}))}function Y(e,t){const n=new Map,o=e._pendingEditorState;for(const[e,o]of t._nodeMap)n.set(e,$cloneWithProperties(o));o&&(o._nodeMap=n),e._dirtyType=2;const r=t._selection;$setSelection(null===r?null:r.clone());}function Z(n){const r=$getSelection()||$getPreviousSelection();if($isRangeSelection(r)){const{focus:e}=r,t=e.getNode(),o=e.offset;if($isRootOrShadowRoot(t)){const e=t.getChildAtIndex(o);null==e?t.append(n):e.insertBefore(n),n.selectNext();}else {let e,r;$isTextNode(t)?(e=t.getParentOrThrow(),r=t.getIndexWithinParent(),o>0&&(r+=1,t.splitText(o))):(e=t,r=o);const[,l]=$splitNode(e,r);l.insertBefore(n),l.selectStart();}}else {if(null!=r){const e=r.getNodes();e[e.length-1].getTopLevelElementOrThrow().insertAfter(n);}else {$getRoot().append(n);}const e=$createParagraphNode();n.insertAfter(e),e.select();}return n.getLatest()}function ee(e,t){const n=t();return e.replace(n),n.append(e),n}function te(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function ne(e,t){const n=[];for(let o=0;o<e.length;o++){const r=t(e[o]);null!==r&&n.push(r);}return n}function oe(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t);}function re(e){if(z)return 1;let t=1;for(;e;)t*=Number(window.getComputedStyle(e).getPropertyValue("zoom")),e=e.parentElement;return t}function le(e){return null!==e._parentEditor}
|
|
16
|
+
|
|
17
|
+
export { V as $dfs, ne as $filter, Q as $findMatchingParent, J as $getNearestBlockElementAncestorOrThrow, G as $getNearestNodeOfType, q as $getNextRightPreorderNode, oe as $insertFirst, Z as $insertNodeToNearestRoot, le as $isEditorIsNestedEditor, Y as $restoreEditorState, ee as $wrapNodeInElement, _ as CAN_USE_BEFORE_INPUT, K as CAN_USE_DOM, O as IS_ANDROID, R as IS_ANDROID_CHROME, I as IS_APPLE, D as IS_APPLE_WEBKIT, H as IS_CHROME, z as IS_FIREFOX, k as IS_IOS, F as IS_SAFARI, $ as addClassNamesToElement, re as calculateZoomLevel, W as isMimeType, B as markSelection, j as mediaFileReader, b as mergeRegister, te as objectKlassEquals, C as positionNodeOnRange, X as registerNestedElementResolver, U as removeClassNamesFromElement };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// Material Design Icons v7.4.47
|
|
4
|
+
var mdiClose = "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";
|
|
5
|
+
var mdiFormatColorFill = "M19,11.5C19,11.5 17,13.67 17,15A2,2 0 0,0 19,17A2,2 0 0,0 21,15C21,13.67 19,11.5 19,11.5M5.21,10L10,5.21L14.79,10M16.56,8.94L7.62,0L6.21,1.41L8.59,3.79L3.44,8.94C2.85,9.5 2.85,10.47 3.44,11.06L8.94,16.56C9.23,16.85 9.62,17 10,17C10.38,17 10.77,16.85 11.06,16.56L16.56,11.06C17.15,10.47 17.15,9.5 16.56,8.94Z";
|
|
6
|
+
|
|
7
|
+
export { mdiClose, mdiFormatColorFill };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
Prism.languages.c = Prism.languages.extend('clike', {
|
|
4
|
+
'comment': {
|
|
5
|
+
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
6
|
+
greedy: true
|
|
7
|
+
},
|
|
8
|
+
'string': {
|
|
9
|
+
// https://en.cppreference.com/w/c/language/string_literal
|
|
10
|
+
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
11
|
+
greedy: true
|
|
12
|
+
},
|
|
13
|
+
'class-name': {
|
|
14
|
+
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
15
|
+
lookbehind: true
|
|
16
|
+
},
|
|
17
|
+
'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
18
|
+
'function': /\b[a-z_]\w*(?=\s*\()/i,
|
|
19
|
+
'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
20
|
+
'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
Prism.languages.insertBefore('c', 'string', {
|
|
24
|
+
'char': {
|
|
25
|
+
// https://en.cppreference.com/w/c/language/character_constant
|
|
26
|
+
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
27
|
+
greedy: true
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
Prism.languages.insertBefore('c', 'string', {
|
|
32
|
+
'macro': {
|
|
33
|
+
// allow for multiline macro definitions
|
|
34
|
+
// spaces after the # character compile fine with gcc
|
|
35
|
+
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
36
|
+
lookbehind: true,
|
|
37
|
+
greedy: true,
|
|
38
|
+
alias: 'property',
|
|
39
|
+
inside: {
|
|
40
|
+
'string': [
|
|
41
|
+
{
|
|
42
|
+
// highlight the path of the include statement as a string
|
|
43
|
+
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
44
|
+
lookbehind: true
|
|
45
|
+
},
|
|
46
|
+
Prism.languages.c['string']
|
|
47
|
+
],
|
|
48
|
+
'char': Prism.languages.c['char'],
|
|
49
|
+
'comment': Prism.languages.c['comment'],
|
|
50
|
+
'macro-name': [
|
|
51
|
+
{
|
|
52
|
+
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
53
|
+
lookbehind: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
57
|
+
lookbehind: true,
|
|
58
|
+
alias: 'function'
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
// highlight macro directives as keywords
|
|
62
|
+
'directive': {
|
|
63
|
+
pattern: /^(#\s*)[a-z]+/,
|
|
64
|
+
lookbehind: true,
|
|
65
|
+
alias: 'keyword'
|
|
66
|
+
},
|
|
67
|
+
'directive-hash': /^#/,
|
|
68
|
+
'punctuation': /##|\\(?=[\r\n])/,
|
|
69
|
+
'expression': {
|
|
70
|
+
pattern: /\S[\s\S]*/,
|
|
71
|
+
inside: Prism.languages.c
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
Prism.languages.insertBefore('c', 'function', {
|
|
78
|
+
// highlight predefined macros as constants
|
|
79
|
+
'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
delete Prism.languages.c['boolean'];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
Prism.languages.clike = {
|
|
4
|
+
'comment': [
|
|
5
|
+
{
|
|
6
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
7
|
+
lookbehind: true,
|
|
8
|
+
greedy: true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
12
|
+
lookbehind: true,
|
|
13
|
+
greedy: true
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
'string': {
|
|
17
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
18
|
+
greedy: true
|
|
19
|
+
},
|
|
20
|
+
'class-name': {
|
|
21
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
22
|
+
lookbehind: true,
|
|
23
|
+
inside: {
|
|
24
|
+
'punctuation': /[.\\]/
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
28
|
+
'boolean': /\b(?:false|true)\b/,
|
|
29
|
+
'function': /\b\w+(?=\()/,
|
|
30
|
+
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
31
|
+
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
32
|
+
'punctuation': /[{}[\];(),.:]/
|
|
33
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
(function (Prism) {
|
|
4
|
+
|
|
5
|
+
var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
|
|
6
|
+
var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
|
|
7
|
+
|
|
8
|
+
Prism.languages.cpp = Prism.languages.extend('c', {
|
|
9
|
+
'class-name': [
|
|
10
|
+
{
|
|
11
|
+
pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
|
|
12
|
+
.replace(/<keyword>/g, function () { return keyword.source; })),
|
|
13
|
+
lookbehind: true
|
|
14
|
+
},
|
|
15
|
+
// This is intended to capture the class name of method implementations like:
|
|
16
|
+
// void foo::bar() const {}
|
|
17
|
+
// However! The `foo` in the above example could also be a namespace, so we only capture the class name if
|
|
18
|
+
// it starts with an uppercase letter. This approximation should give decent results.
|
|
19
|
+
/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
|
|
20
|
+
// This will capture the class name before destructors like:
|
|
21
|
+
// Foo::~Foo() {}
|
|
22
|
+
/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
|
|
23
|
+
// This also intends to capture the class name of method implementations but here the class has template
|
|
24
|
+
// parameters, so it can't be a namespace (until C++ adds generic namespaces).
|
|
25
|
+
/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
|
|
26
|
+
],
|
|
27
|
+
'keyword': keyword,
|
|
28
|
+
'number': {
|
|
29
|
+
pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
|
|
30
|
+
greedy: true
|
|
31
|
+
},
|
|
32
|
+
'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
|
33
|
+
'boolean': /\b(?:false|true)\b/
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
Prism.languages.insertBefore('cpp', 'string', {
|
|
37
|
+
'module': {
|
|
38
|
+
// https://en.cppreference.com/w/cpp/language/modules
|
|
39
|
+
pattern: RegExp(
|
|
40
|
+
/(\b(?:import|module)\s+)/.source +
|
|
41
|
+
'(?:' +
|
|
42
|
+
// header-name
|
|
43
|
+
/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source +
|
|
44
|
+
'|' +
|
|
45
|
+
// module name or partition or both
|
|
46
|
+
/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) +
|
|
47
|
+
')'
|
|
48
|
+
),
|
|
49
|
+
lookbehind: true,
|
|
50
|
+
greedy: true,
|
|
51
|
+
inside: {
|
|
52
|
+
'string': /^[<"][\s\S]+/,
|
|
53
|
+
'operator': /:/,
|
|
54
|
+
'punctuation': /\./
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
'raw-string': {
|
|
58
|
+
pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
|
59
|
+
alias: 'string',
|
|
60
|
+
greedy: true
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
Prism.languages.insertBefore('cpp', 'keyword', {
|
|
65
|
+
'generic-function': {
|
|
66
|
+
pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
|
|
67
|
+
inside: {
|
|
68
|
+
'function': /^\w+/,
|
|
69
|
+
'generic': {
|
|
70
|
+
pattern: /<[\s\S]+/,
|
|
71
|
+
alias: 'class-name',
|
|
72
|
+
inside: Prism.languages.cpp
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
Prism.languages.insertBefore('cpp', 'operator', {
|
|
79
|
+
'double-colon': {
|
|
80
|
+
pattern: /::/,
|
|
81
|
+
alias: 'punctuation'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
Prism.languages.insertBefore('cpp', 'class-name', {
|
|
86
|
+
// the base clause is an optional list of parent classes
|
|
87
|
+
// https://en.cppreference.com/w/cpp/language/class
|
|
88
|
+
'base-clause': {
|
|
89
|
+
pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
|
|
90
|
+
lookbehind: true,
|
|
91
|
+
greedy: true,
|
|
92
|
+
inside: Prism.languages.extend('cpp', {})
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
Prism.languages.insertBefore('inside', 'double-colon', {
|
|
97
|
+
// All untokenized words that are not namespaces should be class names
|
|
98
|
+
'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
|
|
99
|
+
}, Prism.languages.cpp['base-clause']);
|
|
100
|
+
|
|
101
|
+
}(Prism));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
(function (Prism) {
|
|
4
|
+
|
|
5
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
6
|
+
|
|
7
|
+
Prism.languages.css = {
|
|
8
|
+
'comment': /\/\*[\s\S]*?\*\//,
|
|
9
|
+
'atrule': {
|
|
10
|
+
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
11
|
+
inside: {
|
|
12
|
+
'rule': /^@[\w-]+/,
|
|
13
|
+
'selector-function-argument': {
|
|
14
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
15
|
+
lookbehind: true,
|
|
16
|
+
alias: 'selector'
|
|
17
|
+
},
|
|
18
|
+
'keyword': {
|
|
19
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
20
|
+
lookbehind: true
|
|
21
|
+
}
|
|
22
|
+
// See rest below
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
'url': {
|
|
26
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
27
|
+
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
28
|
+
greedy: true,
|
|
29
|
+
inside: {
|
|
30
|
+
'function': /^url/i,
|
|
31
|
+
'punctuation': /^\(|\)$/,
|
|
32
|
+
'string': {
|
|
33
|
+
pattern: RegExp('^' + string.source + '$'),
|
|
34
|
+
alias: 'url'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
'selector': {
|
|
39
|
+
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
40
|
+
lookbehind: true
|
|
41
|
+
},
|
|
42
|
+
'string': {
|
|
43
|
+
pattern: string,
|
|
44
|
+
greedy: true
|
|
45
|
+
},
|
|
46
|
+
'property': {
|
|
47
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
48
|
+
lookbehind: true
|
|
49
|
+
},
|
|
50
|
+
'important': /!important\b/i,
|
|
51
|
+
'function': {
|
|
52
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
53
|
+
lookbehind: true
|
|
54
|
+
},
|
|
55
|
+
'punctuation': /[(){};:,]/
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
59
|
+
|
|
60
|
+
var markup = Prism.languages.markup;
|
|
61
|
+
if (markup) {
|
|
62
|
+
markup.tag.addInlined('style', 'css');
|
|
63
|
+
markup.tag.addAttribute('style', 'css');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}(Prism));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
(function (Prism) {
|
|
4
|
+
|
|
5
|
+
var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
|
|
6
|
+
|
|
7
|
+
// full package (optional) + parent classes (optional)
|
|
8
|
+
var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
|
|
9
|
+
|
|
10
|
+
// based on the java naming conventions
|
|
11
|
+
var className = {
|
|
12
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
13
|
+
lookbehind: true,
|
|
14
|
+
inside: {
|
|
15
|
+
'namespace': {
|
|
16
|
+
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
17
|
+
inside: {
|
|
18
|
+
'punctuation': /\./
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
'punctuation': /\./
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
Prism.languages.java = Prism.languages.extend('clike', {
|
|
26
|
+
'string': {
|
|
27
|
+
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
28
|
+
lookbehind: true,
|
|
29
|
+
greedy: true
|
|
30
|
+
},
|
|
31
|
+
'class-name': [
|
|
32
|
+
className,
|
|
33
|
+
{
|
|
34
|
+
// variables, parameters, and constructor references
|
|
35
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
36
|
+
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
37
|
+
lookbehind: true,
|
|
38
|
+
inside: className.inside
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
// class names based on keyword
|
|
42
|
+
// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
|
|
43
|
+
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
|
|
44
|
+
lookbehind: true,
|
|
45
|
+
inside: className.inside
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
'keyword': keywords,
|
|
49
|
+
'function': [
|
|
50
|
+
Prism.languages.clike.function,
|
|
51
|
+
{
|
|
52
|
+
pattern: /(::\s*)[a-z_]\w*/,
|
|
53
|
+
lookbehind: true
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
57
|
+
'operator': {
|
|
58
|
+
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
59
|
+
lookbehind: true
|
|
60
|
+
},
|
|
61
|
+
'constant': /\b[A-Z][A-Z_\d]+\b/
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
Prism.languages.insertBefore('java', 'string', {
|
|
65
|
+
'triple-quoted-string': {
|
|
66
|
+
// http://openjdk.java.net/jeps/355#Description
|
|
67
|
+
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
68
|
+
greedy: true,
|
|
69
|
+
alias: 'string'
|
|
70
|
+
},
|
|
71
|
+
'char': {
|
|
72
|
+
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
73
|
+
greedy: true
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
Prism.languages.insertBefore('java', 'class-name', {
|
|
78
|
+
'annotation': {
|
|
79
|
+
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
80
|
+
lookbehind: true,
|
|
81
|
+
alias: 'punctuation'
|
|
82
|
+
},
|
|
83
|
+
'generics': {
|
|
84
|
+
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
85
|
+
inside: {
|
|
86
|
+
'class-name': className,
|
|
87
|
+
'keyword': keywords,
|
|
88
|
+
'punctuation': /[<>(),.:]/,
|
|
89
|
+
'operator': /[?&|]/
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
'import': [
|
|
93
|
+
{
|
|
94
|
+
pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
95
|
+
lookbehind: true,
|
|
96
|
+
inside: {
|
|
97
|
+
'namespace': className.inside.namespace,
|
|
98
|
+
'punctuation': /\./,
|
|
99
|
+
'operator': /\*/,
|
|
100
|
+
'class-name': /\w+/
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
|
|
105
|
+
lookbehind: true,
|
|
106
|
+
alias: 'static',
|
|
107
|
+
inside: {
|
|
108
|
+
'namespace': className.inside.namespace,
|
|
109
|
+
'static': /\b\w+$/,
|
|
110
|
+
'punctuation': /\./,
|
|
111
|
+
'operator': /\*/,
|
|
112
|
+
'class-name': /\w+/
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
'namespace': {
|
|
117
|
+
pattern: RegExp(
|
|
118
|
+
/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
|
|
119
|
+
.source.replace(/<keyword>/g, function () { return keywords.source; })),
|
|
120
|
+
lookbehind: true,
|
|
121
|
+
inside: {
|
|
122
|
+
'punctuation': /\./,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}(Prism));
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
Prism.languages.javascript = Prism.languages.extend('clike', {
|
|
4
|
+
'class-name': [
|
|
5
|
+
Prism.languages.clike['class-name'],
|
|
6
|
+
{
|
|
7
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
8
|
+
lookbehind: true
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
'keyword': [
|
|
12
|
+
{
|
|
13
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
14
|
+
lookbehind: true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
18
|
+
lookbehind: true
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
22
|
+
'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
23
|
+
'number': {
|
|
24
|
+
pattern: RegExp(
|
|
25
|
+
/(^|[^\w$])/.source +
|
|
26
|
+
'(?:' +
|
|
27
|
+
(
|
|
28
|
+
// constant
|
|
29
|
+
/NaN|Infinity/.source +
|
|
30
|
+
'|' +
|
|
31
|
+
// binary integer
|
|
32
|
+
/0[bB][01]+(?:_[01]+)*n?/.source +
|
|
33
|
+
'|' +
|
|
34
|
+
// octal integer
|
|
35
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source +
|
|
36
|
+
'|' +
|
|
37
|
+
// hexadecimal integer
|
|
38
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
|
|
39
|
+
'|' +
|
|
40
|
+
// decimal bigint
|
|
41
|
+
/\d+(?:_\d+)*n/.source +
|
|
42
|
+
'|' +
|
|
43
|
+
// decimal number (integer or float) but no bigint
|
|
44
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
|
|
45
|
+
) +
|
|
46
|
+
')' +
|
|
47
|
+
/(?![\w$])/.source
|
|
48
|
+
),
|
|
49
|
+
lookbehind: true
|
|
50
|
+
},
|
|
51
|
+
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
55
|
+
|
|
56
|
+
Prism.languages.insertBefore('javascript', 'keyword', {
|
|
57
|
+
'regex': {
|
|
58
|
+
pattern: RegExp(
|
|
59
|
+
// lookbehind
|
|
60
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
61
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
|
|
62
|
+
// Regex pattern:
|
|
63
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
64
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
65
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
66
|
+
/\//.source +
|
|
67
|
+
'(?:' +
|
|
68
|
+
/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
|
|
69
|
+
'|' +
|
|
70
|
+
// `v` flag syntax. This supports 3 levels of nested character classes.
|
|
71
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
|
|
72
|
+
')' +
|
|
73
|
+
// lookahead
|
|
74
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
75
|
+
),
|
|
76
|
+
lookbehind: true,
|
|
77
|
+
greedy: true,
|
|
78
|
+
inside: {
|
|
79
|
+
'regex-source': {
|
|
80
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
81
|
+
lookbehind: true,
|
|
82
|
+
alias: 'language-regex',
|
|
83
|
+
inside: Prism.languages.regex
|
|
84
|
+
},
|
|
85
|
+
'regex-delimiter': /^\/|\/$/,
|
|
86
|
+
'regex-flags': /^[a-z]+$/,
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
90
|
+
'function-variable': {
|
|
91
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
92
|
+
alias: 'function'
|
|
93
|
+
},
|
|
94
|
+
'parameter': [
|
|
95
|
+
{
|
|
96
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
97
|
+
lookbehind: true,
|
|
98
|
+
inside: Prism.languages.javascript
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
102
|
+
lookbehind: true,
|
|
103
|
+
inside: Prism.languages.javascript
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
107
|
+
lookbehind: true,
|
|
108
|
+
inside: Prism.languages.javascript
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
112
|
+
lookbehind: true,
|
|
113
|
+
inside: Prism.languages.javascript
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
Prism.languages.insertBefore('javascript', 'string', {
|
|
120
|
+
'hashbang': {
|
|
121
|
+
pattern: /^#!.*/,
|
|
122
|
+
greedy: true,
|
|
123
|
+
alias: 'comment'
|
|
124
|
+
},
|
|
125
|
+
'template-string': {
|
|
126
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
127
|
+
greedy: true,
|
|
128
|
+
inside: {
|
|
129
|
+
'template-punctuation': {
|
|
130
|
+
pattern: /^`|`$/,
|
|
131
|
+
alias: 'string'
|
|
132
|
+
},
|
|
133
|
+
'interpolation': {
|
|
134
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
135
|
+
lookbehind: true,
|
|
136
|
+
inside: {
|
|
137
|
+
'interpolation-punctuation': {
|
|
138
|
+
pattern: /^\$\{|\}$/,
|
|
139
|
+
alias: 'punctuation'
|
|
140
|
+
},
|
|
141
|
+
rest: Prism.languages.javascript
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
'string': /[\s\S]+/
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
'string-property': {
|
|
148
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
149
|
+
lookbehind: true,
|
|
150
|
+
greedy: true,
|
|
151
|
+
alias: 'property'
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
Prism.languages.insertBefore('javascript', 'operator', {
|
|
156
|
+
'literal-property': {
|
|
157
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
158
|
+
lookbehind: true,
|
|
159
|
+
alias: 'property'
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (Prism.languages.markup) {
|
|
164
|
+
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
|
165
|
+
|
|
166
|
+
// add attribute support for all DOM events.
|
|
167
|
+
// https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
|
|
168
|
+
Prism.languages.markup.tag.addAttribute(
|
|
169
|
+
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
170
|
+
'javascript'
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Prism.languages.js = Prism.languages.javascript;
|