diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..6165333 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +NEXT_PUBLIC_API_ENDPOINT = https://api.tpet.aws-educate.tw/dev diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..5251382 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +NEXT_PUBLIC_API_ENDPOINT = https://api.tpet.aws-educate.tw/prod diff --git a/package-lock.json b/package-lock.json index 3c1e89c..6ddde8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,14 @@ "version": "0.1.0", "dependencies": { "@heroicons/react": "^2.1.3", + "@tiptap/extension-bullet-list": "^2.4.0", + "@tiptap/extension-image": "^2.4.0", + "@tiptap/extension-link": "^2.4.0", + "@tiptap/extension-list-item": "^2.4.0", + "@tiptap/extension-underline": "^2.4.0", + "@tiptap/pm": "^2.4.0", + "@tiptap/react": "^2.4.0", + "@tiptap/starter-kit": "^2.4.0", "@types/draft-js": "^0.11.18", "draft-js": "^0.11.7", "draft-js-export-html": "^1.4.1", @@ -16,12 +24,16 @@ "flowbite": "^2.3.0", "flowbite-react": "^0.9.0", "formidable": "^3.5.1", + "lucide-react": "^0.395.0", "next": "14.2.3", "react": "^18", "react-dom": "^18", + "sass": "^1.77.5", + "tiptap-extension-resize-image": "^1.1.7", "zod": "^3.23.4" }, "devDependencies": { + "@tailwindcss/typography": "^0.5.13", "@types/formidable": "^3.4.5", "@types/node": "^20", "@types/react": "^18", @@ -492,6 +504,11 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@remirror/core-constants": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@remirror/core-constants/-/core-constants-2.0.2.tgz", + "integrity": "sha512-dyHY+sMF0ihPus3O27ODd4+agdHMEmuRdyiZJ2CCWjPV5UFmn17ZbElvk6WOGVE4rdCJKZQCrPV2BcikOMLUGQ==" + }, "node_modules/@rushstack/eslint-patch": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.10.2.tgz", @@ -512,6 +529,417 @@ "tslib": "^2.4.0" } }, + "node_modules/@tailwindcss/typography": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.13.tgz", + "integrity": "sha512-ADGcJ8dX21dVVHIwTRgzrcunY6YY9uSlAHHGVKvkA+vLc5qLwEszvKts40lx7z0qc4clpjclwLeK5rVCV2P/uw==", + "dev": true, + "dependencies": { + "lodash.castarray": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.merge": "^4.6.2", + "postcss-selector-parser": "6.0.10" + }, + "peerDependencies": { + "tailwindcss": ">=3.0.0 || insiders" + } + }, + "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@tiptap/core": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.4.0.tgz", + "integrity": "sha512-YJSahk8pkxpCs8SflCZfTnJpE7IPyUWIylfgXM2DefjRQa5DZ+c6sNY0s/zbxKYFQ6AuHVX40r9pCfcqHChGxQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-blockquote": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-2.4.0.tgz", + "integrity": "sha512-nJJy4KsPgQqWTTDOWzFRdjCfG5+QExfZj44dulgDFNh+E66xhamnbM70PklllXJgEcge7xmT5oKM0gKls5XgFw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-bold": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-2.4.0.tgz", + "integrity": "sha512-csnW6hMDEHoRfxcPRLSqeJn+j35Lgtt1YRiOwn7DlS66sAECGRuoGfCvQSPij0TCDp4VCR9if5Sf8EymhnQumQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-bubble-menu": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-bubble-menu/-/extension-bubble-menu-2.4.0.tgz", + "integrity": "sha512-s99HmttUtpW3rScWq8rqk4+CGCwergNZbHLTkF6Rp6TSboMwfp+rwL5Q/JkcAG9KGLso1vGyXKbt1xHOvm8zMw==", + "dependencies": { + "tippy.js": "^6.3.7" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-bullet-list": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-2.4.0.tgz", + "integrity": "sha512-9S5DLIvFRBoExvmZ+/ErpTvs4Wf1yOEs8WXlKYUCcZssK7brTFj99XDwpHFA29HKDwma5q9UHhr2OB2o0JYAdw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-code": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-2.4.0.tgz", + "integrity": "sha512-wjhBukuiyJMq4cTcK3RBTzUPV24k5n1eEPlpmzku6ThwwkMdwynnMGMAmSF3fErh3AOyOUPoTTjgMYN2d10SJA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-code-block": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-2.4.0.tgz", + "integrity": "sha512-QWGdv1D56TBGbbJSj2cIiXGJEKguPiAl9ONzJ/Ql1ZksiQsYwx0YHriXX6TOC//T4VIf6NSClHEtwtxWBQ/Csg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-document": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-2.4.0.tgz", + "integrity": "sha512-3jRodQJZDGbXlRPERaloS+IERg/VwzpC1IO6YSJR9jVIsBO6xC29P3cKTQlg1XO7p6ZH/0ksK73VC5BzzTwoHg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-dropcursor": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-2.4.0.tgz", + "integrity": "sha512-c46HoG2PEEpSZv5rmS5UX/lJ6/kP1iVO0Ax+6JrNfLEIiDULUoi20NqdjolEa38La2VhWvs+o20OviiTOKEE9g==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-floating-menu": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-floating-menu/-/extension-floating-menu-2.4.0.tgz", + "integrity": "sha512-vLb9v+htbHhXyty0oaXjT3VC8St4xuGSHWUB9GuAJAQ+NajIO6rBPbLUmm9qM0Eh2zico5mpSD1Qtn5FM6xYzg==", + "dependencies": { + "tippy.js": "^6.3.7" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-gapcursor": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-2.4.0.tgz", + "integrity": "sha512-F4y/0J2lseohkFUw9P2OpKhrJ6dHz69ZScABUvcHxjznJLd6+0Zt7014Lw5PA8/m2d/w0fX8LZQ88pZr4quZPQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-hard-break": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-2.4.0.tgz", + "integrity": "sha512-3+Z6zxevtHza5IsDBZ4lZqvNR3Kvdqwxq/QKCKu9UhJN1DUjsg/l1Jn2NilSQ3NYkBYh2yJjT8CMo9pQIu776g==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-heading": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-2.4.0.tgz", + "integrity": "sha512-fYkyP/VMo7YHO76YVrUjd95Qeo0cubWn/Spavmwm1gLTHH/q7xMtbod2Z/F0wd6QHnc7+HGhO7XAjjKWDjldaw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-history": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-history/-/extension-history-2.4.0.tgz", + "integrity": "sha512-gr5qsKAXEVGr1Lyk1598F7drTaEtAxqZiuuSwTCzZzkiwgEQsWMWTWc9F8FlneCEaqe1aIYg6WKWlmYPaFwr0w==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-horizontal-rule": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-2.4.0.tgz", + "integrity": "sha512-yDgxy+YxagcEsBbdWvbQiXYxsv3noS1VTuGwc9G7ZK9xPmBHJ5y0agOkB7HskwsZvJHoaSqNRsh7oZTkf0VR3g==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-image": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-image/-/extension-image-2.4.0.tgz", + "integrity": "sha512-NIVhRPMO/ONo8OywEd+8zh0Q6Q7EbFHtBxVsvfOKj9KtZkaXQfUO4MzONTyptkvAchTpj9pIzeaEY5fyU87gFA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-italic": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-2.4.0.tgz", + "integrity": "sha512-aaW/L9q+KNHHK+X73MPloHeIsT191n3VLd3xm6uUcFDnUNvzYJ/q65/1ZicdtCaOLvTutxdrEvhbkrVREX6a8g==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-link": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.4.0.tgz", + "integrity": "sha512-r3PjT0bjSKAorHAEBPA0icSMOlqALbxVlWU9vAc+Q3ndzt7ht0CTPNewzFF9kjzARABVt1cblXP/2+c0qGzcsg==", + "dependencies": { + "linkifyjs": "^4.1.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-list-item": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-2.4.0.tgz", + "integrity": "sha512-reUVUx+2cI2NIAqMZhlJ9uK/+zvRzm1GTmlU2Wvzwc7AwLN4yemj6mBDsmBLEXAKPvitfLh6EkeHaruOGymQtg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-ordered-list": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-2.4.0.tgz", + "integrity": "sha512-Zo0c9M0aowv+2+jExZiAvhCB83GZMjZsxywmuOrdUbq5EGYKb7q8hDyN3hkrktVHr9UPXdPAYTmLAHztTOHYRA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-paragraph": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-2.4.0.tgz", + "integrity": "sha512-+yse0Ow67IRwcACd9K/CzBcxlpr9OFnmf0x9uqpaWt1eHck1sJnti6jrw5DVVkyEBHDh/cnkkV49gvctT/NyCw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-strike": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-2.4.0.tgz", + "integrity": "sha512-pE1uN/fQPOMS3i+zxPYMmPmI3keubnR6ivwM+KdXWOMnBiHl9N4cNpJgq1n2eUUGKLurC2qrQHpnVyGAwBS6Vg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-text": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.4.0.tgz", + "integrity": "sha512-LV0bvE+VowE8IgLca7pM8ll7quNH+AgEHRbSrsI3SHKDCYB9gTHMjWaAkgkUVaO1u0IfCrjnCLym/PqFKa+vvg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/extension-underline": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-2.4.0.tgz", + "integrity": "sha512-guWojb7JxUwLz4OKzwNExJwOkhZjgw/ttkXCMBT0PVe55k998MMYe1nvN0m2SeTW9IxurEPtScH4kYJ0XuSm8Q==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0" + } + }, + "node_modules/@tiptap/pm": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-2.4.0.tgz", + "integrity": "sha512-B1HMEqGS4MzIVXnpgRZDLm30mxDWj51LkBT/if1XD+hj5gm8B9Q0c84bhvODX6KIs+c6z+zsY9VkVu8w9Yfgxg==", + "dependencies": { + "prosemirror-changeset": "^2.2.1", + "prosemirror-collab": "^1.3.1", + "prosemirror-commands": "^1.5.2", + "prosemirror-dropcursor": "^1.8.1", + "prosemirror-gapcursor": "^1.3.2", + "prosemirror-history": "^1.3.2", + "prosemirror-inputrules": "^1.3.0", + "prosemirror-keymap": "^1.2.2", + "prosemirror-markdown": "^1.12.0", + "prosemirror-menu": "^1.2.4", + "prosemirror-model": "^1.19.4", + "prosemirror-schema-basic": "^1.2.2", + "prosemirror-schema-list": "^1.3.0", + "prosemirror-state": "^1.4.3", + "prosemirror-tables": "^1.3.5", + "prosemirror-trailing-node": "^2.0.7", + "prosemirror-transform": "^1.8.0", + "prosemirror-view": "^1.32.7" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + } + }, + "node_modules/@tiptap/react": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/react/-/react-2.4.0.tgz", + "integrity": "sha512-baxnIr6Dy+5iGagOEIKFeHzdl1ZRa6Cg+SJ3GDL/BVLpO6KiCM3Mm5ymB726UKP1w7icrBiQD2fGY3Bx8KaiSA==", + "dependencies": { + "@tiptap/extension-bubble-menu": "^2.4.0", + "@tiptap/extension-floating-menu": "^2.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0", + "react": "^17.0.0 || ^18.0.0", + "react-dom": "^17.0.0 || ^18.0.0" + } + }, + "node_modules/@tiptap/starter-kit": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-2.4.0.tgz", + "integrity": "sha512-DYYzMZdTEnRn9oZhKOeRCcB+TjhNz5icLlvJKoHoOGL9kCbuUyEf8WRR2OSPckI0+KUIPJL3oHRqO4SqSdTjfg==", + "dependencies": { + "@tiptap/core": "^2.4.0", + "@tiptap/extension-blockquote": "^2.4.0", + "@tiptap/extension-bold": "^2.4.0", + "@tiptap/extension-bullet-list": "^2.4.0", + "@tiptap/extension-code": "^2.4.0", + "@tiptap/extension-code-block": "^2.4.0", + "@tiptap/extension-document": "^2.4.0", + "@tiptap/extension-dropcursor": "^2.4.0", + "@tiptap/extension-gapcursor": "^2.4.0", + "@tiptap/extension-hard-break": "^2.4.0", + "@tiptap/extension-heading": "^2.4.0", + "@tiptap/extension-history": "^2.4.0", + "@tiptap/extension-horizontal-rule": "^2.4.0", + "@tiptap/extension-italic": "^2.4.0", + "@tiptap/extension-list-item": "^2.4.0", + "@tiptap/extension-ordered-list": "^2.4.0", + "@tiptap/extension-paragraph": "^2.4.0", + "@tiptap/extension-strike": "^2.4.0", + "@tiptap/extension-text": "^2.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + } + }, "node_modules/@types/draft-js": { "version": "0.11.18", "resolved": "https://registry.npmjs.org/@types/draft-js/-/draft-js-0.11.18.tgz", @@ -785,8 +1213,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/aria-query": { "version": "5.3.0", @@ -1212,6 +1639,11 @@ "url": "https://opencollective.com/core-js" } }, + "node_modules/crelt": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", + "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==" + }, "node_modules/cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", @@ -1509,6 +1941,17 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-abstract": { "version": "1.23.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", @@ -1671,7 +2114,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, "engines": { "node": ">=10" }, @@ -3201,6 +3643,19 @@ "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/linkifyjs": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.3.tgz", + "integrity": "sha512-auMesunaJ8yfkHvK4gfg1K0SaKX/6Wn9g2Aac/NwX+l5VdmFZzo/hdPGxEOETj+ryRa4/fiOPjeeKURSAJx1sg==" + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -3216,6 +3671,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash.castarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", + "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==", + "dev": true + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3241,6 +3708,35 @@ "node": "14 || >=16.14" } }, + "node_modules/lucide-react": { + "version": "0.395.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.395.0.tgz", + "integrity": "sha512-6hzdNH5723A4FLaYZWpK50iyZH8iS2Jq5zuPRRotOFkhu6kxxJiebVdJ72tCR5XkiIeYFOU5NUawFZOac+VeYw==", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -3597,6 +4093,11 @@ "node": ">= 0.8.0" } }, + "node_modules/orderedmap": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", + "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==" + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -3904,6 +4405,182 @@ "react-is": "^16.13.1" } }, + "node_modules/prosemirror-changeset": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.2.1.tgz", + "integrity": "sha512-J7msc6wbxB4ekDFj+n9gTW/jav/p53kdlivvuppHsrZXCaQdVgRghoZbSS3kwrRyAstRVQ4/+u5k7YfLgkkQvQ==", + "dependencies": { + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-collab": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/prosemirror-collab/-/prosemirror-collab-1.3.1.tgz", + "integrity": "sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ==", + "dependencies": { + "prosemirror-state": "^1.0.0" + } + }, + "node_modules/prosemirror-commands": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.5.2.tgz", + "integrity": "sha512-hgLcPaakxH8tu6YvVAaILV2tXYsW3rAdDR8WNkeKGcgeMVQg3/TMhPdVoh7iAmfgVjZGtcOSjKiQaoeKjzd2mQ==", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-dropcursor": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.1.tgz", + "integrity": "sha512-M30WJdJZLyXHi3N8vxN6Zh5O8ZBbQCz0gURTfPmTIBNQ5pxrdU7A58QkNqfa98YEjSAL1HUyyU34f6Pm5xBSGw==", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0", + "prosemirror-view": "^1.1.0" + } + }, + "node_modules/prosemirror-gapcursor": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.3.2.tgz", + "integrity": "sha512-wtjswVBd2vaQRrnYZaBCbyDqr232Ed4p2QPtRIUK5FuqHYKGWkEwl08oQM4Tw7DOR0FsasARV5uJFvMZWxdNxQ==", + "dependencies": { + "prosemirror-keymap": "^1.0.0", + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-view": "^1.0.0" + } + }, + "node_modules/prosemirror-history": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.4.0.tgz", + "integrity": "sha512-UUiGzDVcqo1lovOPdi9YxxUps3oBFWAIYkXLu3Ot+JPv1qzVogRbcizxK3LhHmtaUxclohgiOVesRw5QSlMnbQ==", + "dependencies": { + "prosemirror-state": "^1.2.2", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.31.0", + "rope-sequence": "^1.3.0" + } + }, + "node_modules/prosemirror-inputrules": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.4.0.tgz", + "integrity": "sha512-6ygpPRuTJ2lcOXs9JkefieMst63wVJBgHZGl5QOytN7oSZs3Co/BYbc3Yx9zm9H37Bxw8kVzCnDsihsVsL4yEg==", + "dependencies": { + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.0.0" + } + }, + "node_modules/prosemirror-keymap": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.2.tgz", + "integrity": "sha512-EAlXoksqC6Vbocqc0GtzCruZEzYgrn+iiGnNjsJsH4mrnIGex4qbLdWWNza3AW5W36ZRrlBID0eM6bdKH4OStQ==", + "dependencies": { + "prosemirror-state": "^1.0.0", + "w3c-keyname": "^2.2.0" + } + }, + "node_modules/prosemirror-markdown": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.0.tgz", + "integrity": "sha512-UziddX3ZYSYibgx8042hfGKmukq5Aljp2qoBiJRejD/8MH70siQNz5RB1TrdTPheqLMy4aCe4GYNF10/3lQS5g==", + "dependencies": { + "markdown-it": "^14.0.0", + "prosemirror-model": "^1.20.0" + } + }, + "node_modules/prosemirror-menu": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/prosemirror-menu/-/prosemirror-menu-1.2.4.tgz", + "integrity": "sha512-S/bXlc0ODQup6aiBbWVsX/eM+xJgCTAfMq/nLqaO5ID/am4wS0tTCIkzwytmao7ypEtjj39i7YbJjAgO20mIqA==", + "dependencies": { + "crelt": "^1.0.0", + "prosemirror-commands": "^1.0.0", + "prosemirror-history": "^1.0.0", + "prosemirror-state": "^1.0.0" + } + }, + "node_modules/prosemirror-model": { + "version": "1.21.1", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.21.1.tgz", + "integrity": "sha512-IVBAuMqOfltTr7yPypwpfdGT+6rGAteVOw2FO6GEvCGGa1ZwxLseqC1Eax/EChDvG/xGquB2d/hLdgh3THpsYg==", + "dependencies": { + "orderedmap": "^2.0.0" + } + }, + "node_modules/prosemirror-schema-basic": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.2.2.tgz", + "integrity": "sha512-/dT4JFEGyO7QnNTe9UaKUhjDXbTNkiWTq/N4VpKaF79bBjSExVV2NXmJpcM7z/gD7mbqNjxbmWW5nf1iNSSGnw==", + "dependencies": { + "prosemirror-model": "^1.19.0" + } + }, + "node_modules/prosemirror-schema-list": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.4.0.tgz", + "integrity": "sha512-nZOIq/AkBSzCENxUyLm5ltWE53e2PLk65ghMN8qLQptOmDVixZlPqtMeQdiNw0odL9vNpalEjl3upgRkuJ/Jyw==", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.7.3" + } + }, + "node_modules/prosemirror-state": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.3.tgz", + "integrity": "sha512-goFKORVbvPuAQaXhpbemJFRKJ2aixr+AZMGiquiqKxaucC6hlpHNZHWgz5R7dS4roHiwq9vDctE//CZ++o0W1Q==", + "dependencies": { + "prosemirror-model": "^1.0.0", + "prosemirror-transform": "^1.0.0", + "prosemirror-view": "^1.27.0" + } + }, + "node_modules/prosemirror-tables": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.3.7.tgz", + "integrity": "sha512-oEwX1wrziuxMtwFvdDWSFHVUWrFJWt929kVVfHvtTi8yvw+5ppxjXZkMG/fuTdFo+3DXyIPSKfid+Be1npKXDA==", + "dependencies": { + "prosemirror-keymap": "^1.1.2", + "prosemirror-model": "^1.8.1", + "prosemirror-state": "^1.3.1", + "prosemirror-transform": "^1.2.1", + "prosemirror-view": "^1.13.3" + } + }, + "node_modules/prosemirror-trailing-node": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/prosemirror-trailing-node/-/prosemirror-trailing-node-2.0.8.tgz", + "integrity": "sha512-ujRYhSuhQb1Jsarh1IHqb2KoSnRiD7wAMDGucP35DN7j5af6X7B18PfdPIrbwsPTqIAj0fyOvxbuPsWhNvylmA==", + "dependencies": { + "@remirror/core-constants": "^2.0.2", + "escape-string-regexp": "^4.0.0" + }, + "peerDependencies": { + "prosemirror-model": "^1.19.0", + "prosemirror-state": "^1.4.2", + "prosemirror-view": "^1.31.2" + } + }, + "node_modules/prosemirror-transform": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.9.0.tgz", + "integrity": "sha512-5UXkr1LIRx3jmpXXNKDhv8OyAOeLTGuXNwdVfg8x27uASna/wQkr9p6fD3eupGOi4PLJfbezxTyi/7fSJypXHg==", + "dependencies": { + "prosemirror-model": "^1.21.0" + } + }, + "node_modules/prosemirror-view": { + "version": "1.33.8", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.33.8.tgz", + "integrity": "sha512-4PhMr/ufz2cdvFgpUAnZfs+0xij3RsFysreeG9V/utpwX7AJtYCDVyuRxzWoMJIEf4C7wVihuBNMPpFLPCiLQw==", + "dependencies": { + "prosemirror-model": "^1.20.0", + "prosemirror-state": "^1.0.0", + "prosemirror-transform": "^1.1.0" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -3913,6 +4590,14 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "engines": { + "node": ">=6" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -4110,6 +4795,11 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rope-sequence": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz", + "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==" + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -4167,6 +4857,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sass": { + "version": "1.77.5", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.5.tgz", + "integrity": "sha512-oDfX1mukIlxacPdQqNb6mV2tVCrnE+P3nVYioy72V5tlk56CPNcO4TCuFcaCRKKfJ1M3lH95CleRS+dVKL2qMg==", + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/sass/node_modules/immutable": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.6.tgz", + "integrity": "sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==" + }, "node_modules/scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -4649,6 +5360,24 @@ "node": ">=0.8" } }, + "node_modules/tippy.js": { + "version": "6.3.7", + "resolved": "https://registry.npmjs.org/tippy.js/-/tippy.js-6.3.7.tgz", + "integrity": "sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==", + "dependencies": { + "@popperjs/core": "^2.9.0" + } + }, + "node_modules/tiptap-extension-resize-image": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/tiptap-extension-resize-image/-/tiptap-extension-resize-image-1.1.7.tgz", + "integrity": "sha512-PrYKPufFJijjiV8Tp/gZU84sCTzLnf/65zKzgHL2GNdY9C9VtaPME93qIZxUrIppXRF9oB8q+KWFHFVTJQei7w==", + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/extension-image": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -4831,6 +5560,11 @@ "node": "*" } }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==" + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -4866,6 +5600,11 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index 75ac98e..7257bcb 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,14 @@ }, "dependencies": { "@heroicons/react": "^2.1.3", + "@tiptap/extension-bullet-list": "^2.4.0", + "@tiptap/extension-image": "^2.4.0", + "@tiptap/extension-link": "^2.4.0", + "@tiptap/extension-list-item": "^2.4.0", + "@tiptap/extension-underline": "^2.4.0", + "@tiptap/pm": "^2.4.0", + "@tiptap/react": "^2.4.0", + "@tiptap/starter-kit": "^2.4.0", "@types/draft-js": "^0.11.18", "draft-js": "^0.11.7", "draft-js-export-html": "^1.4.1", @@ -17,12 +25,16 @@ "flowbite": "^2.3.0", "flowbite-react": "^0.9.0", "formidable": "^3.5.1", + "lucide-react": "^0.395.0", "next": "14.2.3", "react": "^18", "react-dom": "^18", + "sass": "^1.77.5", + "tiptap-extension-resize-image": "^1.1.7", "zod": "^3.23.4" }, "devDependencies": { + "@tailwindcss/typography": "^0.5.13", "@types/formidable": "^3.4.5", "@types/node": "^20", "@types/react": "^18", diff --git a/src/app/templateEdit/layout.tsx b/src/app/templateEdit/layout.tsx new file mode 100644 index 0000000..e2c0932 --- /dev/null +++ b/src/app/templateEdit/layout.tsx @@ -0,0 +1,12 @@ +import SideNav from "@/app/ui/side-nav"; + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( +
+
+ +
+
{children}
+
+ ); +} diff --git a/src/app/templateEdit/page.tsx b/src/app/templateEdit/page.tsx new file mode 100644 index 0000000..4bd11de --- /dev/null +++ b/src/app/templateEdit/page.tsx @@ -0,0 +1,33 @@ +"use client"; +import { useState } from "react"; +import TipTap from "@/app/ui/Tiptap"; + +export default function Page() { + const [content, setContent] = useState(""); + + const handleContentChange = (reason: any) => { + setContent(reason); + }; + + return ( +
+
+

Create an Email template

+
+

+ Create and save your html file here. +

+
+
+
+
+
+ handleContentChange(newContent)} + /> +
+
+
+ ); +} diff --git a/src/app/ui/Tiptap.tsx b/src/app/ui/Tiptap.tsx new file mode 100644 index 0000000..6fa0340 --- /dev/null +++ b/src/app/ui/Tiptap.tsx @@ -0,0 +1,152 @@ +"use client"; + +import { useEditor, EditorContent } from "@tiptap/react"; +import StarterKit from "@tiptap/starter-kit"; +import Toolbar from "@/app/ui/Toolbar"; +import { Underline } from "@tiptap/extension-underline"; +import BulletList from "@tiptap/extension-bullet-list"; +import ListItem from "@tiptap/extension-list-item"; +import { Link } from "@tiptap/extension-link"; +import "./styles.scss"; +import Image from "@tiptap/extension-image"; +import ImageResize from "tiptap-extension-resize-image"; +import { useState } from "react"; +import NextStepLink from "next/link"; + +const htmltemplateContent = ` +

親愛的{{Name}},

+

您好!恭喜您成功加入「6th AWS Educate Taiwan 雲端校園大使證照陪跑計畫」!非常高興您決定與我們一起踏上學習的旅程,共同探索雲端技術的無限可能!

+

為確保您能夠有效利用本計畫資源,校園大使團隊精心統整許多考照資源於在 Notion Page,並建立 Discord 社群以促進更深入的討論和即時互動,讓您可以輕鬆地提問並與大使互動問答。

+

您可以透過以下連結訪問:
Notion Page:點擊這裡
Discord 社群:{Discord Link}

+

【注意事項】
請記得定期追蹤計畫 Notion Page 和 Discord 社群,我們會定期更新資源和消息。
陪跑計畫包含證照課程與獎勵課程,獎勵課程需完成規定的課程進度才可以參與,詳細規則請見 Notion Page。

+

【開幕活動與報名資訊】
隨著「6th AWS Educate Taiwan 雲端校園大使證照陪跑計畫」正式啟動,誠摯邀請您參加 2024 年 5 月 3 日(星期五)舉行的開幕活動。開幕活動不僅標誌著計畫的正式啟動,也將針對計畫內容、規則等詳細說明,亦可與其他參與者相互認識、交流分享。
有意願參加開幕活動請填寫以下報名表單,表單將於 4/29(一)18:00 截止點擊這裡

+

若您有任何問題或需要進一步協助,請隨時與我們聯繫,我們將竭誠為您服務!

+

台灣 AWS Educate Cloud Ambassador 官方社群:Facebook&Instagram

+

Best regards,

+

Bill Wu

+

AWS Educate Cloud Ambassador

+

billwu0222@gmail.com

`; + +const Tiptap = ({ onChange, content }: any) => { + const [editorContent, setEditorContent] = useState(htmltemplateContent); + const [isFocused, setIsFocused] = useState(false); + const [isUploading, setIsUploading] = useState(false); + const [showNextStep, setShowNextStep] = useState(false); + + const handleUpload = async () => { + const html = ` + + + + + 加入 AWS Educate Taiwan 雲端校園大使證照陪跑計畫 + + + ${editorContent} + + `; + const blob = new Blob([html], { type: "text/html" }); + const formData = new FormData(); + formData.append("file", blob, "html-generate.html"); + + try { + const base_url = process.env.NEXT_PUBLIC_API_ENDPOINT; + const url = new URL(`${base_url}/upload-multiple-file`); + setIsUploading(true); + const response = await fetch(url.toString(), { + method: "POST", + body: formData, + }); + const result = await response.json(); + console.log(result); + setIsUploading(false); + setShowNextStep(true); + alert("You have uploaded the html file successfully!"); + } catch (error) { + console.error("Upload failed:", error); + } + }; + + const handleChange = (newContent: string) => { + console.log(newContent); + setEditorContent(newContent); + onChange(newContent); + }; + + const editor = useEditor({ + extensions: [ + StarterKit, + Underline, + BulletList, + ListItem, + Link.configure({ + openOnClick: false, + autolink: true, + }), + Image, + ImageResize, + ], + editorProps: { + attributes: { + class: + "w-full flex-col justify-start text-black items-start w-full gap-3 pt-4 rounded-bl-md rounded-br-md outline-none", + }, + }, + content: htmltemplateContent, + onUpdate: ({ editor }) => { + handleChange(editor.getHTML()); + }, + }); + + return ( + <> +
+
+ setIsFocused(true)} + onBlur={() => setIsFocused(false)} + /> + +
+
+
+ {/* */} + {isUploading ? ( + + ) : ( + + )} + {showNextStep && ( + + Next Step → + + )} +
+ + ); +}; + +export default Tiptap; diff --git a/src/app/ui/Toolbar.tsx b/src/app/ui/Toolbar.tsx new file mode 100644 index 0000000..fc4ed36 --- /dev/null +++ b/src/app/ui/Toolbar.tsx @@ -0,0 +1,295 @@ +import React, { useCallback } from "react"; +import { type Editor } from "@tiptap/react"; +import { + Bold, + Strikethrough, + Italic, + List, + ListOrdered, + Heading1, + Heading2, + Heading3, + Underline, + Quote, + Undo, + Redo, + Link, + Image, +} from "lucide-react"; + +type Props = { + editor: Editor | null; + content: string; +}; + +const Toolbar = ({ editor, content }: Props) => { + const setLink = useCallback(() => { + if (!editor) return; + const previousUrl = editor.getAttributes("link").href; + const url = window.prompt("URL", previousUrl); + + if (url === null) { + return; + } + + if (url === "") { + editor.chain().focus().extendMarkRange("link").unsetLink().run(); + return; + } + + editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run(); + }, [editor]); + + const uploadFile = async (file: File) => { + const formData = new FormData(); + formData.append("file", file); + const base_url = process.env.NEXT_PUBLIC_API_ENDPOINT; + const url = new URL(`${base_url}/upload-multiple-file`); + + const response = await fetch(url.toString(), { + method: "POST", + body: formData, + }); + + const result = await response.json(); + if (result && result.files && result.files.length > 0) { + return result.files[0].file_url; + } + + return null; + }; + + const addImage = useCallback(async () => { + if (!editor) return; + const fileInput = document.createElement("input"); + fileInput.type = "file"; + fileInput.accept = "image/*"; + fileInput.onchange = async () => { + if (fileInput.files && fileInput.files[0]) { + const fileUrl = await uploadFile(fileInput.files[0]); + if (fileUrl) { + editor.chain().focus().setImage({ src: fileUrl }).run(); + } + } + }; + fileInput.click(); + }, [editor]); + + if (!editor) { + return null; + } + + return ( +
+
+
+ + + + + + + + + + + + + + +
+
+ ); +}; + +export default Toolbar; diff --git a/src/app/ui/attach-dropdown.tsx b/src/app/ui/attach-dropdown.tsx new file mode 100644 index 0000000..38edfca --- /dev/null +++ b/src/app/ui/attach-dropdown.tsx @@ -0,0 +1,262 @@ +"use client"; +import { useState, useEffect, useRef } from "react"; +import { convertToTaipeiTime, formatFileSize } from "@/lib/utils/dataUtils"; + +interface fileDataType { + file_id: string; + created_at: string; + updated_at: string; + file_url: string; + file_name: string; + file_extension: string; + file_size: number; + uploader_id: string; +} + +interface AttachDropdownProps { + onSelect: (selectedFiles: { file_id: string; file_url: string }[]) => void; +} + +export default function AttachDropdown({ onSelect }: AttachDropdownProps) { + const [templateOptions, setTemplateOptions] = useState( + null + ); + const [filteredOptions, setFilteredOptions] = useState( + null + ); + const [searchTerm, setSearchTerm] = useState(""); + const [isOpen, setIsOpen] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [selectedFiles, setSelectedFiles] = useState([]); + const dropdownRef = useRef(null); + + useEffect(() => { + if (templateOptions) { + setFilteredOptions( + templateOptions.filter((option) => + option.file_name.toLowerCase().includes(searchTerm.toLowerCase()) + ) + ); + } + }, [searchTerm, templateOptions]); + + useEffect(() => { + function handleClickOutside(event: MouseEvent) { + if ( + dropdownRef.current && + !dropdownRef.current.contains(event.target as Node) + ) { + setIsOpen(false); + } + } + document.addEventListener("mousedown", handleClickOutside); + return () => { + document.removeEventListener("mousedown", handleClickOutside); + }; + }, [dropdownRef]); + + const fetchFiles = async (limit: number) => { + try { + setIsLoading(true); + const base_url = process.env.NEXT_PUBLIC_API_ENDPOINT; + const url = new URL(`${base_url}/files`); + url.searchParams.append("limit", limit.toString()); + + const response = await fetch(url.toString(), { + method: "GET", + }); + + if (!response.ok) { + const errorMessage = `Request failed: ${response.status} - ${response.statusText}`; + throw new Error(errorMessage); + } + + const result = await response.json(); + setTemplateOptions(result.data); + } catch (error: any) { + alert("Failed to fetch files: " + error.message); + } finally { + setIsLoading(false); + } + }; + + const toggleDropdown = () => { + if (!isOpen) { + fetchFiles(15); + } + setIsOpen(!isOpen); + }; + + const handleSelect = (file: fileDataType) => { + const alreadySelected = selectedFiles.some( + (selectedFile) => selectedFile.file_id === file.file_id + ); + let updatedSelectedFiles; + if (alreadySelected) { + updatedSelectedFiles = selectedFiles.filter( + (selectedFile) => selectedFile.file_id !== file.file_id + ); + } else { + updatedSelectedFiles = [...selectedFiles, file]; + } + setSelectedFiles(updatedSelectedFiles); + onSelect( + updatedSelectedFiles.map(({ file_id, file_url }) => ({ + file_id, + file_url, + })) + ); + }; + + return ( +
+
+ +
+ + {isOpen && ( +
+
+

ATTACH FILES

+ setSearchTerm(e.target.value)} + /> +
+ + {isLoading ? ( +
+ + + + +

Loading...

+
+ ) : filteredOptions && filteredOptions.length > 0 ? ( +
+ + + + + + + + + + {filteredOptions.map((option) => ( + file.file_id === option.file_id + ) + ? "bg-gray-100" + : "" + }`} + onClick={() => handleSelect(option)} + > + + + + + ))} + +
+ File Name + + Created At + + File Size +
+ {option.file_name} + + {convertToTaipeiTime(option.created_at)} + + {formatFileSize(option.file_size)} +
+
+ ) : ( +
+ + + + + + + + + + + + + + +
+ File Name + + Created At + + Created At + + File Size +
+ No files found +
+
+ )} +
+ )} +
+ ); +} diff --git a/src/app/ui/file-upload.tsx b/src/app/ui/file-upload.tsx index 5742b51..6ff9cad 100644 --- a/src/app/ui/file-upload.tsx +++ b/src/app/ui/file-upload.tsx @@ -43,13 +43,12 @@ export default function FileUpload({ setIsSubmitting(true); try { - const response = await fetch( - "https://sojek1stci.execute-api.ap-northeast-1.amazonaws.com/dev/upload-multiple-file", - { - method: "POST", - body: formData, - } - ); + const base_url = process.env.NEXT_PUBLIC_API_ENDPOINT; + const url = new URL(`${base_url}/upload-multiple-file`); + const response = await fetch(url.toString(), { + method: "POST", + body: formData, + }); if (!response.ok) { const errorMessage = `Upload failed: ${response.status} - ${response.statusText}`; @@ -58,13 +57,13 @@ export default function FileUpload({ const result = await response.json(); setFileData(result.files); - result.files.forEach((file: FileDataType) => { - if (file.file_extension === "xlsx") { - localStorage.setItem("xlsx_key", file.file_id); - } else if (file.file_extension === "html") { - localStorage.setItem("html_key", file.file_id); - } - }); + // result.files.forEach((file: FileDataType) => { + // if (file.file_extension === "xlsx") { + // localStorage.setItem("xlsx_key", file.file_id); + // } else if (file.file_extension === "html") { + // localStorage.setItem("html_key", file.file_id); + // } + // }); // onFileUploadSuccess(result.files); alert("File uploaded successfully!"); } catch (error: any) { @@ -82,10 +81,14 @@ export default function FileUpload({

Upload your email template.

- ) : ( + ) : OnFileExtension === ".xlsx" ? (

Upload your participants sheet.

+ ) : OnFileExtension === "all" ? ( +

Attach your files.

+ ) : ( +

Unsupported file type.

)}
@@ -107,12 +110,21 @@ export default function FileUpload({ background-color: #082f49; } `} -

- only {OnFileExtension} is accepted -

+ {OnFileExtension === "all" ? ( +

+ all types of files are accepted +

+ ) : ( +

+ only {OnFileExtension} is accepted +

+ )}