-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from andi23rosca/solid-markdown-v2
solid-markdown V2
- Loading branch information
Showing
39 changed files
with
3,155 additions
and
8,450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.3.1/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// solid-refresh | ||
import { createSignal, type Component, createEffect } from "solid-js"; | ||
import remarkGfm from "remark-gfm"; | ||
import { SolidMarkdown } from "../src"; | ||
import { Components } from "src/types"; | ||
const initial = `# 🚀 solid-markdown demo | ||
Edit any of the text and see it rendered in real time. | ||
A paragraph with *emphasis* and **strong importance**. | ||
## Custom component for heading 2 | ||
> A block quote with ~strikethrough~ and a URL: https://reactjs.org. | ||
* Lists | ||
* [ ] todo | ||
* [x] done | ||
1. nested | ||
2. lists | ||
* another one | ||
nested text under a list item | ||
A table: | ||
| Syntax | Description | Test Text | | ||
| :--- | :----: | ---: | | ||
| Header | Title | Here's this | | ||
| Paragraph | Text | And more |`; | ||
|
||
const App: Component = () => { | ||
const [md, setMd] = createSignal(initial); | ||
|
||
return ( | ||
<div class="container"> | ||
<textarea | ||
rows={md().split(/\r\n|\r|\n/).length + 2} | ||
class="editor" | ||
onInput={(e) => { | ||
setMd(e.currentTarget.value); | ||
}} | ||
contentEditable | ||
> | ||
{md()} | ||
</textarea> | ||
|
||
<SolidMarkdown | ||
remarkPlugins={[remarkGfm]} | ||
components={{ | ||
h2: Heading2, | ||
}} | ||
> | ||
{md()} | ||
</SolidMarkdown> | ||
</div> | ||
); | ||
}; | ||
|
||
const Heading2: Components["h2"] = (props) => { | ||
return <p style={{ color: "red" }}>{props.children}</p>; | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<title>Solid Markdown Demo</title> | ||
</head> | ||
|
||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
|
||
<script src="./index.tsx" type="module"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { render } from 'solid-js/web' | ||
import "./styles.css" | ||
import App from './App' | ||
|
||
render(() => <App />, document.getElementById('root')!) |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
body { | ||
font-family: sans-serif; | ||
margin: 0; | ||
font-size: 16px; | ||
padding: 1rem; | ||
} | ||
|
||
.container { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
column-gap: 3rem; | ||
max-width: 65rem; | ||
padding: 1rem; | ||
margin: 0 auto; | ||
} | ||
@media screen and (max-width: 600px) { | ||
.container { | ||
grid-template-columns: 1fr; | ||
row-gap: 1rem; | ||
} | ||
} | ||
|
||
.container .editor { | ||
padding: 1rem; | ||
white-space: pre-wrap; | ||
resize: none; | ||
font-family: monospace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["vite/client"] | ||
}, | ||
"exclude": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { defineConfig } from 'vite' | ||
import solidPlugin from 'vite-plugin-solid' | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
alias: { | ||
src: '/src', | ||
}, | ||
}, | ||
plugins: [ | ||
solidPlugin(), | ||
{ | ||
name: 'Reaplace env variables', | ||
transform(code, id) { | ||
if (id.includes('node_modules')) { | ||
return code | ||
} | ||
return code | ||
.replace(/process\.env\.SSR/g, 'false') | ||
.replace(/process\.env\.DEV/g, 'true') | ||
.replace(/process\.env\.PROD/g, 'false') | ||
.replace(/process\.env\.NODE_ENV/g, '"development"') | ||
.replace(/import\.meta\.env\.SSR/g, 'false') | ||
.replace(/import\.meta\.env\.DEV/g, 'true') | ||
.replace(/import\.meta\.env\.PROD/g, 'false') | ||
.replace(/import\.meta\.env\.NODE_ENV/g, '"development"') | ||
}, | ||
}, | ||
], | ||
server: { | ||
port: 3000, | ||
}, | ||
build: { | ||
target: 'esnext', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
declare global { | ||
interface ImportMeta { | ||
env: { | ||
NODE_ENV: 'production' | 'development' | ||
PROD: boolean | ||
DEV: boolean | ||
} | ||
} | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
NODE_ENV: 'production' | 'development' | ||
PROD: boolean | ||
DEV: boolean | ||
} | ||
} | ||
} | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.