commit
6397a44fd9
17 changed files with 2694 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||||
|
node_modules |
||||
|
dist |
@ -0,0 +1,12 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>Document</title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<div id="app"></div> |
||||
|
<script type="module" src="main.ts"></script> |
||||
|
</body> |
||||
|
</html> |
@ -0,0 +1,4 @@ |
|||||
|
import XxEditor from "@inkeon/core" |
||||
|
|
||||
|
const editor = new XxEditor() |
||||
|
editor.init("#app") |
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"name": "@examples/basic", |
||||
|
"type": "module", |
||||
|
"version": "1.0.0", |
||||
|
"description": "", |
||||
|
"main": "index.js", |
||||
|
"scripts": { |
||||
|
"start": "vite" |
||||
|
}, |
||||
|
"keywords": [], |
||||
|
"author": "", |
||||
|
"license": "ISC", |
||||
|
"devDependencies": { |
||||
|
"@inkeon/core": "workspace:*" |
||||
|
} |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
{ |
||||
|
"private": true, |
||||
|
"name": "inkeon", |
||||
|
"scripts": {}, |
||||
|
"devDependencies": { |
||||
|
"@types/lodash-es": "^4.17.12", |
||||
|
"lodash-es": "^4.17.21", |
||||
|
"typescript": "^5.7.2", |
||||
|
"unbuild": "^3.0.1", |
||||
|
"vite": "^6.0.5" |
||||
|
} |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
import { BuildConfig, defineBuildConfig } from "unbuild"; |
||||
|
import { merge } from "lodash-es"; |
||||
|
|
||||
|
// OR tsup
|
||||
|
|
||||
|
const BaseConfig = { |
||||
|
entries: [ |
||||
|
"src/index.ts", |
||||
|
{ |
||||
|
input: "src/", |
||||
|
outDir: "dist/esm/", |
||||
|
format: "esm", |
||||
|
ext: "mjs", |
||||
|
declaration: true, |
||||
|
}, |
||||
|
{ |
||||
|
input: "src/", |
||||
|
outDir: "dist/cjs/", |
||||
|
format: "cjs", |
||||
|
ext: "cjs", |
||||
|
declaration: true, |
||||
|
}, |
||||
|
], |
||||
|
declaration: true, |
||||
|
replace: {}, |
||||
|
rollup: { |
||||
|
emitCJS: true, |
||||
|
output: { |
||||
|
exports: "named" |
||||
|
} |
||||
|
}, |
||||
|
} as BuildConfig; |
||||
|
|
||||
|
|
||||
|
export function mergeConfig(targetConfig: BuildConfig) { |
||||
|
return defineBuildConfig(merge(BaseConfig, targetConfig)) |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
import { mergeConfig } from "./build.config.base"; |
||||
|
|
||||
|
export default mergeConfig({ |
||||
|
replace: { |
||||
|
__DEV__: "true", |
||||
|
__PROD__: "false" |
||||
|
} |
||||
|
}); |
@ -0,0 +1,14 @@ |
|||||
|
import { mergeConfig } from "./build.config.base"; |
||||
|
console.log(mergeConfig({ |
||||
|
replace: { |
||||
|
__DEV__: "false", |
||||
|
__PROD__: "true" |
||||
|
} |
||||
|
})); |
||||
|
|
||||
|
export default mergeConfig({ |
||||
|
replace: { |
||||
|
__DEV__: "false", |
||||
|
__PROD__: "true" |
||||
|
} |
||||
|
}); |
@ -0,0 +1,7 @@ |
|||||
|
'use strict' |
||||
|
|
||||
|
if (process.env.NODE_ENV === 'production') { |
||||
|
module.exports = require('./dist/index.cjs') |
||||
|
} else { |
||||
|
module.exports = require('./dist/index.cjs') |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
export * from './index.js' |
@ -0,0 +1,51 @@ |
|||||
|
{ |
||||
|
"name": "@inkeon/core", |
||||
|
"type": "module", |
||||
|
"version": "1.0.0", |
||||
|
"description": "", |
||||
|
"main": "index.js", |
||||
|
"module": "./index.mjs", |
||||
|
"exports": { |
||||
|
".": { |
||||
|
"import": { |
||||
|
"types": "./dist/index.d.mts", |
||||
|
"node": "./dist/index.mjs", |
||||
|
"default": "./dist/index.mjs" |
||||
|
}, |
||||
|
"require": { |
||||
|
"types": "./dist/index.d.cts", |
||||
|
"node": "./dist/index.cjs", |
||||
|
"default": "./dist/index.cjs" |
||||
|
}, |
||||
|
"types": "./dist/index.d.ts" |
||||
|
}, |
||||
|
"./cjs/*": { |
||||
|
"types": "./dist/cjs/*.d.ts", |
||||
|
"node": "./dist/cjs/*.cjs", |
||||
|
"default": "./dist/cjs/*.cjs" |
||||
|
}, |
||||
|
"./esm/*": { |
||||
|
"types": "./dist/esm/*.d.ts", |
||||
|
"node": "./dist/esm/*.mjs", |
||||
|
"default": "./dist/esm/*.mjs" |
||||
|
} |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"build": "unbuild --config build/build.config.prod.ts", |
||||
|
"dev": "unbuild --config build/build.config.dev.ts --watch", |
||||
|
"build:stub": "unbuild --config build/build.config.prod.ts --stub" |
||||
|
}, |
||||
|
"files": [ |
||||
|
"index.js", |
||||
|
"index.mjs", |
||||
|
"dist" |
||||
|
], |
||||
|
"keywords": [], |
||||
|
"author": "", |
||||
|
"license": "ISC", |
||||
|
"dependencies": { |
||||
|
"@tiptap/core": "^2.10.4", |
||||
|
"@tiptap/pm": "^2.10.4", |
||||
|
"@tiptap/starter-kit": "^2.10.4" |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
import { Editor } from '@tiptap/core' |
||||
|
import StarterKit from '@tiptap/starter-kit' |
||||
|
import { getDom } from './utils.js' |
||||
|
|
||||
|
console.log(__DEV__); |
||||
|
|
||||
|
class Inkeon { |
||||
|
constructor(dom: string | Element) { |
||||
|
const domEl = getDom(dom) |
||||
|
this.init(domEl) |
||||
|
} |
||||
|
|
||||
|
#editor: Editor |
||||
|
|
||||
|
init(dom: Element) { |
||||
|
this.#editor = new Editor({ |
||||
|
element: getDom(dom), |
||||
|
extensions: [StarterKit], |
||||
|
content: '<p>Hello World!</p>', |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export { Inkeon } |
||||
|
export default Inkeon |
@ -0,0 +1,11 @@ |
|||||
|
|
||||
|
export function getDom(params: string | Element) { |
||||
|
if (typeof params === "string") { |
||||
|
const el = document.querySelector(params) |
||||
|
if (!el) { |
||||
|
throw "请指定dom元素" |
||||
|
} |
||||
|
return el |
||||
|
} |
||||
|
return params |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
|
||||
|
declare const __DEV__: boolean |
File diff suppressed because it is too large
@ -0,0 +1,4 @@ |
|||||
|
packages: |
||||
|
- 'packages/*' |
||||
|
- 'examples/*' |
||||
|
- '!**/test/**' |
@ -0,0 +1,17 @@ |
|||||
|
{ |
||||
|
"compilerOptions": { |
||||
|
"module": "NodeNext", |
||||
|
"moduleResolution": "nodenext", |
||||
|
"baseUrl": ".", |
||||
|
"paths": { |
||||
|
"@inkeon/*": [ |
||||
|
"packages/*/src" |
||||
|
] |
||||
|
}, |
||||
|
}, |
||||
|
"include": [ |
||||
|
"examples", |
||||
|
"packages/*/src", |
||||
|
"packages/global.d.ts", |
||||
|
] |
||||
|
} |
Loading…
Reference in new issue