@d1vij/react-mdx-loader 0.1.0 → 0.1.2

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/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- type JSX = React.JSX.Element | null;
2
- type HeaderLevels = 1 | 2 | 3 | 4 | 5 | 6;
3
- type StyleClasses = "header" | `header_${HeaderLevels}` | "header_icon" | "anchor" | "button" | "bold" | "italic" | "span" | "striked" | "paragraph" | "code" | "preformatted" | "blockquote" | "horizontal_line" | "image" | "list" | `${"un" | ""}ordered_list` | "list_item" | "table" | "table_head" | "table_head_cell" | "table_body" | "table_row" | "table_data";
1
+ declare const StyleClassesList: readonly ["header", "header_1", "header_2", "header_3", "header_4", "header_5", "header_6", "header_icon", "anchor", "button", "bold", "italic", "span", "striked", "paragraph", "code", "preformatted", "blockquote", "horizontal_line", "image", "list", "unordered_list", "ordered_list", "list_item", "table", "table_head", "table_head_cell", "table_body", "table_row", "table_data"];
2
+ type StyleClasses = (typeof StyleClassesList)[number];
4
3
  type StyleClassesMap = Partial<{ [K in StyleClasses] : string }>;
5
4
  declare const StyleContext: React.Context<StyleClassesMap>;
5
+ type JSX = React.JSX.Element | null;
6
+ type HeaderLevels = 1 | 2 | 3 | 4 | 5 | 6;
6
7
  import { MDXProps } from "mdx/types";
7
8
  type MDXSourceComponent = React.ComponentType<MDXProps>;
