Skip to content

Commit

Permalink
rebuild this proj
Browse files Browse the repository at this point in the history
  • Loading branch information
g-mero committed Aug 2, 2024
1 parent a30dfda commit d275b30
Show file tree
Hide file tree
Showing 52 changed files with 6,831 additions and 35,300 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

23 changes: 1 addition & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
pnpm-lock.yaml
9 changes: 0 additions & 9 deletions .gitpod.yml

This file was deleted.

52 changes: 52 additions & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const Dynamic: typeof import('solid-js/web')['Dynamic']
const ErrorBoundary: typeof import('solid-js')['ErrorBoundary']
const For: typeof import('solid-js')['For']
const Index: typeof import('solid-js')['Index']
const Match: typeof import('solid-js')['Match']
const Portal: typeof import('solid-js/web')['Portal']
const Show: typeof import('solid-js')['Show']
const Suspense: typeof import('solid-js')['Suspense']
const SuspenseList: typeof import('solid-js')['SuspenseList']
const Switch: typeof import('solid-js')['Switch']
const batch: typeof import('solid-js')['batch']
const children: typeof import('solid-js')['children']
const createContext: typeof import('solid-js')['createContext']
const createDeferred: typeof import('solid-js')['createDeferred']
const createEffect: typeof import('solid-js')['createEffect']
const createMemo: typeof import('solid-js')['createMemo']
const createMutable: typeof import('solid-js/store')['createMutable']
const createRenderEffect: typeof import('solid-js')['createRenderEffect']
const createResource: typeof import('solid-js')['createResource']
const createRoot: typeof import('solid-js')['createRoot']
const createSelector: typeof import('solid-js')['createSelector']
const createSignal: typeof import('solid-js')['createSignal']
const createStore: typeof import('solid-js/store')['createStore']
const hydrate: typeof import('solid-js/web')['hydrate']
const indexArray: typeof import('solid-js')['indexArray']
const isServer: typeof import('solid-js/web')['isServer']
const lazy: typeof import('solid-js')['lazy']
const mapArray: typeof import('solid-js')['mapArray']
const mergeProps: typeof import('solid-js')['mergeProps']
const observable: typeof import('solid-js')['observable']
const on: typeof import('solid-js')['on']
const onCleanup: typeof import('solid-js')['onCleanup']
const onError: typeof import('solid-js')['onError']
const onMount: typeof import('solid-js')['onMount']
const produce: typeof import('solid-js/store')['produce']
const reconcile: typeof import('solid-js/store')['reconcile']
const render: typeof import('solid-js/web')['render']
const renderToStream: typeof import('solid-js/web')['renderToStream']
const renderToString: typeof import('solid-js/web')['renderToString']
const renderToStringAsync: typeof import('solid-js/web')['renderToStringAsync']
const splitProps: typeof import('solid-js')['splitProps']
const untrack: typeof import('solid-js')['untrack']
const useContext: typeof import('solid-js')['useContext']
const useTransition: typeof import('solid-js')['useTransition']
}
74 changes: 74 additions & 0 deletions esbuild-plugin-scss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable node/prefer-global/process */
import fs from 'node:fs'
import path from 'node:path'
import type { BuildOptions, Charset, Plugin } from 'esbuild'
import esbuild from 'esbuild'

export interface StylePluginOptions {
/**
* whether to minify the css code.
* @default true
*/
minify?: boolean

/**
* css charset.
* @default 'utf8'
*/
charset?: Charset
}

// https://github.com/evanw/esbuild/issues/20#issuecomment-802269745
export function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Plugin {
return {
name: 'style',
setup({ onResolve, onLoad }) {
const cwd = process.cwd()
const opt: BuildOptions = { logLevel: 'silent', bundle: true, write: false, charset, minify }

onResolve({ filter: /\.css$/, namespace: 'file' }, (args) => {
const absPath = path.join(args.resolveDir, args.path)
const relPath = path.relative(cwd, absPath)
const resolved = fs.existsSync(absPath) ? relPath : args.path
return { path: resolved, namespace: 'style-stub' }
})

onResolve({ filter: /\.css$/, namespace: 'style-stub' }, (args) => {
return { path: args.path, namespace: 'style-content' }
})

onResolve({ filter: /^__style_helper__$/, namespace: 'style-stub' }, args => ({
path: args.path,
namespace: 'style-helper',
sideEffects: false,
}))

onLoad({ filter: /.*/, namespace: 'style-helper' }, async () => ({
contents: `
export function injectStyle(text) {
if (typeof document !== 'undefined') {
var style = document.createElement('style')
var node = document.createTextNode(text)
style.appendChild(node)
document.head.appendChild(style)
}
}
`,
}))

onLoad({ filter: /.*/, namespace: 'style-stub' }, async args => ({
contents: `
import { injectStyle } from "__style_helper__"
import css from ${JSON.stringify(args.path)}
injectStyle(css)
`,
}))

onLoad({ filter: /.*/, namespace: 'style-content' }, async (args) => {
const options = { entryPoints: [args.path], ...opt }
const { errors, warnings, outputFiles } = await esbuild.build(options)
return { errors, warnings, contents: outputFiles![0].text, loader: 'text' }
})
},
}
}
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import antfu from '@antfu/eslint-config'

