Browse Source

init

standard
谢亚昕 3 months ago
commit
6397a44fd9
  1. 2
      .gitignore
  2. 12
      examples/basic/index.html
  3. 4
      examples/basic/main.ts
  4. 16
      examples/basic/package.json
  5. 12
      package.json
  6. 37
      packages/core/build/build.config.base.ts
  7. 8
      packages/core/build/build.config.dev.ts
  8. 14
      packages/core/build/build.config.prod.ts
  9. 7
      packages/core/index.js
  10. 1
      packages/core/index.mjs
  11. 51
      packages/core/package.json
  12. 25
      packages/core/src/index.ts
  13. 11
      packages/core/src/utils.ts
  14. 2
      packages/global.d.ts
  15. 2471
      pnpm-lock.yaml
  16. 4
      pnpm-workspace.yaml
  17. 17
      tsconfig.json

2
.gitignore

@ -0,0 +1,2 @@
node_modules
dist

12
examples/basic/index.html

@ -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>

4
examples/basic/main.ts

@ -0,0 +1,4 @@
import XxEditor from "@inkeon/core"
const editor = new XxEditor()
editor.init("#app")

16
examples/basic/package.json

@ -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:*"
}
}

12
package.json

@ -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"
}
}

37
packages/core/build/build.config.base.ts

@ -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))
}

8
packages/core/build/build.config.dev.ts

@ -0,0 +1,8 @@
import { mergeConfig } from "./build.config.base";
export default mergeConfig({
replace: {
__DEV__: "true",
__PROD__: "false"
}
});

14
packages/core/build/build.config.prod.ts

@ -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"
}
});

7
packages/core/index.js

@ -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')
}

1
packages/core/index.mjs

@ -0,0 +1 @@
export * from './index.js'

51
packages/core/package.json

@ -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"
}
}

25
packages/core/src/index.ts

@ -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

11
packages/core/src/utils.ts

@ -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
}

2
packages/global.d.ts

@ -0,0 +1,2 @@
declare const __DEV__: boolean

2471
pnpm-lock.yaml

File diff suppressed because it is too large

4
pnpm-workspace.yaml

@ -0,0 +1,4 @@
packages:
- 'packages/*'
- 'examples/*'
- '!**/test/**'

17
tsconfig.json

@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "nodenext",
"baseUrl": ".",
"paths": {
"@inkeon/*": [
"packages/*/src"
]
},
},
"include": [
"examples",
"packages/*/src",
"packages/global.d.ts",
]
}
Loading…
Cancel
Save