Skip to content

Commit aa46105

Browse files
committed
citation update
1 parent c4563aa commit aa46105

File tree

16 files changed

+366
-374
lines changed

16 files changed

+366
-374
lines changed

bun.lockb

210 KB
Binary file not shown.

index.php

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
<?php
2-

package.json

+58-56
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
11
{
2-
"private": true,
3-
"type": "module",
4-
"scripts": {
5-
"build": "tsc && vite build",
6-
"dev": "vite",
7-
"lint": "eslint resources/js --ext .js,.jsx,.ts,.tsx --ignore-path .gitignore --fix"
8-
},
9-
"devDependencies": {
10-
"@headlessui/react": "^2.0.0",
11-
"@inertiajs/react": "^2.0.0",
12-
"@tailwindcss/forms": "^0.5.3",
13-
"@tailwindcss/vite": "^4.0.17",
14-
"@types/node": "^18.13.0",
15-
"@types/react": "^18.0.28",
16-
"@types/react-dom": "^18.0.10",
17-
"@typescript-eslint/eslint-plugin": "^7.16.0",
18-
"@typescript-eslint/parser": "^7.16.0",
19-
"@vitejs/plugin-react": "^4.2.0",
20-
"autoprefixer": "^10.4.12",
21-
"axios": "^1.7.4",
22-
"concurrently": "^9.0.1",
23-
"eslint": "^8.57.0",
24-
"eslint-config-prettier": "^9.1.0",
25-
"eslint-plugin-prettier": "^5.1.3",
26-
"eslint-plugin-react": "^7.34.4",
27-
"eslint-plugin-react-hooks": "^4.6.2",
28-
"laravel-vite-plugin": "^1.2.0",
29-
"prettier": "^3.3.0",
30-
"prettier-plugin-organize-imports": "^4.0.0",
31-
"prettier-plugin-tailwindcss": "^0.6.5",
32-
"react": "^18.2.0",
33-
"react-dom": "^18.2.0",
34-
"typescript": "^5.0.2",
35-
"vite": "^6.0.11"
36-
},
37-
"dependencies": {
38-
"@tiptap/extension-dropcursor": "^2.11.5",
39-
"@tiptap/extension-image": "^2.11.5",
40-
"@tiptap/extension-strike": "^2.11.5",
41-
"@tiptap/extension-table": "^2.11.5",
42-
"@tiptap/extension-table-cell": "^2.11.5",
43-
"@tiptap/extension-table-header": "^2.11.5",
44-
"@tiptap/extension-table-row": "^2.11.5",
45-
"@tiptap/extension-text": "^2.11.3",
46-
"@tiptap/extension-underline": "^2.11.5",
47-
"@tiptap/pm": "^2.11.5",
48-
"@tiptap/react": "^2.11.5",
49-
"@tiptap/starter-kit": "^2.11.5",
50-
"@tiptap/suggestion": "^2.11.5",
51-
"bibtex.js": "^0.0.12-beta",
52-
"prosemirror-tables": "^1.6.4",
53-
"puppeteer": "^24.4.0",
54-
"react-hot-toast": "^2.5.2",
55-
"tailwindcss": "^4.0.17",
56-
"tiptap-pagination-breaks": "^1.0.3"
57-
}
2+
"private": true,
3+
"type": "module",
4+
"scripts": {
5+
"build": "tsc && vite build",
6+
"dev": "vite",
7+
"lint": "eslint resources/js --ext .js,.jsx,.ts,.tsx --ignore-path .gitignore --fix"
8+
},
9+
"devDependencies": {
10+
"@headlessui/react": "^2.0.0",
11+
"@inertiajs/react": "^2.0.0",
12+
"@tailwindcss/forms": "^0.5.3",
13+
"@tailwindcss/vite": "^4.0.17",
14+
"@types/node": "^18.13.0",
15+
"@types/react": "^18.0.28",
16+
"@types/react-dom": "^18.0.10",
17+
"@typescript-eslint/eslint-plugin": "^7.16.0",
18+
"@typescript-eslint/parser": "^7.16.0",
19+
"@vitejs/plugin-react": "^4.2.0",
20+
"autoprefixer": "^10.4.12",
21+
"axios": "^1.7.4",
22+
"concurrently": "^9.0.1",
23+
"eslint": "^8.57.0",
24+
"eslint-config-prettier": "^9.1.0",
25+
"eslint-plugin-prettier": "^5.1.3",
26+
"eslint-plugin-react": "^7.34.4",
27+
"eslint-plugin-react-hooks": "^4.6.2",
28+
"laravel-vite-plugin": "^1.2.0",
29+
"prettier": "^3.3.0",
30+
"prettier-plugin-organize-imports": "^4.0.0",
31+
"prettier-plugin-tailwindcss": "^0.6.5",
32+
"react": "^18.2.0",
33+
"react-dom": "^18.2.0",
34+
"typescript": "^5.0.2",
35+
"vite": "^6.0.11"
36+
},
37+
"dependencies": {
38+
"@tiptap/extension-dropcursor": "^2.11.5",
39+
"@tiptap/extension-image": "^2.11.5",
40+
"@tiptap/extension-strike": "^2.11.5",
41+
"@tiptap/extension-table": "^2.11.5",
42+
"@tiptap/extension-table-cell": "^2.11.5",
43+
"@tiptap/extension-table-header": "^2.11.5",
44+
"@tiptap/extension-table-row": "^2.11.5",
45+
"@tiptap/extension-text": "^2.11.3",
46+
"@tiptap/extension-underline": "^2.11.5",
47+
"@tiptap/pm": "^2.11.5",
48+
"@tiptap/react": "^2.11.5",
49+
"@tiptap/starter-kit": "^2.11.5",
50+
"@tiptap/suggestion": "^2.11.5",
51+
"bibtex.js": "^0.0.14-beta",
52+
"katex": "^0.16.21",
53+
"prosemirror-pagination": "^0.1.5",
54+
"prosemirror-tables": "^1.6.4",
55+
"puppeteer": "^24.4.0",
56+
"react-hot-toast": "^2.5.2",
57+
"tailwindcss": "^4.0.17",
58+
"tiptap-pagination-breaks": "^1.0.3"
59+
}
5860
}