export default antfu({
solid: true,
rules: {
'no-console': 'warn',
// conflicts with auto-import
'solid/jsx-no-undef': 'off',
'solid/reactivity': ['warn', {
// List of function names to consider as reactive functions (allow signals to be safely passed as arguments). In addition, any create* or use* functions are automatically included.
customReactiveFunctions: ['watch'], // Array<string>
}],
},
ignores: ['*.d.ts', '*.js'],
})
68 changes: 6 additions & 62 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Solid</title>
<link rel="stylesheet" href="docs/global.css">
<link rel="stylesheet" href="docs/global.css" />
</head>

<body style="background-color: blanchedalmond;">
<div id="app" style="max-width: 600px; margin: 3rem auto 0;"></div>
<body style="background-color: blanchedalmond">
<div id="app" style="max-width: 600px; margin: 3rem auto 0"></div>
<div id="change-theme">
<i class="icon"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
<g fill="none">
Expand All @@ -21,7 +21,7 @@
</g>
</svg></i>

<i class="icon hide" style="color: #fff;"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"
<i class="icon hide" style="color: #fff"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"
viewBox="0 0 24 24">
<g fill="currentColor">
<path d="M18 12a6 6 0 1 1-12 0a6 6 0 0 1 12 0Z" />
Expand All @@ -35,73 +35,17 @@
<script type="module">
import { Editor } from '/src/index.ts'

const md = window.markdownit()


let theme = 'light'

const editor = Editor({
target: document.querySelector('#app'),
onChange(v) {
console.log(v)
},
handelPreview(v) {
return md.render(v)
},

theme,
})

editor.setVal(`## 这是测试测试
可能有一些小问题
但是问题不大
主要是想看看有没有用
> 比如这是一个blockquote
> 这也是
\`\`\`javascript
var gmero = "gmero"
console.log(gmero)
\`\`\`
尽量弄个长一点我好测试滚动条的情况
啊啊啊
啊啊啊
啊啊啊
啊啊啊
啊啊啊
`)

const changeThemeBtn = document.querySelector('#change-theme')

if (changeThemeBtn) {
changeThemeBtn.addEventListener('click', () => {
const [moon, sun] = changeThemeBtn.querySelectorAll('.icon')
if (theme === 'light') {
theme = 'dark'
moon.classList.add('hide')
sun.classList.remove('hide')
changeThemeBtn.classList.add('dark')
document.body.classList.add('dark')
} else {
theme = 'light'
sun.classList.add('hide')
moon.classList.remove('hide')
changeThemeBtn.classList.remove('dark')
document.body.classList.remove('dark')
}
editor.setTheme(theme)
})
}
</script>
</body>

Expand Down
76 changes: 49 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,61 @@
{
"name": "solidjs-md-editor",
"private": false,
"version": "0.2.1",
"type": "module",
"main": "./dist/editor.es.js",
"module": "./dist/editor.es.js",
"version": "0.3.0",
"private": false,
"exports": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {},
"files": [
"dist"
],
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"build": "tsup --dts"
},
"devDependencies": {
"@iconify-icon/solid": "^1.0.7",
"@iconify-icons/solar": "^1.2.0",
"@types/codemirror": "^5.60.7",
"@types/lodash-es": "^4.17.7",
"@xbmlz/eslint-config-prettier": "^0.1.16",
"@xbmlz/eslint-config-solid": "^0.1.16",
"babel-preset-solid": "^1.7.3",
"eslint": "^8.38.0",
"sass": "^1.61.0",
"typescript": "^4.9.5",
"typescript-plugin-css-modules": "^4.2.3",
"vite": "^3.2.5",
"vite-plugin-dts": "^2.2.0",
"vite-plugin-solid": "^2.7.0",
"@babel/core": "^7.21.4"
"peerDependencies": {
"solid-js": ">=1.8.0"
},
"dependencies": {
"codemirror": "5.65.12",
"lodash-es": "^4.17.21",
"solid-js": "^1.7.3"
}
}
"@codemirror/commands": "^6.6.0",
"@codemirror/lang-markdown": "^6.2.5",
"@codemirror/language": "^6.10.2",
"@codemirror/language-data": "^6.5.1",
"@codemirror/state": "^6.4.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.29.1",
"@floating-ui/dom": "^1.6.7",
"@iconify-json/ri": "^1.1.21",
"@iconify/json": "^2.2.232",
"@lezer/highlight": "^1.2.0",
"@unocss/reset": "^0.61.2",
"codemirror": "^6.0.1",
"solid-motionone": "^1.0.0",
"solid-uses": "^0.1.4",
"unocss": "^0.61.2"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.2",
"@iconify-icon/solid": "^2.1.1",
"@lezer/markdown": "^1.3.0",
"@types/node": "^20.14.9",
"@unocss/vite": "^0.61.2",
"esbuild": "^0.23.0",
"eslint": "^8.57.0",
"eslint-plugin-solid": "^0.14.1",
"tsup": "^8.1.0",
"tsup-preset-solid": "^2.2.0",
"typescript": "^5.5.3",
"unplugin-auto-import": "^0.18.2",
"vite": "^5.3.3",
"vite-plugin-solid": "^2.10.2"
},
"browser": {}
}
Loading

0 comments on commit d275b30

Please sign in to comment.