Skip to content
Draft
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
1 change: 0 additions & 1 deletion example/react-example/.env

This file was deleted.

24 changes: 24 additions & 0 deletions example/react-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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?
94 changes: 42 additions & 52 deletions example/react-example/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
# Getting Started with Create React App
# React Example - @turbodocx/html-to-docx

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
Modern React example demonstrating how to use @turbodocx/html-to-docx in a browser environment with Vite.

## Available Scripts
## Features

In the project directory, you can run:
- ⚡️ **Vite** - Fast development with instant HMR
- ⚛️ **React 19** - Latest React features
- 🎨 **Modern UI** - Clean, responsive design
- 📝 **Live Editor** - Edit HTML and generate DOCX in real-time
- 🚀 **No polyfills needed** - Works directly in modern browsers

### `yarn start`
## Quick Start

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
```bash
npm install
npm run dev
```

The page will reload if you make edits.\
You will also see any lint errors in the console.
Then open [http://localhost:5173](http://localhost:5173) in your browser.

### `yarn test`
## Usage

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
The example demonstrates:

### `yarn build`
- Converting HTML to DOCX in the browser
- Using the file-saver library to download generated files
- Handling various HTML elements (headings, lists, tables, images, etc.)
- Styling with custom fonts and colors
- Configuring options like page numbers and table settings

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
## Code Example

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
```jsx
import HTMLtoDOCX from '@turbodocx/html-to-docx';
import { saveAs } from 'file-saver';

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
async function generateDocument() {
const fileBuffer = await HTMLtoDOCX(html, null, {
table: { row: { cantSplit: true } },
footer: true,
pageNumber: true,
});

### `yarn eject`
saveAs(fileBuffer, 'document.docx');
}
```

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
## Build for Production

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
```bash
npm run build
npm run preview
```

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
- [@turbodocx/html-to-docx Documentation](https://www.turbodocx.com)
- [Vite Documentation](https://vite.dev)
- [React Documentation](https://react.dev)
29 changes: 29 additions & 0 deletions example/react-example/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{js,jsx}'],
extends: [
js.configs.recommended,
reactHooks.configs['recommended-latest'],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
},
},
])
13 changes: 13 additions & 0 deletions example/react-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-example</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading