Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
presets: [
"@babel/preset-env",
"@babel/preset-react",
Expand Down
11 changes: 6 additions & 5 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
testEnvironment: "jsdom",
setupFilesAfterEnv: [
'<rootDir>/jest.setup.ts',
],
import type { Config } from 'jest';

const config: Config = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};

export default config;
3 changes: 2 additions & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import '@testing-library/jest-dom/extend-expect';
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';
12,913 changes: 4,974 additions & 7,939 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@troop.com/tiptap-react-render",
"version": "0.0.2",
"version": "0.0.3",
"description": "Render TipTap JSON in React without the editor!",
"scripts": {
"rollup": "rollup -c",
Expand All @@ -9,28 +9,28 @@
"author": "troop.com",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.5.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@types/jest": "^29.4.0",
"@types/react": "^17.0.53",
"babel-jest": "^29.5.0",
"jest": "^29.5.0",
"jest-dom": "^4.0.0",
"jest-environment-jsdom": "^29.5.0",
"react": "^17.0.2",
"rollup": "^2.79.1",
"rollup-plugin-dts": "^4.2.3",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^4.9.5"
"@babel/core": "^7.26.9",
"@babel/preset-env": "^7.26.9",
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-typescript": "^11.1.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"@types/jest": "^29.5.14",
"@types/react": "^19.0.10",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"react": "^19.0.0",
"rollup": "^4.34.8",
"rollup-plugin-dts": "^6.1.1",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "^5.7.3"
},
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"files": [
Expand Down
10 changes: 8 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, resolve as pathResolve } from 'path';
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";

const packageJson = require("./package.json");
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const packageJson = JSON.parse(readFileSync(pathResolve(__dirname, 'package.json'), 'utf8'));

export default [
{
Expand All @@ -27,7 +33,7 @@ export default [
],
},
{
input: "dist/esm/index.d.ts",
input: "dist/esm/types/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "esm" }],
plugins: [dts()],
},
Expand Down
4 changes: 4 additions & 0 deletions src/tip-tap-render.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @jest-environment jsdom
*/

import React from "react";
import { render } from "@testing-library/react";
import {
Expand Down
6 changes: 3 additions & 3 deletions src/tip-tap-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import React from 'react';
* @param {NodeHandlers} handlers a handler for each node type
* @returns tree of components as react elements
*/
export function TipTapRender(props: {node: TipTapNode, handlers: NodeHandlers}): JSX.Element {
export function TipTapRender(props: {node: TipTapNode, handlers: NodeHandlers}): React.JSX.Element {
const {node, handlers: mapping} = props;
// recursively render child content
const children: JSX.Element[] = [];
const children: React.JSX.Element[] = [];
node.content && node.content.forEach((child, ix) => {
children.push(
<TipTapRender
Expand Down Expand Up @@ -46,7 +46,7 @@ export interface NodeProps {
node: TipTapNode;
}

export type NodeHandler = (props: NodeProps) => JSX.Element
export type NodeHandler = (props: NodeProps) => React.JSX.Element

export interface NodeHandlers {
readonly [attr: string]: NodeHandler
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Added
"rootDir": "src",
"declarationMap": true,
"jsx": "react",
"jsx": "react-jsx",
"module": "ESNext",
"declaration": true,
"declarationDir": "types",
Expand All @@ -19,5 +19,7 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"emitDeclarationOnly": true,
}

"types": ["@testing-library/jest-dom"],
},
}