mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 14:59:27 +08:00
refactor: move the jsx-runtime into @tiptap/core
This commit is contained in:
parent
a6adab0346
commit
dd7ea894f8
21
package-lock.json
generated
21
package-lock.json
generated
@ -4910,10 +4910,6 @@
|
||||
"resolved": "packages/html",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tiptap/jsx": {
|
||||
"resolved": "packages/jsx",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tiptap/pm": {
|
||||
"resolved": "packages/pm",
|
||||
"link": true
|
||||
@ -4926,10 +4922,6 @@
|
||||
"resolved": "packages/starter-kit",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tiptap/static-renderer": {
|
||||
"resolved": "packages/static-renderer",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tiptap/suggestion": {
|
||||
"resolved": "packages/suggestion",
|
||||
"link": true
|
||||
@ -19792,19 +19784,6 @@
|
||||
"@tiptap/pm": "^2.6.6"
|
||||
}
|
||||
},
|
||||
"packages/jsx": {
|
||||
"name": "@tiptap/jsx",
|
||||
"version": "2.6.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.6.6",
|
||||
"@tiptap/pm": "^2.6.6"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"packages/pm": {
|
||||
"name": "@tiptap/pm",
|
||||
"version": "2.6.6",
|
||||
|
1
packages/core/jsx-runtime/index.cjs
Normal file
1
packages/core/jsx-runtime/index.cjs
Normal file
@ -0,0 +1 @@
|
||||
export * from '../dist/index.cjs'
|
17
packages/core/jsx-runtime/index.d.ts
vendored
Normal file
17
packages/core/jsx-runtime/index.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
export type * from '../dist/packages/core/src/jsx-runtime.d.ts'
|
||||
|
||||
declare namespace React {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[elemName: string]: any
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[elemName: string]: any
|
||||
}
|
||||
}
|
||||
}
|
1
packages/core/jsx-runtime/index.js
Normal file
1
packages/core/jsx-runtime/index.js
Normal file
@ -0,0 +1 @@
|
||||
export * from '../dist/index.js'
|
@ -21,6 +21,18 @@
|
||||
"types": "./dist/packages/core/src/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"types": "./jsx-runtime/index.d.ts",
|
||||
"browser": "./jsx-runtime/index.js",
|
||||
"import": "./jsx-runtime/index.js",
|
||||
"require": "./jsx-runtime/index.cjs"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"types": "./jsx-runtime/index.d.ts",
|
||||
"browser": "./jsx-runtime/index.js",
|
||||
"import": "./jsx-runtime/index.js",
|
||||
"require": "./jsx-runtime/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
@ -29,7 +41,8 @@
|
||||
"types": "dist/packages/core/src/index.d.ts",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
"dist",
|
||||
"jsx-runtime"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@tiptap/pm": "^2.6.6"
|
||||
|
@ -5,6 +5,11 @@ export * as extensions from './extensions/index.js'
|
||||
export * from './helpers/index.js'
|
||||
export * from './InputRule.js'
|
||||
export * from './inputRules/index.js'
|
||||
export {
|
||||
createElement,
|
||||
Fragment,
|
||||
createElement as h,
|
||||
} from './jsx-runtime.js'
|
||||
export * from './Mark.js'
|
||||
export * from './Node.js'
|
||||
export * from './NodePos.js'
|
||||
|
@ -13,41 +13,17 @@ export type DOMOutputSpecArray =
|
||||
| [string, Attributes, DOMOutputSpecArray | 0]
|
||||
| [string, DOMOutputSpecArray];
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace JSX {
|
||||
// @ts-ignore - conflict with React typings
|
||||
type Element = [string, ...any[]]
|
||||
interface IntrinsicElements {
|
||||
// @ts-ignore - conflict with React typings
|
||||
[key: string]: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type JSXRenderer = (
|
||||
tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement),
|
||||
props?: Attributes,
|
||||
...children: JSXRenderer[]
|
||||
) => DOMOutputSpecArray | DOMOutputSpecElement;
|
||||
|
||||
/**
|
||||
* The JSX pragma function for tiptap
|
||||
* It will render JSX to a format that Tiptap's `renderHTML` function can understand
|
||||
* @example A simple div element
|
||||
* ```tsx
|
||||
* renderHTML({ HTMLAttributes }) {
|
||||
* return <div {...HTMLAttributes}></div>;
|
||||
* }
|
||||
* ```
|
||||
* @example A div element that wraps it's children
|
||||
* ```tsx
|
||||
* renderHTML({ HTMLAttributes }) {
|
||||
* return <div {...HTMLAttributes}><slot /></div>;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export const jsxTiptap: JSXRenderer = (tag, attributes, ...children) => {
|
||||
export function Fragment(props: { children: JSXRenderer[] }) {
|
||||
return props.children
|
||||
}
|
||||
|
||||
export const h: JSXRenderer = (tag, attributes, ...children) => {
|
||||
// Treat the slot tag as the Prosemirror hole to render content into
|
||||
if (tag === 'slot') {
|
||||
return 0
|
||||
@ -62,4 +38,10 @@ export const jsxTiptap: JSXRenderer = (tag, attributes, ...children) => {
|
||||
return [tag, attributes ?? {}, ...children]
|
||||
}
|
||||
|
||||
export const children = 0
|
||||
// See
|
||||
// https://esbuild.github.io/api/#jsx-import-source
|
||||
// https://www.typescriptlang.org/tsconfig/#jsxImportSource
|
||||
|
||||
export {
|
||||
h as createElement, h as jsx, h as jsxDEV, h as jsxs,
|
||||
}
|
@ -1 +0,0 @@
|
||||
# Change Log
|
@ -1,18 +0,0 @@
|
||||
# @tiptap/static-renderer
|
||||
|
||||
[![Version](https://img.shields.io/npm/v/@tiptap/static-renderer.svg?label=version)](https://www.npmjs.com/package/@tiptap/static-renderer)
|
||||
[![Downloads](https://img.shields.io/npm/dm/@tiptap/static-renderer.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
|
||||
[![License](https://img.shields.io/npm/l/@tiptap/static-renderer.svg)](https://www.npmjs.com/package/@tiptap/static-renderer)
|
||||
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
|
||||
|
||||
## Introduction
|
||||
|
||||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
|
||||
|
||||
## Official Documentation
|
||||
|
||||
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
||||
|
||||
## License
|
||||
|
||||
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
@ -1,45 +0,0 @@
|
||||
{
|
||||
"name": "@tiptap/jsx",
|
||||
"description": "statically render Tiptap JSON",
|
||||
"version": "2.6.6",
|
||||
"homepage": "https://tiptap.dev",
|
||||
"keywords": [
|
||||
"tiptap",
|
||||
"tiptap static renderer",
|
||||
"tiptap react renderer"
|
||||
],
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/packages/jsx/src/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"umd": "dist/index.umd.js",
|
||||
"types": "dist/packages/jsx/src/index.d.ts",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.6.6",
|
||||
"@tiptap/pm": "^2.6.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ueberdosis/tiptap",
|
||||
"directory": "packages/jsx"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf dist",
|
||||
"build": "npm run clean && rollup -c"
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
import { baseConfig } from '@tiptap-shared/rollup-config'
|
||||
|
||||
import pkg from './package.json' assert { type: 'json' }
|
||||
|
||||
export default baseConfig({ input: 'src/index.ts', pkg })
|
Loading…
Reference in New Issue
Block a user