html-flip-book-react 0.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/flip-book.d.ts +14 -0
  2. package/dist/flip-book.d.ts.map +1 -0
  3. package/dist/flip-book.js +1410 -0
  4. package/dist/flip-book.js.map +1 -0
  5. package/example/.vscode/settings.json +3 -0
  6. package/example/README.md +47 -0
  7. package/example/assets/pages_data/en/assets/cover.jpg +0 -0
  8. package/example/assets/pages_data/en/assets/sql-command.png +0 -0
  9. package/example/assets/pages_data/en/content/000-introduction.md +85 -0
  10. package/example/assets/pages_data/en/content/001-databases.md +39 -0
  11. package/example/assets/pages_data/en/content/002-install-mysql.md +162 -0
  12. package/example/assets/pages_data/en/content/003-creating-tables.md +304 -0
  13. package/example/assets/pages_data/en/content/004-basic-syntax.md +145 -0
  14. package/example/assets/pages_data/en/content/005-select.md +359 -0
  15. package/example/assets/pages_data/en/content/006-where.md +225 -0
  16. package/example/assets/pages_data/en/content/007-order-and-group-by.md +142 -0
  17. package/example/assets/pages_data/en/content/008-insert.md +86 -0
  18. package/example/assets/pages_data/en/content/009-update.md +92 -0
  19. package/example/assets/pages_data/en/content/010-delete.md +28 -0
  20. package/example/assets/pages_data/en/content/011-join.md +297 -0
  21. package/example/assets/pages_data/en/content/012-sql-command-categories.md +121 -0
  22. package/example/assets/pages_data/en/content/013-sub-queries.md +112 -0
  23. package/example/assets/pages_data/en/content/014-unions.md +124 -0
  24. package/example/assets/pages_data/en/content/015-Keys-in-a-Relational Database.md +51 -0
  25. package/example/assets/pages_data/en/content/016-Logical-operator-keywords.md +17 -0
  26. package/example/assets/pages_data/en/content/017-having-clause_aggregate-functions.md +184 -0
  27. package/example/assets/pages_data/en/content/018-essential-mysql-functions.md +190 -0
  28. package/example/assets/pages_data/en/content/019-triggers-in-sql.md +133 -0
  29. package/example/assets/pages_data/en/content/020-TCL-commands.md +154 -0
  30. package/example/assets/pages_data/en/content/021-DCL-commands.md +126 -0
  31. package/example/assets/pages_data/en/content/100-mysqldump.md +109 -0
  32. package/example/assets/pages_data/en/content/101-learn-materialize.md +267 -0
  33. package/example/assets/pages_data/en/content/999-conclusion.md +24 -0
  34. package/example/assets/pages_data/he/4.txt +2 -0
  35. package/example/assets/pages_data/he/5.txt +4 -0
  36. package/example/assets/pages_data/he/6.txt +4 -0
  37. package/example/index.html +21 -0
  38. package/example/package-lock.json +5324 -0
  39. package/example/package.json +39 -0
  40. package/example/src/App.css +52 -0
  41. package/example/src/App.tsx +25 -0
  42. package/example/src/EnBook.tsx +55 -0
  43. package/example/src/HeBook.tsx +44 -0
  44. package/example/src/index.tsx +12 -0
  45. package/example/vite-env.d.ts +1 -0
  46. package/example/vite.config.js +84 -0
  47. package/package.json +45 -0
  48. package/src/FlipBook.tsx +45 -0
  49. package/vite.config.js +66 -0
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "html-flip-book-react-example",
3
+ "version": "1.0.0",
4
+ "description": "Flipbook component for HTML",
5
+ "homepage": "https://doradsoft.github.io/html-flip-book/",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": "^22.x.x"
9
+ },
10
+ "scripts": {
11
+ "dev": "vite",
12
+ "predeploy": "npm run build",
13
+ "deploy": "gh-pages -d dist -r https://github.com/doradsoft/html-flip-book.git",
14
+ "build": "vite build --mode development"
15
+ },
16
+ "author": "DoradSoft",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "html-flip-book-react": "file:../",
20
+ "react": "^18.3.1",
21
+ "react-dom": "^18.3.1",
22
+ "react-markdown": "^9.0.1"
23
+ },
24
+ "devDependencies": {
25
+ "@actions/core": "^1.10.1",
26
+ "@types/react": "^18.3.3",
27
+ "@types/react-dom": "^18.3.0",
28
+ "@vitejs/plugin-react-refresh": "^1.3.6",
29
+ "@vitejs/plugin-react-swc": "^3.7.0",
30
+ "react-refresh": "^0.14.2",
31
+ "rimraf": "^5.0.8",
32
+ "typescript": "^5.5.3",
33
+ "vite": "^5.3.3",
34
+ "vite-plugin-checker": "^0.7.1",
35
+ "vite-tsconfig-paths": "^4.3.2",
36
+ "vitest": "^1.6.0",
37
+ "gh-pages": "6.1.1"
38
+ }
39
+ }
@@ -0,0 +1,52 @@
1
+ html,
2
+ body {
3
+ margin: 0;
4
+ }
5
+
6
+ .app {
7
+ display: flex;
8
+ flex-direction: column;
9
+ height: 100vh;
10
+ }
11
+
12
+ header {
13
+ /* your styles */
14
+ flex-shrink: 0;
15
+ }
16
+
17
+ .books-container {
18
+ flex-grow: 1;
19
+ overflow: auto;
20
+ display: flex;
21
+ justify-content: space-between;
22
+ padding: 20px;
23
+ gap: 20px;
24
+ }
25
+
26
+ .he-book-container,
27
+ .en-book-container {
28
+ flex-basis: 50%;
29
+ box-sizing: border-box;
30
+ }
31
+
32
+ .he-book-container {
33
+ direction: rtl;
34
+ text-align: right;
35
+ }
36
+
37
+ .en-page,
38
+ .he-page {
39
+ background-color: white;
40
+ overflow-y: scroll;
41
+ overflow-x: hidden;
42
+ border: 1px solid #00000056;
43
+ padding: 2%;
44
+ }
45
+
46
+ .en-page img {
47
+ max-width: 100%;
48
+ }
49
+
50
+ .en-page * {
51
+ overflow: auto;
52
+ }
@@ -0,0 +1,25 @@
1
+ // App.tsx
2
+ import type { FC } from "react";
3
+ import "./App.css"; // Import the CSS file
4
+ import EnBook from "./EnBook";
5
+ import HeBook from "./HeBook";
6
+
7
+ export const App: FC = () => {
8
+ return (
9
+ <div className="app">
10
+ <header>
11
+ <h1>HTML Flip Book Example</h1>
12
+ </header>
13
+ <section className="books-container">
14
+ <section className="en-book-container">
15
+ <EnBook />
16
+ </section>
17
+ <section className="he-book-container">
18
+ <HeBook />
19
+ </section>
20
+ </section>
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default App;
@@ -0,0 +1,55 @@
1
+ // EnBook.tsx
2
+ import { useEffect, useState } from 'react'
3
+ import { FlipBook } from 'html-flip-book-react'
4
+ import Markdown from 'react-markdown'
5
+
6
+ const markdownFiles = import.meta.glob('/assets/pages_data/en/content/*.md')
7
+
8
+ interface MarkdownModule {
9
+ default: string
10
+ }
11
+
12
+ export const EnBook = () => {
13
+ const [enPages, setEnPages] = useState<JSX.Element[]>([])
14
+
15
+ useEffect(() => {
16
+ const loadMarkdownFiles = async () => {
17
+ const files = await Promise.all(
18
+ Object.entries(markdownFiles).map(async ([path, resolver]) => {
19
+ const content = await resolver()
20
+ assertIsMarkdownModule(content)
21
+ return {
22
+ path,
23
+ content: content.default
24
+ }
25
+ })
26
+ )
27
+ const pages = files
28
+ // To avoid having an empty page at the end
29
+ .concat([{ path: '', content: '' }])
30
+ .map(({ content }, index) => (
31
+ <div key={index} className="en-page">
32
+ <Markdown>{content}</Markdown>
33
+ </div>
34
+ ))
35
+
36
+ setEnPages(pages)
37
+ }
38
+
39
+ loadMarkdownFiles()
40
+ }, [])
41
+
42
+ function assertIsMarkdownModule(
43
+ module: unknown
44
+ ): asserts module is MarkdownModule {
45
+ if (typeof (module as MarkdownModule).default !== 'string') {
46
+ throw new Error('Invalid markdown module')
47
+ }
48
+ }
49
+
50
+ return enPages.length ? (
51
+ <FlipBook className="en-book" pages={enPages} debug={true} />
52
+ ) : null
53
+ }
54
+
55
+ export default EnBook
@@ -0,0 +1,44 @@
1
+ // HeBook.tsx
2
+ import { FlipBook, PageSemantics } from 'html-flip-book-react'
3
+
4
+ const hePages = Array.from({ length: 10 }, (_, index) => (
5
+ <div key={index}>
6
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
7
+ </div>
8
+ ))
9
+
10
+ const hePageSemanticsDict: Record<number, string> = {
11
+ 4: 'א',
12
+ 5: 'ב',
13
+ 6: 'ג'
14
+ }
15
+
16
+ const hePageSemantics: PageSemantics = {
17
+ indexToSemanticName(pageIndex: number): string {
18
+ return hePageSemanticsDict[pageIndex] ?? ''
19
+ },
20
+ semanticNameToIndex(semanticPageName: string): number | null {
21
+ const entry = Object.entries(hePageSemanticsDict).find(
22
+ ([, value]) => value === semanticPageName
23
+ )
24
+ return entry ? parseInt(entry[0]) : null
25
+ },
26
+ indexToTitle(pageIndex: number): string {
27
+ const chapter = hePageSemanticsDict[pageIndex]
28
+ return chapter ? `פרק ${chapter}` : ''
29
+ }
30
+ }
31
+
32
+ export const HeBook = () => {
33
+ return (
34
+ <FlipBook
35
+ className="he-book"
36
+ pages={hePages}
37
+ pageSemantics={hePageSemantics}
38
+ debug={true}
39
+ direction="rtl"
40
+ />
41
+ )
42
+ }
43
+
44
+ export default HeBook
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import * as ReactDOM from 'react-dom/client';
3
+ import { App } from './App';
4
+
5
+ const root = ReactDOM.createRoot(
6
+ document.getElementById('root') as HTMLElement,
7
+ );
8
+ root.render(
9
+ <React.StrictMode>
10
+ <App />
11
+ </React.StrictMode>,
12
+ );
@@ -0,0 +1 @@
1
+ declare module "*.md";
@@ -0,0 +1,84 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import reactRefresh from '@vitejs/plugin-react-refresh'
4
+ import react from '@vitejs/plugin-react-swc'
5
+ import { defineConfig } from 'vite'
6
+ import checker from 'vite-plugin-checker'
7
+ import tsconfigPaths from 'vite-tsconfig-paths'
8
+ import packageJson from './package.json'
9
+
10
+ export default defineConfig(({ mode }) => {
11
+ const isProd = mode === 'production'
12
+ return {
13
+ mode,
14
+ assetsInclude: ['**/*.md'],
15
+ base: '',
16
+ build: {
17
+ sourcemap: !isProd,
18
+ emptyOutDir: true,
19
+ rollupOptions: {
20
+ external: ['react', 'react-dom'],
21
+ makeAbsoluteExternalsRelative: true
22
+ },
23
+ terserOptions: {
24
+ module: true,
25
+ output: {
26
+ comments: () => false
27
+ },
28
+ compress: {
29
+ drop_console: true
30
+ }
31
+ }
32
+ },
33
+ esbuild: { legalComments: 'none' },
34
+ server: {
35
+ open: true
36
+ },
37
+ plugins: [
38
+ react(),
39
+ {
40
+ name: 'markdown-loader',
41
+ transform (_export, id) {
42
+ if (id.endsWith('.md')) {
43
+ const mdContent = fs.readFileSync(id, 'utf-8')
44
+ return {
45
+ code: `export default ${JSON.stringify(mdContent)}`,
46
+ map: null // provide source map if available
47
+ }
48
+ }
49
+ }
50
+ },
51
+ reactRefresh(),
52
+ tsconfigPaths(),
53
+ checker({
54
+ typescript: true
55
+ }),
56
+ {
57
+ name: 'update-esm-package-props',
58
+ generateBundle: (options, bundle) => {
59
+ if (isProd) {
60
+ for (const fileName in bundle) {
61
+ if (fileName.startsWith('index-')) {
62
+ fs.writeFile(
63
+ path.resolve(__dirname, './package.json'),
64
+ JSON.stringify(
65
+ { ...packageJson, main: `dist/${fileName}` },
66
+ null,
67
+ 2
68
+ ),
69
+ err => {
70
+ if (err) throw err
71
+ console.log(
72
+ '\x1b[36m%s\x1b[0m',
73
+ '\nPackage ESM main entrypoint updated!\n\r'
74
+ )
75
+ }
76
+ )
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ })
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "html-flip-book-react",
3
+ "description": "Flip Book React Component",
4
+ "version": "0.0.0-alpha.1",
5
+ "type": "module",
6
+ "author": "DoradSoft",
7
+ "main": "./dist/flip-book.js",
8
+ "types": "./dist/flip-book.d.ts",
9
+ "homepage": "https://github.com/doradsoft/html-flip-book",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/doradsoft/html-flip-book.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/doradsoft/html-flip-book/issues"
16
+ },
17
+ "keywords": [
18
+ "book",
19
+ "flip-book",
20
+ "react"
21
+ ],
22
+ "license": "MIT",
23
+ "scripts": {
24
+ "build": "vite build"
25
+ },
26
+ "dependencies": {
27
+ "react": "^18.3.1",
28
+ "react-dom": "^18.3.1"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^18.3.3",
32
+ "@types/react-dom": "^18.3.0",
33
+ "@vitejs/plugin-react-refresh": "^1.3.6",
34
+ "@vitejs/plugin-react-swc": "^3.7.0",
35
+ "html-flip-book-base": "file:../base",
36
+ "react-refresh": "^0.14.2",
37
+ "typescript": "^5.5.3",
38
+ "typescript-eslint": "^8.0.0-alpha.14",
39
+ "vite": "^5.3.3",
40
+ "vite-plugin-checker": "^0.7.1",
41
+ "vite-plugin-dts": "^3.9.1",
42
+ "vite-tsconfig-paths": "^4.3.2",
43
+ "vitest": "^1.6.0"
44
+ }
45
+ }
@@ -0,0 +1,45 @@
1
+ import React, { useEffect, useRef } from 'react'
2
+ import { FlipBook as FlipBookBase, PageSemantics } from 'html-flip-book-base'
3
+
4
+ interface FlipBookWrapperProps {
5
+ pages: React.ReactNode[]
6
+ className: string
7
+ pageSemantics?: PageSemantics
8
+ debug?: boolean
9
+ direction?: 'rtl' | 'ltr' // Add the direction property to the interface
10
+ // Add any other props that the wrapper might need
11
+ }
12
+
13
+ const FlipBookReact: React.FC<FlipBookWrapperProps> = ({
14
+ pages,
15
+ className,
16
+ debug = false,
17
+ direction = 'ltr', // Add the direction prop
18
+ pageSemantics = undefined
19
+ }) => {
20
+ const flipBook = useRef(
21
+ new FlipBookBase({
22
+ pageSemantics: pageSemantics,
23
+ pagesCount: pages.length,
24
+ direction: direction
25
+ })
26
+ )
27
+
28
+ useEffect(() => {
29
+ flipBook.current.render(`.${className}`, debug)
30
+ // Do any other necessary setup here
31
+ }, [])
32
+
33
+ return (
34
+ <div className={className}>
35
+ {pages.map((page, index) => (
36
+ <div key={index} className="page">
37
+ {page}
38
+ </div>
39
+ ))}
40
+ </div>
41
+ )
42
+ }
43
+
44
+ export { FlipBookReact as FlipBook }
45
+ export type { PageSemantics }
package/vite.config.js ADDED
@@ -0,0 +1,66 @@
1
+ import reactRefresh from '@vitejs/plugin-react-refresh'
2
+ import react from '@vitejs/plugin-react-swc'
3
+ import { defineConfig } from 'vite'
4
+ import checker from 'vite-plugin-checker'
5
+ import tsconfigPaths from 'vite-tsconfig-paths'
6
+ import dts from 'vite-plugin-dts'
7
+ import fs from 'fs'
8
+ import path from 'path'
9
+
10
+ export default defineConfig(({ mode }) => {
11
+ return {
12
+ mode,
13
+ base: '',
14
+ build: {
15
+ sourcemap: true,
16
+ emptyOutDir: true,
17
+ lib: {
18
+ entry: 'src/FlipBook.tsx',
19
+ formats: ['es'],
20
+ fileName: 'flip-book'
21
+ },
22
+ rollupOptions: {
23
+ external: ['react', 'react-dom'],
24
+ makeAbsoluteExternalsRelative: true
25
+ },
26
+ terserOptions: {
27
+ module: true,
28
+ output: {
29
+ comments: () => false
30
+ },
31
+ compress: {
32
+ drop_console: true
33
+ }
34
+ }
35
+ },
36
+ esbuild: { legalComments: 'none' },
37
+ plugins: [
38
+ react(),
39
+ reactRefresh(),
40
+ tsconfigPaths(),
41
+ checker({
42
+ typescript: true
43
+ }),
44
+ dts({
45
+ afterBuild: emittedFiles => {
46
+ emittedFiles.forEach((content, filePath) => {
47
+ if (filePath.includes('FlipBook')) {
48
+ const newFilePath = filePath.replace(/FlipBook/g, 'flip-book')
49
+ const newDir = path.dirname(newFilePath)
50
+
51
+ // Ensure the directory exists
52
+ if (!fs.existsSync(newDir)) {
53
+ fs.mkdirSync(newDir, { recursive: true })
54
+ }
55
+
56
+ fs.renameSync(filePath, newFilePath)
57
+ fs.writeFileSync(newFilePath, content)
58
+ console.log(`Renamed ${filePath} to ${newFilePath}`)
59
+ }
60
+ })
61
+ }
62
+ })
63
+ ]
64
+ }
65
+ })
66
+