resources/js/Components/Citation.tsx

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
import { CiteManager } from "bibtex.js"
1+
import { CiteManager, CiteUtils } from "bibtex.js"
22
import { Editor } from "@tiptap/react";
3+
import { useContext } from "react";
4+
import { MainContext } from "@/Context/MainContext";
5+
import Dropdown from "./Dropdown";
36

4-
type CitationProps = { editor: Editor };
5-
const Citation: React.FC<CitationProps> = ({ editor }) => {
7+
8+
const Citation: React.FC = () => {
9+
10+
const ctx = useContext(MainContext)
611
const cites = CiteManager.getAll();
7-
return (<div>
12+
return (<div className="p-5">
13+
814

9-
{cites.map((c, i) => {
10-
return <div key={i}>
11-
<button onClick={() => editor.chain().insertContent(`<cite cite="${c.id}"></cite>`).run()}>{c.id}</button>
12-
</div>
15+
{cites && cites.map((c, i) => {
16+
const cite = new CiteUtils(c)
17+
return <Dropdown key={i}>
18+
<Dropdown.Trigger >
19+
<div className="text-sm border border-transparent py-2 border-b-slate-300">
20+
<div className="truncate w-11/12">{cite.getTitle()}</div>
21+
{/* <p>{cite.formatAuthorname()},{c.data.year}</p> */}
22+
</div>
23+
</Dropdown.Trigger>
24+
<Dropdown.Content width="36" align="right">
25+
<div className="px-5">
26+
<button className="truncate text-sm w-full flex flex-col items-start" onClick={() => ctx?.editor?.chain().insertContent(`<cite cite="${c.id}"></cite>`).run()}>
27+
add
28+
</button>
29+
<button className="truncate text-sm w-full flex flex-col items-start" onClick={() => ctx?.editor?.chain().insertContent(`<cite cite="${c.id}" citeA="true"></cite>`).run()}>
30+
add as citeA
31+
</button>
32+
</div>
33+
</Dropdown.Content>
34+
</Dropdown>
1335
})}
1436
</div>)
1537

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Citation from "./Citation"
2+
3+
4+
5+
6+
7+
export const CitationSettings:React.FC = () => {
8+
9+
10+
return (<div>
11+
12+
13+
<Citation></Citation>
14+
</div>)
15+
}

resources/js/Components/Sidebar.tsx

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { useContext } from "react";
22
import ImageList from "./ImageList";
33
import TableSetting from "./TableSettings";
44
import { MainContext } from "@/Context/MainContext";
5+
import { CitationSettings } from "./CitationSettings";
56

67
export type SideBarProps = {
7-
el?: "images" | "table";
8+
el?: "images" | "table" | "citation" | "math";
89
props?: Record<any, any>;
910
};
1011

@@ -14,6 +15,7 @@ export default function Sidebar() {
1415
const child: Record<string, React.ComponentType<any>> = {
1516
table: TableSetting,
1617
images: ImageList,
18+
citation: CitationSettings
1719
};
1820

1921
const Component = ctx?.sidebar.el ? child[ctx.sidebar.el] : null;
@@ -27,14 +29,11 @@ export default function Sidebar() {
2729
${ctx?.sidebar.el ? "translate-x-0 opacity-100" : "-translate-x-full opacity-0"}`}
2830
>
2931
<div style={{ scrollbarWidth: "none", msOverflowStyle: 'none' }} className="border-b rounded-lg p-2 text-sm border-slate-100 flex overflow-x-scroll space-x-1" >
30-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer" onClick={()=>ctx?.setSidebar({el:'table'})}>Table</button>
31-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer" onClick={()=>ctx?.setSidebar({el:'images'})}>Image</button>
32-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
33-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
34-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
35-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
36-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
37-
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Others</button>
32+
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer" onClick={() => ctx?.setSidebar({ el: 'table' })}>Table</button>
33+
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer" onClick={() => ctx?.setSidebar({ el: 'images' })}>Image</button>
34+
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer" onClick={() => ctx?.setSidebar({ el: "citation" })}>Citation</button>
35+
<button className="p-1 rounded-md px-2 bg-slate-100 cursor-pointer">Math</button>
36+
3837
</div>
3938
{Component && <Component {...ctx?.sidebar.props} />}
4039
</div>

resources/js/Components/TableSettings.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ const TableSetting: React.FC = () => {
4444
editor?.chain().focus().setCellAlignmentCenter().run()
4545
}} className="disabled:opacity-50 text-xs text-center px-2 py-0.5 bg-red-700 rounded-md text-white" >Center</button>
4646
</div>
47-
<div className="flex justify-center px-0.5 py-0.5">
48-
49-
<button
50-
onClick={() => editor?.chain().focus().setCellAlignmentRight().run()}
51-
className="disabled:opacity-50 text-xs text-center px-2 py-0.5 bg-blue-800 rounded-md text-white" >Right</button>
52-
</div>
5347

5448
</div>
5549
</div>

resources/js/Components/Toolbar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const Toolbar: React.FC<ToolbarProps> = ({ editor, documentData, chapter, mytest
8484
</svg>
8585
</p>
8686
</Dropdown.Trigger>
87-
<Dropdown.Content align="right">
87+
<Dropdown.Content align="right" width="56">
8888
<div className="p-2 flex flex-col space-y-1">
8989
<Link className={`${chapter == 'Bab 1' ? 'bg-green-700 text-white hover:bg-green-800' : 'hover:bg-slate-100'} p-1 px-1.5 text-sm rounded-md`} href={`/document/${documentData.id}/bab1`} >Bab 1</Link>
9090
<Link className={`${chapter == 'Bab 2' ? 'bg-green-700 text-white hover:bg-green-800' : 'hover:bg-slate-100'} p-1 px-1.5 text-sm rounded-md`} href={`/document/${documentData.id}/bab2`}>Bab 2</Link>

resources/js/Pages/Document/DocumentEditor.tsx

+45-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import { Image } from "@/Tiptap/Extenstions/Image"
2222
import { SaveOnLoad } from "@/Utilities/Save"
2323
import { CellMenu, DefaultMenu, ImageMenu } from "@/Components/Menu"
2424
import { DeleteContent } from "@/Components/DeleteContent"
25-
import Dropcursor from "@tiptap/extension-dropcursor"
25+
import Modal from "@/Components/Modal"
26+
import PrimaryButton from "@/Components/PrimaryButton"
27+
import DangerButton from "@/Components/DangerButton"
28+
import { Pagination } from "@/Tiptap/Extenstions/Pagination"
29+
import { CiteLocalStorage, CiteManager } from "bibtex.js"
30+
// import {} from "prosemirror-pagination"
2631

2732

2833

@@ -44,18 +49,29 @@ const DocumentEditor: React.FC = () => {
4449
Image,
4550
Caption,
4651
FloatingMenu,
47-
Dropcursor,
4852
columnResizing as any,
53+
Pagination.configure({
54+
pageHeight: 29.7,
55+
})
4956

50-
]
5157

58+
]
59+
CiteManager.init(new CiteLocalStorage(`@book{butti2023high,
60+
title={High Performance with Laravel Octane: Learn to fine-tune and optimize PHP and Laravel apps using Octane and an asynchronous approach},
61+
author={Butti, Roberto},
62+
year={2023},
63+
publisher={Packt Publishing Ltd}
64+
}`));
5265

5366
const content = props.content.contents
5467

5568
const schema = {
5669
type: "doc",
5770
content: content
5871
}
72+
73+
74+
const [confirmUnsave, setConfirmUnsave] = useState<boolean>(false);
5975
const [sidebar, setSidebar] = useState<SideBarProps>({
6076
el: "table",
6177

@@ -76,6 +92,9 @@ const DocumentEditor: React.FC = () => {
7692

7793
},
7894
onCreate: async ({ editor }) => {
95+
if (localStorage.getItem('document-cache')) {
96+
setConfirmUnsave(true)
97+
}
7998

8099
const response = await SaveOnLoad(props)
81100
if (response && response.ok) {
@@ -90,7 +109,8 @@ const DocumentEditor: React.FC = () => {
90109
} catch (error) {
91110
console.error("Update Error:", error);
92111
}
93-
}
112+
},
113+
94114

95115
})
96116

@@ -120,6 +140,27 @@ const DocumentEditor: React.FC = () => {
120140

121141
</style>
122142
</Head>}
143+
<Modal show={confirmUnsave} maxWidth="xl">
144+
145+
<div className="bg-white rounded-lg shadow-lg overflow-hidden">
146+
<div className="flex justify-between p-4">
147+
<p className="font-semibold text-xl">Found Unsaved Document {props.content.name} </p>
148+
<button
149+
onClick={() => setConfirmUnsave(false)}
150+
className="text-gray-500 cursor-pointer hover:text-gray-700 transition"
151+
>
152+
153+
</button>
154+
</div>
155+
<div className="p-5">
156+
<p>We found unsaved document for {props.content.name} do you wanna save it?</p>
157+
</div>
158+
<div className="flex justify-end p-5 space-x-4">
159+
<PrimaryButton>Save</PrimaryButton>
160+
<DangerButton onClick={() => setConfirmUnsave(false)}>Discard</DangerButton>
161+
</div>
162+
</div>
163+
</Modal>
123164
<Toolbar editor={editor} mytest={handleprint} documentData={props.document} chapter={props.chapter} />
124165
<Sidebar />
125166
<div className="flex justify-center h-full w-full space-x-2 pt-36" id="container" >

0 commit comments

Comments
 (0)