8
9
  type MDXFromComponentProps = {
@@ -12,7 +13,7 @@ declare function MDXFromComponent({ SourceComponent }: MDXFromComponentProps): J
12
13
  import { Options as MDXOptions } from "@mdx-js/rollup";
13
14
  import { Plugin } from "vite";
14
15
  type MDXLoaderPluginOptions = {
15
- mdxPluginOptions: MDXOptions;
16
+ mdxPluginOptions?: MDXOptions;
16
17
  };
17
18
  /**
18
19
  * Vite plugin to support MDX conversion.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createContext as G,useContext as K}from"react";var c=G({});function o(){return K(c)}import{cn as W}from"@d1vij/shit-i-always-use";import{useState as Y}from"react";import{jsxDEV as $}from"react/jsx-dev-runtime";var Z=new URL(window.location.href).origin.toString();function J(t){let e=o(),[r]=Y(()=>{if(t.href?.match(/^#.*/))return"_self";return new URL(t.href??"").origin.toString()===Z?"_self":"_blank"});return $("a",{className:W(e.anchor),target:r,href:t.href,children:t.children},void 0,!1,void 0,this)}import{cn as Q}from"@d1vij/shit-i-always-use";import{jsxDEV as R}from"react/jsx-dev-runtime";function f(t){let e=o();return R("blockquote",{className:Q(e.blockquote),children:t.children},void 0,!1,void 0,this)}import{cn as A}from"@d1vij/shit-i-always-use";import{jsxDEV as B}from"react/jsx-dev-runtime";function P(t){let e=o();return B("span",{className:A(e.bold),children:t.children},void 0,!1,void 0,this)}import{cn as I}from"@d1vij/shit-i-always-use";import{jsxDEV as H}from"react/jsx-dev-runtime";function i(t){let e=o(),r=/language-(\w+)/.exec(t.className||"")?.[1];return H("code",{className:I(e.code,r&&`language-${r}`),children:t.children},void 0,!1,void 0,this)}import{cn as T,useClipboardText as D}from"@d1vij/shit-i-always-use";import{useEffect as x,useRef as v,useState as V}from"react";import{jsxDEV as d}from"react/jsx-dev-runtime";function n(t){let e=o(),r=v(null),[p,u]=V(""),{copy:O}=D();async function U(){let X=new URL(`/#${p}`,window.location.origin).toString();console.log("clicked"),await O(X)}return x(()=>{if(!r.current)return;let z=(r.current.textContent??"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,30);u(z)},[]),d("h1",{className:T(e.header,e[`header_${t.level}`]),children:d("button",{onClick:()=>void U(),ref:r,id:p,type:"button",children:t.children},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{cn as j}from"@d1vij/shit-i-always-use";import{jsxDEV as tt}from"react/jsx-dev-runtime";function y(t){let e=o();return tt("img",{className:j(e.image),alt:t.alt,title:t.title,src:t.src},void 0,!1,void 0,this)}import{cn as et}from"@d1vij/shit-i-always-use";import{jsxDEV as ot}from"react/jsx-dev-runtime";function h(t){let e=o();return ot("span",{className:et(e.italic),children:t.children},void 0,!1,void 0,this)}import{cn as b}from"@d1vij/shit-i-always-use";import{jsxDEV as g}from"react/jsx-dev-runtime";function s(t){let e=o(),r=t.type==="ordered"?"ol":"ul";return g(r,{className:b(e.list,t.type==="ordered"&&e.ordered_list,t.type==="unordered"&&e.unordered_list),children:t.children},void 0,!1,void 0,this)}function N(t){let e=o();return g("li",{className:b(e.list_item),children:t.children},void 0,!1,void 0,this)}import{cn as rt}from"@d1vij/shit-i-always-use";import{jsxDEV as nt}from"react/jsx-dev-runtime";function _(t){let e=o();return nt("p",{className:rt(e.paragraph),children:t.children},void 0,!1,void 0,this)}import{cn as mt}from"@d1vij/shit-i-always-use";import{jsxDEV as lt}from"react/jsx-dev-runtime";function a(t){let e=o();return lt("pre",{className:mt(e.preformatted),children:t.children},void 0,!1,void 0,this)}import{cn as st}from"@d1vij/shit-i-always-use";import{jsxDEV as pt}from"react/jsx-dev-runtime";function M(t){let e=o();return pt("span",{className:st(e.striked),children:t.children},void 0,!1,void 0,this)}import{cn as m}from"@d1vij/shit-i-always-use";import{jsxDEV as l}from"react/jsx-dev-runtime";function F(t){let e=o();return l("table",{className:m(e.table),children:t.children},void 0,!1,void 0,this)}function q(t){let e=o();return l("thead",{className:m(e.table_head),children:t.children},void 0,!1,void 0,this)}function E(t){let e=o();return l("tbody",{className:m(e.table_body),children:t.children},void 0,!1,void 0,this)}function k(t){let e=o();return l("tr",{className:m(e.table_row),children:t.children},void 0,!1,void 0,this)}function w(t){let e=o();return l("th",{className:m(e.table_head_cell),children:t.children},void 0,!1,void 0,this)}function L(t){let e=o();return l("td",{className:m(e.table_data),children:t.children},void 0,!1,void 0,this)}var ct={h1:(t)=>n({...t,level:1}),h2:(t)=>n({...t,level:2}),h3:(t)=>n({...t,level:3}),h4:(t)=>n({...t,level:4}),h5:(t)=>n({...t,level:5}),h6:(t)=>n({...t,level:6}),a:J,em:h,del:M,strong:P,code:i,blockquote:f,pre:a,p:_,ol:(t)=>s({...t,type:"ordered"}),ul:(t)=>s({...t,type:"unordered"}),li:N,img:y,table:F,thead:q,tbody:E,th:w,tr:k,td:L},S=ct;import{jsxDEV as ft}from"react/jsx-dev-runtime";function C({SourceComponent:t}){return ft(t,{components:S},void 0,!1,void 0,this)}import it from"@mdx-js/rollup";function yt({mdxPluginOptions:t}){return{name:"react-mdx-loader-plugin",enforce:"pre",config(e){return{...e,plugins:[it(t)]}}}}export{c as StyleContext,yt as MDXLoaderPlugin,C as MDXFromComponent};
1
+ import{createContext as U,useContext as G}from"react";var p=U({});function o(){return G(p)}import{cn as R}from"@d1vij/shit-i-always-use";import{useMemo as W,useState as Y}from"react";import{jsxDEV as Z}from"react/jsx-dev-runtime";function h(t){let e=W(()=>new URL(window.location.href).origin.toString(),[]),r=o(),[s]=Y(()=>{if(t.href?.match(/^#.*/))return"_self";return new URL(t.href??"").origin.toString()===e?"_self":"_blank"});return Z("a",{className:R(r.anchor),target:s,href:t.href,children:t.children},void 0,!1,void 0,this)}import{cn as $}from"@d1vij/shit-i-always-use";import{jsxDEV as x}from"react/jsx-dev-runtime";function c(t){let e=o();return x("blockquote",{className:$(e.blockquote),children:t.children},void 0,!1,void 0,this)}import{cn as A}from"@d1vij/shit-i-always-use";import{jsxDEV as Q}from"react/jsx-dev-runtime";function _(t){let e=o();return Q("span",{className:A(e.bold),children:t.children},void 0,!1,void 0,this)}import{cn as T}from"@d1vij/shit-i-always-use";import{jsxDEV as B}from"react/jsx-dev-runtime";function i(t){let e=o(),r=/language-(\w+)/.exec(t.className||"")?.[1];return B("code",{className:T(e.code,r&&`language-${r}`),children:t.children},void 0,!1,void 0,this)}import{cn as I,useClipboardText as H}from"@d1vij/shit-i-always-use";import{useEffect as D,useRef as v,useState as V}from"react";import{jsxDEV as b}from"react/jsx-dev-runtime";function n(t){let e=o(),r=v(null),[s,u]=V(""),{copy:d}=H();async function K(){let X=new URL(`/#${s}`,window.location.origin).toString();console.log("clicked"),await d(X)}return D(()=>{if(!r.current)return;let O=(r.current.textContent??"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,30);u(O)},[]),b("h1",{className:I(e.header,e[`header_${t.level}`]),children:b("button",{onClick:()=>void K(),ref:r,id:s,type:"button",children:t.children},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{cn as j}from"@d1vij/shit-i-always-use";import{jsxDEV as tt}from"react/jsx-dev-runtime";function y(t){let e=o();return tt("img",{className:j(e.image),alt:t.alt,title:t.title,src:t.src},void 0,!1,void 0,this)}import{cn as et}from"@d1vij/shit-i-always-use";import{jsxDEV as ot}from"react/jsx-dev-runtime";function J(t){let e=o();return ot("span",{className:et(e.italic),children:t.children},void 0,!1,void 0,this)}import{cn as P}from"@d1vij/shit-i-always-use";import{jsxDEV as C}from"react/jsx-dev-runtime";function a(t){let e=o(),r=t.type==="ordered"?"ol":"ul";return C(r,{className:P(e.list,t.type==="ordered"&&e.ordered_list,t.type==="unordered"&&e.unordered_list),children:t.children},void 0,!1,void 0,this)}function g(t){let e=o();return C("li",{className:P(e.list_item),children:t.children},void 0,!1,void 0,this)}import{cn as rt}from"@d1vij/shit-i-always-use";import{jsxDEV as nt}from"react/jsx-dev-runtime";function N(t){let e=o();return nt("p",{className:rt(e.paragraph),children:t.children},void 0,!1,void 0,this)}import{cn as lt}from"@d1vij/shit-i-always-use";import{jsxDEV as mt}from"react/jsx-dev-runtime";function f(t){let e=o();return mt("pre",{className:lt(e.preformatted),children:t.children},void 0,!1,void 0,this)}import{cn as st}from"@d1vij/shit-i-always-use";import{jsxDEV as at}from"react/jsx-dev-runtime";function M(t){let e=o();return at("span",{className:st(e.striked),children:t.children},void 0,!1,void 0,this)}import{cn as l}from"@d1vij/shit-i-always-use";import{jsxDEV as m}from"react/jsx-dev-runtime";function E(t){let e=o();return m("table",{className:l(e.table),children:t.children},void 0,!1,void 0,this)}function L(t){let e=o();return m("thead",{className:l(e.table_head),children:t.children},void 0,!1,void 0,this)}function k(t){let e=o();return m("tbody",{className:l(e.table_body),children:t.children},void 0,!1,void 0,this)}function q(t){let e=o();return m("tr",{className:l(e.table_row),children:t.children},void 0,!1,void 0,this)}function F(t){let e=o();return m("th",{className:l(e.table_head_cell),children:t.children},void 0,!1,void 0,this)}function w(t){let e=o();return m("td",{className:l(e.table_data),children:t.children},void 0,!1,void 0,this)}var pt={h1:(t)=>n({...t,level:1}),h2:(t)=>n({...t,level:2}),h3:(t)=>n({...t,level:3}),h4:(t)=>n({...t,level:4}),h5:(t)=>n({...t,level:5}),h6:(t)=>n({...t,level:6}),a:h,em:J,del:M,strong:_,code:i,blockquote:c,pre:f,p:N,ol:(t)=>a({...t,type:"ordered"}),ul:(t)=>a({...t,type:"unordered"}),li:g,img:y,table:E,thead:L,tbody:k,th:F,tr:q,td:w},S=pt;import{jsxDEV as ct}from"react/jsx-dev-runtime";function z({SourceComponent:t}){return ct(t,{components:S},void 0,!1,void 0,this)}import it from"@mdx-js/rollup";function yt({mdxPluginOptions:t}){return{name:"react-mdx-loader-plugin",enforce:"pre",config(e){return{...e,plugins:[it(t)]}}}}export{p as StyleContext,yt as MDXLoaderPlugin,z as MDXFromComponent};
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/d1vij/react-mdx-loader"
6
6
  },
7
7
  "homepage": "https://github.com/d1vij/react-mdx-loader",
8
- "version": "0.1.0",
8
+ "version": "0.1.2",
9
9
  "description": "Supporting lib to create content driven sites using MDX",
10
10
  "license": "MIT",
11
11
  "files": [