mirror of
https://github.com/artegoser/AnoPaper.git
synced 2025-02-23 20:51:27 +03:00
delete all
This commit is contained in:
parent
95fe085859
commit
0202d31abe
51 changed files with 0 additions and 17910 deletions
33
src/App.css
33
src/App.css
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f2f2f2;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #bdbdbd;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #6e6e6e;
|
||||
}
|
106
src/App.jsx
106
src/App.jsx
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import "./App.css";
|
||||
import { Routes, Route } from "react-router-dom";
|
||||
import Menu from "./components/menu";
|
||||
import CreateNote from "./pages/create";
|
||||
import Save from "./pages/save-local";
|
||||
import Publish from "./pages/publish";
|
||||
import NotePage from "./pages/note";
|
||||
import Notes from "./pages/notes";
|
||||
import PubNote from "./pages/pubNote";
|
||||
import PubError from "./pages/pubError";
|
||||
import PubNoteSafe from "./pages/pubNoteSafe";
|
||||
import RenderMarkdown from "./components/markdown";
|
||||
import socket from "./components/socket";
|
||||
import Settings from "./pages/settings";
|
||||
import { useState } from "react";
|
||||
import { localesProcess } from "./components/utils";
|
||||
import { ButtonWithIcon } from "./components/button";
|
||||
import { LinkIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
function App() {
|
||||
Storage.prototype.setObj = function (key, obj) {
|
||||
return this.setItem(key, JSON.stringify(obj));
|
||||
};
|
||||
Storage.prototype.getObj = function (key) {
|
||||
return JSON.parse(this.getItem(key)) || {};
|
||||
};
|
||||
|
||||
const [key, setKey] = useState(Math.random());
|
||||
|
||||
window.settings = localStorage.getObj("settings") || {};
|
||||
|
||||
localesProcess();
|
||||
|
||||
window.addEventListener("reRenderPage", () => {
|
||||
setKey(Math.random());
|
||||
});
|
||||
|
||||
window.socket = socket;
|
||||
|
||||
if (settings.userName == "bruh") {
|
||||
document.body.classList.add(
|
||||
"transition-transform",
|
||||
"transform",
|
||||
"rotate-180"
|
||||
);
|
||||
} else if (document.body.classList.contains("transition-transform")) {
|
||||
document.body.classList.remove("rotate-180");
|
||||
document.body.classList.add("rotate-0");
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="grid grid-cols-4 lg:grid-cols-5 gap-10 text-black dark:text-white"
|
||||
key={key}
|
||||
>
|
||||
<Menu />
|
||||
<div className="col-span-4 p-5 m-4 rounded-2xl">
|
||||
<Routes>
|
||||
<Route path="/" element={<CreateNote />} />
|
||||
<Route path="/notes/save-local" element={<Save />} />
|
||||
<Route path="/notes/publish" element={<Publish />} />
|
||||
<Route path="/notes/:id" element={<NotePage />} />
|
||||
<Route path="/pubNotes/:id" element={<PubNote />} />
|
||||
<Route path="/pubNotesSafe/:id" element={<PubNoteSafe />} />
|
||||
<Route path="/pubError" element={<PubError />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
<Route
|
||||
path="/about"
|
||||
element={
|
||||
<>
|
||||
<div className="col-span-4 md">
|
||||
<RenderMarkdown>{locals.about_md}</RenderMarkdown>
|
||||
</div>
|
||||
<ButtonWithIcon
|
||||
icon={LinkIcon}
|
||||
text={locals.SourceCode}
|
||||
href="https://github.com/artegoser/AnoPaper"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<Route path="/notes" element={<Notes />} />
|
||||
</Routes>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
function Button({
|
||||
href,
|
||||
className,
|
||||
onClick,
|
||||
w,
|
||||
children,
|
||||
color = "bg-zinc-100 hover:bg-zinc-300 dark:bg-zinc-600 dark:hover:bg-zinc-800",
|
||||
}) {
|
||||
return (
|
||||
<Link to={href} className={className}>
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={`transition-transform ${
|
||||
w ? w : "w-48"
|
||||
} ease-[cubic-bezier(.69,.58,.32,1.69)] hover:scale-105 p-2 pl-6 text-lg ${color} rounded-2xl ${className}`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function IconWithText(props) {
|
||||
if (props.reverse) {
|
||||
return (
|
||||
<div className="grid place-content-end grid-cols-2">
|
||||
<div>{props.children}</div>
|
||||
<div className="justify-self-end">{props.icon}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="grid place-content-start grid-cols-4">
|
||||
<div>{props.icon}</div>
|
||||
<div className="justify-self-start col-span-3">{props.children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonWithIcon(props) {
|
||||
return (
|
||||
<Button
|
||||
href={props.href}
|
||||
className={props.className}
|
||||
onClick={props.onClick}
|
||||
w={props.w}
|
||||
color={props.color}
|
||||
>
|
||||
<IconWithText
|
||||
reverse={props.reverse}
|
||||
icon={
|
||||
<props.icon
|
||||
className={props.iconClass || "transform translate-z-0 h-7 w-7"}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{props.text}
|
||||
</IconWithText>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, IconWithText, ButtonWithIcon };
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function CheckBox(props) {
|
||||
return (
|
||||
<div className={`m-5 ${props.className}`}>
|
||||
<input
|
||||
className="appearance-none h-3 w-6 duration-500 checked:bg-blue-600 checked:border-blue-600 pr-3 border border-gray-300 rounded-lg mr-1 checked:shadow-lg checked:shadow-blue-600 transition ease-out cursor-pointer"
|
||||
type="checkbox"
|
||||
id={props.id}
|
||||
defaultChecked={props.checked}
|
||||
onClick={props.onClick}
|
||||
title={props.title}
|
||||
/>
|
||||
<label
|
||||
title={props.title}
|
||||
className="inline-block cursor-pointer"
|
||||
htmlFor={props.id}
|
||||
>
|
||||
{props.label}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CheckBox };
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { ClipboardIcon, CheckIcon } from "@heroicons/react/24/outline";
|
||||
import { useEffect } from "react";
|
||||
|
||||
function CopyToClipboard(props) {
|
||||
let [copied, setCopied] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (copied === true) {
|
||||
setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className="grid grid-cols-4 border rounded-lg p-2 border-blue-300 bg-blue-500 text-white hover:bg-blue-600 transition-colors"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(props.text);
|
||||
setCopied(true);
|
||||
}}
|
||||
>
|
||||
<div className="col-span-3 truncate">{props.text}</div>
|
||||
<div className="justify-self-center lg:justify-self-end cursor-pointer">
|
||||
{copied === true ? (
|
||||
<CheckIcon className="transform translate-z-0 h-7 w-7" />
|
||||
) : (
|
||||
<ClipboardIcon className="transform translate-z-0 h-7 w-7" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function CodeCopyBtn({ text }) {
|
||||
let [copied, setCopied] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (copied === true) {
|
||||
setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className="code-copy-btn"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
}}
|
||||
>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
{copied === true ? (
|
||||
<CheckIcon className="transform translate-z-0 h-7 w-7" />
|
||||
) : (
|
||||
<ClipboardIcon className="transform translate-z-0 h-7 w-7" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { CopyToClipboard, CodeCopyBtn };
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import rehypeMathjax from "rehype-mathjax";
|
||||
import remarkMath from "remark-math";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
import SyntaxHighlighter from "react-syntax-highlighter";
|
||||
import { darcula, github } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
||||
|
||||
import { CodeCopyBtn } from "./copytocb";
|
||||
|
||||
let theme = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light";
|
||||
|
||||
function CodeBlock(props) {
|
||||
let text = props.children[0];
|
||||
let oneline = text.indexOf("\n") <= 1;
|
||||
if (oneline) {
|
||||
return <code className="md-code">{text}</code>;
|
||||
} else
|
||||
return (
|
||||
<SyntaxHighlighter
|
||||
className={`md-code ${props.className}`}
|
||||
style={theme == "light" ? github : darcula}
|
||||
>
|
||||
{text}
|
||||
</SyntaxHighlighter>
|
||||
);
|
||||
}
|
||||
|
||||
function RenderMarkdown(props) {
|
||||
return (
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkMath, remarkGfm]}
|
||||
rehypePlugins={[rehypeMathjax]}
|
||||
components={{
|
||||
code: CodeBlock,
|
||||
pre: Pre,
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</ReactMarkdown>
|
||||
);
|
||||
}
|
||||
|
||||
function Pre({ children }) {
|
||||
let text = children[0].props.children[0];
|
||||
let oneline = text.indexOf("\n") <= 1;
|
||||
return (
|
||||
<pre className={oneline ? "" : "blog-pre"}>
|
||||
{!oneline && <CodeCopyBtn text={text} />}
|
||||
{children}
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
|
||||
export default RenderMarkdown;
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ButtonWithIcon } from "./button";
|
||||
import {
|
||||
MagnifyingGlassCircleIcon,
|
||||
PencilIcon,
|
||||
ExclamationCircleIcon,
|
||||
Cog6ToothIcon,
|
||||
ChevronDownIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
|
||||
function Menu() {
|
||||
const [hidden, setHidden] = useState(window.innerWidth < 1024 ? true : false);
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 lg:grid-cols-1 col-span-4 lg:col-span-1 gap-2 mt-4 lg:m-4 place-content-start justify-self-center justify-center">
|
||||
{window.innerWidth < 1024 && (
|
||||
<ButtonWithIcon
|
||||
icon={ChevronDownIcon}
|
||||
text={locals.Menu}
|
||||
reverse
|
||||
className="col-span-2 lg:col-span-1 justify-self-center"
|
||||
color="bg-sky-600 hover:bg-sky-800 dark:bg-sky-800 dark:hover:bg-sky-900 text-white"
|
||||
onClick={() => {
|
||||
setHidden(!hidden);
|
||||
}}
|
||||
iconClass={`transition-transform transform translate-z-0 h-7 w-7 ${
|
||||
!hidden ? "rotate-180" : "rotate-0"
|
||||
}`}
|
||||
/>
|
||||
)}
|
||||
{!hidden && (
|
||||
<>
|
||||
<ButtonWithIcon
|
||||
icon={MagnifyingGlassCircleIcon}
|
||||
text={locals.Notes}
|
||||
href="/notes"
|
||||
/>
|
||||
<ButtonWithIcon icon={PencilIcon} text={locals.Write} href="/" />
|
||||
<ButtonWithIcon
|
||||
icon={Cog6ToothIcon}
|
||||
text={locals.Settings}
|
||||
href="/settings"
|
||||
/>
|
||||
<ButtonWithIcon
|
||||
icon={ExclamationCircleIcon}
|
||||
text={locals.About}
|
||||
href="/about"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Menu;
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import RenderMarkdown from "../components/markdown";
|
||||
import { timestamp2text } from "./utils";
|
||||
|
||||
function Note({ note }) {
|
||||
return (
|
||||
<>
|
||||
<div className="border border-blue-300 rounded-lg p-4">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="font-medium text-center lg:text-left leading-tight text-4xl mt-0 mb-2">
|
||||
{note.name}
|
||||
</h2>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
{`${timestamp2text(note.time)} ${
|
||||
note.pub ? `| ${locals.PublicNote}` : `| ${locals.LocalNote}`
|
||||
}`}
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full md break-words">
|
||||
<RenderMarkdown>{note.text}</RenderMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
<div className="hidden">
|
||||
<input type="text" id="noteTextArea" />
|
||||
<input type="text" id="noteNameInput" />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Note;
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Configuration, OpenAIApi } from "openai";
|
||||
|
||||
async function Complete(text) {
|
||||
document.body.style.cursor = "wait";
|
||||
|
||||
let initText = text;
|
||||
|
||||
const configuration = new Configuration({
|
||||
apiKey: settings.openAiKey,
|
||||
});
|
||||
const openai = new OpenAIApi(configuration);
|
||||
const response = await openai.createCompletion({
|
||||
model: "text-davinci-003",
|
||||
prompt: initText,
|
||||
max_tokens: 1000,
|
||||
temperature: 1,
|
||||
top_p: 1,
|
||||
n: 1,
|
||||
stream: false,
|
||||
logprobs: null,
|
||||
});
|
||||
|
||||
document.body.style.cursor = "default";
|
||||
|
||||
return initText + response.data.choices[0].text;
|
||||
}
|
||||
|
||||
export { Complete };
|
|
@ -1,194 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* eslint-disable react-refresh/only-export-components */
|
||||
import { CheckBox } from "./checkbox";
|
||||
import { inputStyle, settingsAddInput } from "./styles";
|
||||
import { ButtonWithIcon } from "./button";
|
||||
import { Complete } from "../components/openai";
|
||||
import { DocumentTextIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
function SettingsCheckBox({ label, title, className, settingName, onClick }) {
|
||||
return (
|
||||
<CheckBox
|
||||
label={label}
|
||||
title={title}
|
||||
checked={settings[settingName]}
|
||||
className={className}
|
||||
onClick={(e) => {
|
||||
!!settingName && setSetting(settingName, e.target.checked);
|
||||
!!onClick && onClick(e);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function SettingsTextInput({
|
||||
placeholder,
|
||||
title,
|
||||
label,
|
||||
className,
|
||||
settingName,
|
||||
onChange,
|
||||
secret,
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<label className="block mb-2 text-base font-medium text-gray-700 dark:text-white">
|
||||
{label}
|
||||
</label>
|
||||
<input
|
||||
className={`${inputStyle} ${settingsAddInput} m-2 ${className}`}
|
||||
type={secret ? "password" : "text"}
|
||||
placeholder={placeholder}
|
||||
title={title}
|
||||
autoComplete="new-password"
|
||||
defaultValue={window.settings[settingName]}
|
||||
onChange={(e) => {
|
||||
!!settingName && setSetting(settingName, e.target.value);
|
||||
!!onChange && onChange(e);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function setSetting(settingName, value) {
|
||||
window.settings[settingName] = value;
|
||||
localStorage.setObj("settings", window.settings);
|
||||
}
|
||||
|
||||
function SettingsSelectInput({
|
||||
label,
|
||||
className,
|
||||
settingName,
|
||||
options,
|
||||
onChange,
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<label className="block mb-2 text-base font-medium text-gray-700 dark:text-white">
|
||||
{label}
|
||||
</label>
|
||||
<select
|
||||
className={`${inputStyle} ${settingsAddInput} m-2 ${className}`}
|
||||
defaultValue={window.settings[settingName]}
|
||||
onChange={(e) => {
|
||||
!!settingName && setSetting(settingName, e.target.value);
|
||||
!!onChange && onChange(e);
|
||||
}}
|
||||
>
|
||||
{options.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SettingsSection({ name, children }) {
|
||||
return (
|
||||
<div className="ml-0 lg:ml-6 mt-6 lg:mt-3">
|
||||
<h1 className="text-center lg:text-left leading-tight text-xl font-semibold">
|
||||
{name}
|
||||
</h1>
|
||||
<div className="ml-0 lg:ml-6 mt-6 lg:mt-3">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NoteNameInput({ value, onChange, preview = false }) {
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
className={`mb-2 md:w-1/6 w-full ${inputStyle} ${
|
||||
preview ? "hidden" : ""
|
||||
}`}
|
||||
placeholder={locals.NoteName}
|
||||
maxLength={64}
|
||||
defaultValue={value}
|
||||
onChange={onChange}
|
||||
id="noteNameInput"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function NoteTextArea({ value, onChange, preview = false }) {
|
||||
return (
|
||||
<textarea
|
||||
className={`
|
||||
${inputStyle}
|
||||
w-full
|
||||
${preview ? "hidden" : ""}
|
||||
`}
|
||||
rows="10"
|
||||
placeholder={locals.NotePlaceholder}
|
||||
maxLength={5000}
|
||||
onChange={onChange}
|
||||
defaultValue={value}
|
||||
id="noteTextArea"
|
||||
></textarea>
|
||||
);
|
||||
}
|
||||
|
||||
function NotesAdditionalSettings({
|
||||
noteText = localStorage.getItem("NoteText"),
|
||||
onClickAIComp,
|
||||
onClickCollabEdit,
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{settings.additionalFeatures && (
|
||||
<div className="justify-self-start lg:justify-self-start">
|
||||
<SettingsSection name={locals.AdditionalFeatures}>
|
||||
{!!settings.openAiKey && (
|
||||
<ButtonWithIcon
|
||||
icon={DocumentTextIcon}
|
||||
text={locals.AIComplete}
|
||||
className="m-1"
|
||||
w="w-full"
|
||||
onClick={async () => {
|
||||
let text = await Complete(noteText);
|
||||
document.getElementById("noteTextArea").value = text;
|
||||
|
||||
onClickAIComp(text);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<SettingsCheckBox
|
||||
label={locals.CollabEdit}
|
||||
settingName="CollabEdit"
|
||||
onClick={onClickCollabEdit}
|
||||
/>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export {
|
||||
SettingsCheckBox,
|
||||
SettingsTextInput,
|
||||
SettingsSelectInput,
|
||||
SettingsSection,
|
||||
setSetting,
|
||||
NoteNameInput,
|
||||
NoteTextArea,
|
||||
NotesAdditionalSettings,
|
||||
};
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { io } from "socket.io-client";
|
||||
import { reRenderPage } from "./utils";
|
||||
|
||||
const socket = io();
|
||||
|
||||
function onConnect() {
|
||||
console.log("Socket connected");
|
||||
}
|
||||
|
||||
function onDisconnect() {
|
||||
console.log("Socket disconnected, local mode only");
|
||||
window.alreadyConnected = false;
|
||||
}
|
||||
|
||||
function onFooEvent() {
|
||||
console.log("bar");
|
||||
}
|
||||
|
||||
function onSync({ settings, Notes, NoteText, NoteName }) {
|
||||
localStorage.setItem("Notes", Notes);
|
||||
localStorage.setItem("NoteText", NoteText);
|
||||
localStorage.setItem("NoteName", NoteName);
|
||||
localStorage.setItem("settings", settings);
|
||||
reRenderPage();
|
||||
}
|
||||
|
||||
socket.on("connect", onConnect);
|
||||
socket.on("disconnect", onDisconnect);
|
||||
socket.on("foo", onFooEvent);
|
||||
socket.on("broadcastSync", onSync);
|
||||
|
||||
export default socket;
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
let inputStyle =
|
||||
"block px-3 py-1.5 text-base font-normal text-gray-700 dark:text-white bg-white dark:bg-zinc-900 bg-clip-padding border border-solid border-gray-300 rounded-lg transition ease-in-out focus:border-blue-600 focus:outline-none";
|
||||
let settingsAddInput = "w-full lg:w-1/4";
|
||||
|
||||
export { inputStyle, settingsAddInput };
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Locales } from "../localisation/main";
|
||||
|
||||
function timestamp2text(time) {
|
||||
time = new Date(time);
|
||||
return time.toLocaleString(settings.language);
|
||||
}
|
||||
|
||||
function reRenderPage() {
|
||||
window.dispatchEvent(new Event("reRenderPage"));
|
||||
}
|
||||
|
||||
function localesProcess(reRender) {
|
||||
let locale =
|
||||
window.settings.language ||
|
||||
navigator.language ||
|
||||
navigator.userLanguage ||
|
||||
"en-US";
|
||||
|
||||
let lang = locale.split("-")[0];
|
||||
|
||||
let localeObj = Object.assign({}, Locales.en);
|
||||
Object.assign(localeObj, Locales[lang]);
|
||||
Object.assign(localeObj, Locales[locale]);
|
||||
|
||||
window.locals = localeObj;
|
||||
|
||||
if (reRender) reRenderPage();
|
||||
}
|
||||
|
||||
async function getNetLocale(lang, fileName) {
|
||||
return (await (await fetch(`localisation/${lang}/${fileName}`)).text()) || "";
|
||||
}
|
||||
|
||||
function nameUpdate(val) {
|
||||
socket.emit("nameChanged", {
|
||||
name: val,
|
||||
room: settings.CollabEditPassword,
|
||||
});
|
||||
window.lastSocketUpdate = Date.now();
|
||||
}
|
||||
|
||||
function textUpdate(val) {
|
||||
socket.emit("textChanged", {
|
||||
text: val,
|
||||
room: settings.CollabEditPassword,
|
||||
});
|
||||
window.lastSocketUpdate = Date.now();
|
||||
}
|
||||
|
||||
function collab_edit_init(setName, setText, saveToLocalStorage = true) {
|
||||
if (settings.CollabEdit === true) {
|
||||
if (!window.alreadyConnected) {
|
||||
socket.emit("joinRoom", settings.CollabEditPassword);
|
||||
window.alreadyConnected = true;
|
||||
window.lastSocketUpdate = Date.now();
|
||||
window.socketTimeout = 100;
|
||||
window.nameChanged = false;
|
||||
window.textChanged = false;
|
||||
|
||||
setInterval(() => {
|
||||
if (window.nameChanged) {
|
||||
nameUpdate(window.nameChanged);
|
||||
window.nameChanged = false;
|
||||
}
|
||||
|
||||
if (window.textChanged) {
|
||||
textUpdate(window.textChanged);
|
||||
window.textChanged = false;
|
||||
}
|
||||
}, window.socketTimeout);
|
||||
}
|
||||
|
||||
socket.on("textChanged", (data) => {
|
||||
setText(data.text);
|
||||
if (saveToLocalStorage) localStorage.setItem("NoteText", data.text);
|
||||
document.getElementById("noteTextArea").value = data.text;
|
||||
});
|
||||
|
||||
socket.on("nameChanged", (data) => {
|
||||
setName(data.name);
|
||||
if (saveToLocalStorage) localStorage.setItem("NoteName", data.name);
|
||||
document.getElementById("noteNameInput").value = data.name;
|
||||
});
|
||||
|
||||
socket.on("roomJoined", () => {
|
||||
nameUpdate(localStorage.getItem("NoteName"), true);
|
||||
textUpdate(localStorage.getItem("NoteText"), true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
timestamp2text,
|
||||
reRenderPage,
|
||||
localesProcess,
|
||||
getNetLocale,
|
||||
collab_edit_init,
|
||||
nameUpdate,
|
||||
textUpdate,
|
||||
};
|
118
src/index.css
118
src/index.css
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
/* styles for displaying markdown */
|
||||
.md h1 {
|
||||
@apply text-6xl;
|
||||
}
|
||||
.md h2 {
|
||||
@apply text-5xl;
|
||||
}
|
||||
.md h3 {
|
||||
@apply text-4xl;
|
||||
}
|
||||
.md h4 {
|
||||
@apply text-3xl;
|
||||
}
|
||||
.md h5 {
|
||||
@apply text-2xl;
|
||||
}
|
||||
.md h6 {
|
||||
@apply text-xl;
|
||||
}
|
||||
|
||||
.md blockquote {
|
||||
@apply border-l-4 pl-2 rounded-lg ml-4 mt-2 mb-2;
|
||||
@apply bg-zinc-200 border-zinc-400;
|
||||
@apply dark:bg-zinc-800 dark:border-zinc-600;
|
||||
@apply pb-2;
|
||||
}
|
||||
|
||||
.md hr {
|
||||
@apply mb-4 mt-4 border-2 rounded-lg;
|
||||
}
|
||||
|
||||
.md ul {
|
||||
@apply list-disc list-inside ml-4;
|
||||
}
|
||||
|
||||
.md li ul {
|
||||
@apply list-disc list-inside;
|
||||
}
|
||||
|
||||
.md ol {
|
||||
@apply list-decimal list-inside ml-4;
|
||||
}
|
||||
|
||||
.md li ol {
|
||||
@apply list-decimal list-inside ml-4;
|
||||
}
|
||||
|
||||
.md-code {
|
||||
@apply p-1;
|
||||
@apply rounded-lg;
|
||||
@apply bg-zinc-200 border-zinc-400;
|
||||
@apply dark:bg-zinc-800 dark:border-zinc-600 overflow-auto;
|
||||
}
|
||||
|
||||
.md a {
|
||||
@apply inline-block bg-transparent text-blue-600;
|
||||
}
|
||||
|
||||
.md table {
|
||||
@apply w-full lg:w-1/2;
|
||||
border-style: hidden;
|
||||
}
|
||||
|
||||
.md table thead {
|
||||
@apply bg-zinc-200 dark:bg-zinc-800;
|
||||
}
|
||||
|
||||
.md table tr {
|
||||
@apply border-2 border-zinc-400;
|
||||
}
|
||||
|
||||
.md img {
|
||||
@apply w-96 ease-[cubic-bezier(.69,.58,.32,1.69)] hover:scale-105 rounded-2xl hover:drop-shadow-2xl transition duration-500 lg:ml-5;
|
||||
}
|
||||
|
||||
.md .math-inline {
|
||||
display: inline-block;
|
||||
}
|
||||
.md li p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* other styles */
|
||||
|
||||
.blog-pre {
|
||||
@apply mt-2 mb-2 relative;
|
||||
}
|
||||
|
||||
.code-copy-btn {
|
||||
@apply text-zinc-400 dark:text-zinc-300 absolute right-2 top-2 cursor-pointer;
|
||||
}
|
||||
|
||||
.code-copy-btn:hover {
|
||||
@apply text-zinc-500 dark:text-zinc-400;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getNetLocale } from "../components/utils";
|
||||
|
||||
let en = {
|
||||
about_md: await getNetLocale("en", "about.md"),
|
||||
Notes: "Notes",
|
||||
Write: "Write",
|
||||
Chat: "Chat",
|
||||
Settings: "Settings",
|
||||
About: "About",
|
||||
Name: "Name",
|
||||
UserName: "Username",
|
||||
User: "User",
|
||||
PhotoUrl: "Photo URL",
|
||||
Url: "URL",
|
||||
Status: "Status",
|
||||
UserStatus: "User status",
|
||||
EditPreview: "Editing in preview",
|
||||
EditPreviewWarn:
|
||||
"Can cause irreversible text changes, such as breaking code tags",
|
||||
PublicNote: "Public note",
|
||||
PublicNoteTitle: "If enabled, note will be visible to all users",
|
||||
Interface: "Interface",
|
||||
Language: "Language",
|
||||
ThirdPartyApi: "Third party API",
|
||||
OpenAiKey: "OpenAI API key",
|
||||
Key: "Key",
|
||||
Preview: "Preview",
|
||||
NotePlaceholder:
|
||||
"Your note starts here. You can use markdown, MathJax and GFM.",
|
||||
NoteName: "Note name",
|
||||
Publish: "Publish",
|
||||
Save: "Save",
|
||||
WriteNote: "Write note",
|
||||
PubError: "Error in publishing note",
|
||||
PubErrorMsg: "Note was not published due to an unknown error",
|
||||
PubErrorMsgNoName: "Note was not published, because it does not have a name.",
|
||||
PubErrorMsgNoText: "Note was not published, because it does not have a text.",
|
||||
Back: "Back",
|
||||
PubNoteNotExist: "This note does not exist",
|
||||
NoteNotExist: "This note does not exist",
|
||||
Idontexists: "I don't exist",
|
||||
PubUrlPlaceholder:
|
||||
"The link to send a public note. When you click this link, the note will disappear from the server and be saved locally.",
|
||||
Delete: "Delete",
|
||||
Open: "Open",
|
||||
NoNotesYet: "No notes yet",
|
||||
AIComplete: "Continue Note (AI)",
|
||||
AdditionalFeatures: "Additional features",
|
||||
CollabEdit: "Collaborative editing",
|
||||
Password: "Password",
|
||||
SyncPassword: "Sync password",
|
||||
CollabEditPassword: "Password for collaborative editing",
|
||||
BroadcastSync: "Getting notes, settings from another device",
|
||||
SyncAll: "Send data to all devices",
|
||||
Sync: "Sync",
|
||||
Search: "Search",
|
||||
NoNotesFound: "No notes found",
|
||||
LocalNote: "Local",
|
||||
Menu: "Menu",
|
||||
SourceCode: "Source code",
|
||||
Edit: "Edit",
|
||||
};
|
||||
|
||||
export default en;
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//translated with Google Translate
|
||||
//if you want to help with translations, please contribute to this project
|
||||
|
||||
let eo = {
|
||||
Notes: "Notoj",
|
||||
Write: "Skribu",
|
||||
Chat: "Babilejo",
|
||||
Settings: "Agordoj",
|
||||
About: "Pri",
|
||||
Name: "Nomo",
|
||||
UserName: "Uzantnomo",
|
||||
User: "Uzanto",
|
||||
PhotoUrl: "Foto URL",
|
||||
Url: "url",
|
||||
Status: "Statuso",
|
||||
UserStatus: "Uzanto -Statuso",
|
||||
EditPreview: "Redaktado en Antaŭrigardo",
|
||||
EditPreviewWarn:
|
||||
"Povas kaŭzi neinversigeblajn tekstajn ŝanĝojn, kiel rompi kodajn etikedojn",
|
||||
PublicNote: "Publika Noto",
|
||||
PublicNoteTitle: "Se ebligita, noto estos videbla por ĉiuj uzantoj",
|
||||
Interface: "Interfaco",
|
||||
Language: "Lingvo",
|
||||
ThirdPartyApi: "Tria API",
|
||||
OpenAiKey: "OpenAI API ŝlosilo",
|
||||
Key: "Ŝlosilo",
|
||||
Preview: "Antaŭrigardo",
|
||||
NotePlaceholder:
|
||||
"Via noto komenciĝas ĉi tie.Vi povas uzi Markdown, Mathjax kaj GFM.",
|
||||
NoteName: "Note nomo",
|
||||
Publish: "Publikigi",
|
||||
Save: "Savi",
|
||||
WriteNote: "Skribu Noton",
|
||||
PubError: "Eraro en Eldona Noto",
|
||||
PubErrorMsg: "Noto ne estis publikigita pro nekonata eraro",
|
||||
PubErrorMsgNoName: "Noto ne estis publikigita, ĉar ĝi ne havas nomon.",
|
||||
PubErrorMsgNoText: "Noto ne estis publikigita, ĉar ĝi ne havas tekston.",
|
||||
Back: "Reen",
|
||||
PubNoteNotExist: "Ĉi tiu noto ne ekzistas",
|
||||
NoteNotExist: "Ĉi tiu noto ne ekzistas",
|
||||
Idontexists: "Mi ne ekzistas",
|
||||
PubUrlPlaceholder:
|
||||
"La ligo por sendi publikan noton.Kiam vi alklakas ĉi tiun ligon, la noto malaperos de la servilo kaj estos konservita surloke.",
|
||||
Delete: "Forigi",
|
||||
Open: "Malferma",
|
||||
NoNotesYet: "Ankoraŭ neniuj notoj",
|
||||
AIComplete: "Daŭrigu Noton (AI)",
|
||||
AdditionalFeatures: "Pliaj Trajtoj",
|
||||
CollabEdit: "Kunlabora Redaktado",
|
||||
Password: "Pasvorto",
|
||||
SyncPassword: "Sinkrona pasvorto",
|
||||
CollabEditPassword: "Pasvorto por kunlabora redaktado",
|
||||
BroadcastSync: "Ricevante notojn, agordojn de alia aparato",
|
||||
SyncAll: "Sendado de datumoj",
|
||||
Sync: "Sinkronigi",
|
||||
Search: "Serĉo",
|
||||
NoNotesFound: "Neniuj notoj trovitaj",
|
||||
LocalNote: "Loka",
|
||||
PublishNote: "Publika",
|
||||
Menu: "Menuo",
|
||||
};
|
||||
|
||||
export default eo;
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//translated with Google Translate
|
||||
//if you want to help with translations, please contribute to this project
|
||||
|
||||
let es = {
|
||||
Notes: "Notas",
|
||||
Write: "Escribir",
|
||||
Chat: "Charlar",
|
||||
Settings: "Ajustes",
|
||||
About: "Acerca de",
|
||||
Name: "Nombre",
|
||||
UserName: "Nombre de usuario",
|
||||
User: "Usuaria",
|
||||
PhotoUrl: "URL fotográfica",
|
||||
Url: "Url",
|
||||
Status: "Estado",
|
||||
UserStatus: "Estatus de usuario",
|
||||
EditPreview: "Edición en vista previa",
|
||||
EditPreviewWarn:
|
||||
"Puede causar cambios de texto irreversibles, como etiquetas de código de ruptura",
|
||||
PublicNote: "Nota pública",
|
||||
PublicNoteTitle:
|
||||
"Si está habilitado, Note será visible para todos los usuarios",
|
||||
Interface: "Interfaz",
|
||||
Language: "Idioma",
|
||||
ThirdPartyApi: "API de terceros",
|
||||
OpenAiKey: "Clave de API de OpenAI",
|
||||
Key: "Llave",
|
||||
Preview: "Avance",
|
||||
NotePlaceholder: "Tu nota comienza aquí.Puede usar Markdown, MathJax y GFM.",
|
||||
NoteName: "Nombre de nota",
|
||||
Publish: "Publicar",
|
||||
Save: "Ahorrar",
|
||||
WriteNote: "Toma nota",
|
||||
PubError: "Error en la nota de publicación",
|
||||
PubErrorMsg: "La nota no se publicó debido a un error desconocido",
|
||||
PubErrorMsgNoName: "No se publicó una nota, porque no tiene un nombre.",
|
||||
PubErrorMsgNoText: "La nota no se publicó, porque no tiene un texto.",
|
||||
Back: "Atrás",
|
||||
PubNoteNotExist: "Esta nota no existe",
|
||||
NoteNotExist: "Esta nota no existe",
|
||||
Idontexists: "No existe",
|
||||
PubUrlPlaceholder:
|
||||
"El enlace para enviar una nota pública.Cuando haga clic en este enlace, la nota desaparecerá del servidor y se guardará localmente.",
|
||||
Delete: "Borrar",
|
||||
Open: "Abierto",
|
||||
NoNotesYet: "No hay notas todavía",
|
||||
AIComplete: "Continuar nota (ai)",
|
||||
AdditionalFeatures: "Características adicionales",
|
||||
CollabEdit: "Edición colaborativa",
|
||||
Password: "Contraseña",
|
||||
SyncPassword: "Sincronización de contraseña",
|
||||
CollabEditPassword: "Contraseña para edición colaborativa",
|
||||
BroadcastSync: "Obtener notas, configuraciones de otro dispositivo",
|
||||
SyncAll: "Envío de datos",
|
||||
Sync: "Sincronización",
|
||||
Search: "Buscar",
|
||||
NoNotesFound: "No se encontraron notas",
|
||||
LocalNote: "Local",
|
||||
PublishNote: "Pública",
|
||||
Menu: "Menú",
|
||||
};
|
||||
|
||||
export default es;
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//translated with Google Translate
|
||||
//if you want to help with translations, please contribute to this project
|
||||
|
||||
let ja = {
|
||||
Notes: "ノート",
|
||||
Write: "書く",
|
||||
Chat: "チャット",
|
||||
Settings: "設定",
|
||||
About: "だいたい",
|
||||
Name: "名前",
|
||||
UserName: "ユーザー名",
|
||||
User: "ユーザー",
|
||||
PhotoUrl: "写真の URL",
|
||||
Url: "URL",
|
||||
Status: "スターテス",
|
||||
UserStatus: "ユーザーステータス",
|
||||
EditPreview: "プレビューでの編集",
|
||||
EditPreviewWarn:
|
||||
"コードタグの破損など、元に戻せないテキスト変更を引き起こす可能性があります",
|
||||
PublicNote: "公開メモ",
|
||||
PublicNoteTitle: "有効にすると、メモはすべてのユーザーに表示されます",
|
||||
Interface: "インターフェース",
|
||||
Language: "言語",
|
||||
ThirdPartyApi: "サードパーティ API",
|
||||
OpenAiKey: "OpenAI API キー",
|
||||
Key: "鍵",
|
||||
Preview: "プレビュー",
|
||||
NotePlaceholder:
|
||||
"あなたのメモはここから始まります。マークダウン、MathJax、GFM を使用できます。",
|
||||
NoteName: "音名",
|
||||
Publish: "公開",
|
||||
Save: "保存",
|
||||
WriteNote: "記帳",
|
||||
PubError: "メモの公開エラー",
|
||||
PubErrorMsg: "不明なエラーのため、ノートは公開されませんでした",
|
||||
PubErrorMsgNoName: "名前がないため、ノートは公開されませんでした。",
|
||||
PubErrorMsgNoText: "テキストがないため、ノートは公開されませんでした。",
|
||||
Back: "戻る",
|
||||
PubNoteNotExist: "このメモは存在しません",
|
||||
NoteNotExist: "このメモは存在しません",
|
||||
Idontexists: "私は存在しません",
|
||||
PubUrlPlaceholder:
|
||||
"公開メモを送信するためのリンク。このリンクをクリックすると、メモはサーバーから消え、ローカルに保存されます。",
|
||||
Delete: "消去",
|
||||
Open: "開ける",
|
||||
NoNotesYet: "メモはまだありません",
|
||||
AIComplete: "継続評価 (AI)",
|
||||
AdditionalFeatures: "追加機能",
|
||||
CollabEdit: "共同編集",
|
||||
Password: "パスワード",
|
||||
SyncPassword: "パスワードを同期",
|
||||
CollabEditPassword: "共同編集用パスワード",
|
||||
BroadcastSync: "別のデバイスからメモ、設定を取得する",
|
||||
SyncAll: "すべてのデバイスにデータを送信",
|
||||
Sync: "同期",
|
||||
Search: "検索",
|
||||
NoNotesFound: "メモが見つかりません",
|
||||
LocalNote: "地元",
|
||||
PublishNote: "公共",
|
||||
Menu: "メニュー",
|
||||
};
|
||||
|
||||
export default ja;
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import ru from "./ru";
|
||||
import en from "./en";
|
||||
import es from "./es";
|
||||
import eo from "./eo";
|
||||
import ja from "./ja";
|
||||
import zh from "./zh";
|
||||
|
||||
let Locales = {
|
||||
ru,
|
||||
en,
|
||||
es,
|
||||
eo,
|
||||
ja,
|
||||
zh,
|
||||
};
|
||||
|
||||
let langChoices = [
|
||||
{
|
||||
value: "ru-RU",
|
||||
label: "Русский",
|
||||
},
|
||||
{
|
||||
value: "en-US",
|
||||
label: "English (US)",
|
||||
},
|
||||
{
|
||||
value: "es",
|
||||
label: "Español",
|
||||
},
|
||||
{
|
||||
value: "eo",
|
||||
label: "Esperanto",
|
||||
},
|
||||
{
|
||||
value: "ja-JP",
|
||||
label: "日本語",
|
||||
},
|
||||
{
|
||||
value: "zh-CN",
|
||||
label: "中国人",
|
||||
},
|
||||
];
|
||||
|
||||
export { Locales, langChoices };
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getNetLocale } from "../components/utils";
|
||||
|
||||
let ru = {
|
||||
about_md: await getNetLocale("ru", "about.md"),
|
||||
Notes: "Заметки",
|
||||
Write: "Написать",
|
||||
Chat: "Чат",
|
||||
Settings: "Настройки",
|
||||
About: "Подробнее",
|
||||
Name: "Имя",
|
||||
UserName: "Имя пользователя",
|
||||
User: "Пользователь",
|
||||
PhotoUrl: "Ссылка на фото",
|
||||
Url: "Ссылка",
|
||||
Status: "Статус",
|
||||
UserStatus: "Статус пользователя",
|
||||
EditPreview: "Редактирование в предпросмотре",
|
||||
EditPreviewWarn:
|
||||
"Может вызывать необратимые изменения текста, например ломает теги кода",
|
||||
PublicNote: "Публичная заметка",
|
||||
PublicNoteTitle: "Если включено, то заметка будет видна всем пользователям",
|
||||
Interface: "Интерфейс",
|
||||
Language: "Язык",
|
||||
ThirdPartyApi: "Сторонний API",
|
||||
OpenAiKey: "OpenAI API ключ",
|
||||
Key: "Ключ",
|
||||
Preview: "Предпросмотр",
|
||||
NotePlaceholder:
|
||||
"Ваша заметка начинается здесь. Вы можете использовать markdown, MathJax и GFM.",
|
||||
NoteName: "Название заметки",
|
||||
Publish: "Опубликовать",
|
||||
Save: "Сохранить",
|
||||
WriteNote: "Написать заметку",
|
||||
PubError: "Ошибка в публикации заметки",
|
||||
PubErrorMsg: "Заметка не была опубликована из-за неизвестной ошибки",
|
||||
PubErrorMsgNoName:
|
||||
"Заметка не была опубликована, так как отсутствует название.",
|
||||
PubErrorMsgNoText: "Заметка не была опубликована, так как отсутствует текст.",
|
||||
Back: "Назад",
|
||||
PubNoteNotExist: "Такой публичной заметки не существует",
|
||||
NoteNotExist: "Заметки не существует",
|
||||
Idontexists: "Меня не существует",
|
||||
PubUrlPlaceholder:
|
||||
"Ссылка для отправки публичной заметки. При переходе на эту ссылку, заметка исчезнет с сервера и будет сохранена локально.",
|
||||
Delete: "Удалить",
|
||||
Open: "Открыть",
|
||||
NoNotesYet: "Заметок пока нет",
|
||||
AIComplete: "Продолжить заметку (ИИ)",
|
||||
AdditionalFeatures: "Дополнительные функции",
|
||||
CollabEdit: "Совместное редактирование",
|
||||
Password: "Пароль",
|
||||
CollabEditPassword: "Пароль для совместного редактирования",
|
||||
SyncPassword: "Пароль для синхронизации",
|
||||
BroadcastSync: "Получение заметок, настроек с другого устройства",
|
||||
SyncAll: "Отправить данные",
|
||||
Sync: "Синхронизация",
|
||||
Search: "Поиск",
|
||||
NoNotesFound: "Заметок не найдено",
|
||||
LocalNote: "Локальная",
|
||||
PublishNote: "Публичная",
|
||||
Menu: "Меню",
|
||||
SourceCode: "Исходный код",
|
||||
Edit: "Изменить",
|
||||
};
|
||||
|
||||
export default ru;
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//translated with Google Translate
|
||||
//if you want to help with translations, please contribute to this project
|
||||
|
||||
let zh = {
|
||||
Notes: "笔记",
|
||||
Write: "写",
|
||||
Chat: "聊天",
|
||||
Settings: "设置",
|
||||
About: "关于",
|
||||
Name: "姓名",
|
||||
UserName: "用户名",
|
||||
User: "用户",
|
||||
PhotoUrl: "照片网址",
|
||||
Url: "网址",
|
||||
Status: "地位",
|
||||
UserStatus: "用户状态",
|
||||
EditPreview: "在预览中编辑",
|
||||
EditPreviewWarn: "可能导致不可逆转的文本更改,例如破坏代码标签",
|
||||
PublicNote: "公众号",
|
||||
PublicNoteTitle: "如果启用,注释将对所有用户可见",
|
||||
Interface: "界面",
|
||||
Language: "语言",
|
||||
ThirdPartyApi: "第三方接口",
|
||||
OpenAiKey: "OpenAI API 密钥",
|
||||
Key: "钥匙",
|
||||
Preview: "预览",
|
||||
NotePlaceholder: "你的笔记从这里开始。你可以使用 markdown、MathJax 和 GFM。",
|
||||
NoteName: "笔记名称",
|
||||
Publish: "发布",
|
||||
Save: "节省",
|
||||
WriteNote: "写笔记",
|
||||
PubError: "发布笔记时出错",
|
||||
PubErrorMsg: "由于未知错误,笔记未发布",
|
||||
PubErrorMsgNoName: "注释未发布,因为它没有名称。",
|
||||
PubErrorMsgNoText: "注释未发布,因为它没有文本。",
|
||||
Back: "后退",
|
||||
PubNoteNotExist: "此备注不存在",
|
||||
NoteNotExist: "此备注不存在",
|
||||
Idontexists: "我不存在",
|
||||
PubUrlPlaceholder:
|
||||
"发送公共笔记的链接。当您单击此链接时,该笔记将从服务器上消失并保存在本地。",
|
||||
Delete: "删除",
|
||||
Open: "打开",
|
||||
NoNotesYet: "还没有笔记",
|
||||
AIComplete: "继续评级 (AI)",
|
||||
AdditionalFeatures: "附加功能",
|
||||
CollabEdit: "协同编辑",
|
||||
Password: "密码",
|
||||
SyncPassword: "同步密码",
|
||||
CollabEditPassword: "协同编辑密码",
|
||||
BroadcastSync: "从另一台设备获取笔记、设置",
|
||||
SyncAll: "向所有设备发送数据",
|
||||
Sync: "同步",
|
||||
Search: "搜索",
|
||||
NoNotesFound: "找不到笔记",
|
||||
LocalNote: "当地的",
|
||||
PublishNote: "民众",
|
||||
Menu: "菜单",
|
||||
};
|
||||
|
||||
export default zh;
|
30
src/main.jsx
30
src/main.jsx
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import App from "./App";
|
||||
import "./index.css";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")).render(
|
||||
<React.StrictMode>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</React.StrictMode>
|
||||
);
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
||||
import { CheckBox } from "../components/checkbox";
|
||||
import { useState } from "react";
|
||||
import RenderMarkdown from "../components/markdown";
|
||||
import {
|
||||
collab_edit_init,
|
||||
timestamp2text,
|
||||
textUpdate,
|
||||
} from "../components/utils";
|
||||
import rehypeRemark from "rehype-remark/lib";
|
||||
import ContentEditable from "react-contenteditable";
|
||||
import ReactDOMServer from "react-dom/server";
|
||||
import { unified } from "unified";
|
||||
import rehypeParse from "rehype-parse";
|
||||
import remarkStringify from "remark-stringify";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import remarkMath from "remark-math";
|
||||
import {
|
||||
NoteNameInput,
|
||||
NoteTextArea,
|
||||
NotesAdditionalSettings,
|
||||
SettingsCheckBox,
|
||||
} from "../components/settingsInputs";
|
||||
|
||||
function CreateNote() {
|
||||
const [preview, setPreview] = useState(false);
|
||||
const [publicState, setPublicState] = useState(settings.publicNote);
|
||||
const [text, setText] = useState(localStorage.getItem("NoteText"));
|
||||
const [name, setName] = useState(localStorage.getItem("NoteName"));
|
||||
|
||||
async function previewChange(val) {
|
||||
let md = await unified()
|
||||
.use(remarkGfm)
|
||||
.use(remarkMath)
|
||||
.use(rehypeParse)
|
||||
.use(rehypeRemark)
|
||||
.use(remarkStringify)
|
||||
.process(val.target.value);
|
||||
|
||||
md = md.value.trim();
|
||||
|
||||
localStorage.setItem("NoteText", md);
|
||||
|
||||
if (settings.CollabEdit === true) {
|
||||
socket.emit("textChanged", {
|
||||
text: md,
|
||||
room: settings.CollabEditPassword,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
collab_edit_init(setName, setText, false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="text-center lg:text-left leading-tight text-2xl font-bold">
|
||||
{`${preview ? "" : locals.WriteNote}`}
|
||||
</h2>
|
||||
<CheckBox
|
||||
className="justify-self-center lg:justify-self-end"
|
||||
label={locals.Preview}
|
||||
id="preview"
|
||||
onClick={(val) => {
|
||||
setText(localStorage.getItem("NoteText"));
|
||||
setPreview(val.target.checked);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<NoteNameInput
|
||||
value={localStorage.getItem("NoteName") || ""}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
localStorage.setItem("NoteName", e.target.value);
|
||||
window.nameChanged = e.target.value;
|
||||
}}
|
||||
preview={preview}
|
||||
/>
|
||||
|
||||
<NoteTextArea
|
||||
value={localStorage.getItem("NoteText") || ""}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value);
|
||||
localStorage.setItem("NoteText", e.target.value);
|
||||
window.textChanged = e.target.value;
|
||||
}}
|
||||
preview={preview}
|
||||
/>
|
||||
|
||||
{preview && (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="font-medium text-center lg:text-left leading-tight text-4xl mt-0 mb-2">
|
||||
{name}
|
||||
</h2>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
{timestamp2text(Date.now())}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{preview && (
|
||||
<div className="w-full md break-words">
|
||||
<ContentEditable
|
||||
disabled={!window.settings.editPreview}
|
||||
onChange={previewChange}
|
||||
html={ReactDOMServer.renderToString(
|
||||
<RenderMarkdown>{text}</RenderMarkdown>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full">
|
||||
<SettingsCheckBox
|
||||
label={locals.PublicNote}
|
||||
title={locals.PublicNoteTitle}
|
||||
checked={settings.publicNote}
|
||||
settingName="publicNote"
|
||||
className="justify-self-center lg:justify-self-start"
|
||||
onClick={(val) => {
|
||||
setPublicState(val.target.checked);
|
||||
}}
|
||||
/>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
<ButtonWithIcon
|
||||
icon={ChevronDoubleRightIcon}
|
||||
text={publicState ? locals.Publish : locals.Save}
|
||||
reverse={true}
|
||||
href={publicState ? "/notes/publish" : "/notes/save-local"}
|
||||
className="m-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<NotesAdditionalSettings
|
||||
onClickAIComp={(text) => {
|
||||
localStorage.setItem("NoteText", text);
|
||||
setText(text);
|
||||
|
||||
if (settings.CollabEdit === true) {
|
||||
textUpdate(text);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CreateNote;
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useParams } from "react-router-dom";
|
||||
import {
|
||||
ArchiveBoxArrowDownIcon,
|
||||
ChevronDoubleLeftIcon,
|
||||
ChevronDoubleRightIcon,
|
||||
PencilIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import Note from "../components/note";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
NoteNameInput,
|
||||
NoteTextArea,
|
||||
NotesAdditionalSettings,
|
||||
} from "../components/settingsInputs";
|
||||
import { collab_edit_init, nameUpdate, textUpdate } from "../components/utils";
|
||||
|
||||
function NotePage() {
|
||||
let params = useParams();
|
||||
|
||||
let notes = localStorage.getObj("Notes");
|
||||
let note = notes[params.id];
|
||||
|
||||
let [edit, setEdit] = useState(false);
|
||||
let [text, setText] = useState(note.text);
|
||||
let [name, setName] = useState(note.name);
|
||||
|
||||
collab_edit_init(setName, setText, false);
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<ButtonWithIcon
|
||||
icon={ChevronDoubleLeftIcon}
|
||||
className="mb-4"
|
||||
href="/notes"
|
||||
text={locals.Notes}
|
||||
/>
|
||||
|
||||
{note ? (
|
||||
edit ? (
|
||||
<>
|
||||
<NoteNameInput
|
||||
value={name}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
window.nameChanged = e.target.value;
|
||||
}}
|
||||
/>
|
||||
<NoteTextArea
|
||||
value={text}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value);
|
||||
window.textChanged = e.target.value;
|
||||
}}
|
||||
/>
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 justify-items-center w-full">
|
||||
<NotesAdditionalSettings
|
||||
noteText={text}
|
||||
onClickAIComp={(text) => {
|
||||
setText(text);
|
||||
if (settings.CollabEdit === true) {
|
||||
textUpdate(text);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Note note={note} />
|
||||
)
|
||||
) : (
|
||||
<div>{locals.NoteNotExists}</div>
|
||||
)}
|
||||
{note && (
|
||||
<div className="grid grid-cols-1">
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
<ButtonWithIcon
|
||||
className="mt-4"
|
||||
text={edit ? locals.Save : locals.Edit}
|
||||
icon={edit ? ArchiveBoxArrowDownIcon : PencilIcon}
|
||||
onClick={() => {
|
||||
if (edit) {
|
||||
notes[params.id].name = name;
|
||||
notes[params.id].text = text;
|
||||
localStorage.setObj("Notes", notes);
|
||||
} else {
|
||||
if (settings.CollabEdit === true) {
|
||||
textUpdate(notes[params.id].text);
|
||||
nameUpdate(notes[params.id].name);
|
||||
}
|
||||
}
|
||||
|
||||
setEdit(!edit);
|
||||
}}
|
||||
/>
|
||||
|
||||
{!edit && (
|
||||
<>
|
||||
<ButtonWithIcon
|
||||
className="mt-4"
|
||||
text={locals.Publish}
|
||||
icon={ChevronDoubleRightIcon}
|
||||
href={`/notes/publish?local_id=${params.id}`}
|
||||
/>
|
||||
<ButtonWithIcon
|
||||
className="mt-4"
|
||||
href="/notes"
|
||||
text={locals.Delete}
|
||||
icon={TrashIcon}
|
||||
onClick={() => {
|
||||
let notesObj = localStorage.getObj("Notes");
|
||||
|
||||
delete notesObj[params.id];
|
||||
|
||||
localStorage.setObj("Notes", notesObj);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default NotePage;
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
||||
import { timestamp2text } from "../components/utils";
|
||||
import Fuse from "fuse.js";
|
||||
import { inputStyle } from "../components/styles";
|
||||
import { useState } from "react";
|
||||
import { setSetting } from "../components/settingsInputs";
|
||||
import RemoveMarkdown from "remove-markdown";
|
||||
|
||||
function Notes() {
|
||||
if (!settings.newNotes) {
|
||||
let notesObj = localStorage.getObj("Notes");
|
||||
let notes = Object.entries(notesObj);
|
||||
for (let [id, note] of notes) {
|
||||
note.id = id;
|
||||
note.textTime = timestamp2text(note.time);
|
||||
notesObj[id] = note;
|
||||
}
|
||||
localStorage.setObj("Notes", notesObj);
|
||||
setSetting("newNotes", true);
|
||||
}
|
||||
|
||||
let n = Object.values(localStorage.getObj("Notes"));
|
||||
|
||||
const [search, setSearch] = useState("");
|
||||
const [indexed, setIndexed] = useState(false);
|
||||
|
||||
if (search && !indexed) {
|
||||
window.fuseIndex = new Fuse(n, {
|
||||
includeScore: true,
|
||||
useExtendedSearch: true,
|
||||
keys: [
|
||||
"name",
|
||||
"textTime",
|
||||
{
|
||||
name: "text",
|
||||
getFn: (obj) => RemoveMarkdown(obj.text),
|
||||
},
|
||||
],
|
||||
});
|
||||
setIndexed(true);
|
||||
}
|
||||
|
||||
let found = search === "" ? n : window.fuseIndex.search(search);
|
||||
|
||||
if (search !== "") {
|
||||
found = found
|
||||
.sort((a, b) => {
|
||||
return a.score - b.score;
|
||||
})
|
||||
.map(({ item }) => item);
|
||||
} else {
|
||||
found = found.sort((a, b) => {
|
||||
return b.time - a.time;
|
||||
});
|
||||
}
|
||||
|
||||
let notes = found.map((item) => {
|
||||
return (
|
||||
<div
|
||||
className="grid grid-cols-1 lg:grid-cols-2 border border-blue-300 rounded-lg m-2 p-2 justify-items-start"
|
||||
key={item.id}
|
||||
>
|
||||
<div className="font-medium leading-tight text-4xl mt-0 mb-2">
|
||||
{item.name}
|
||||
</div>
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 justify-self-center lg:justify-self-end">
|
||||
<div className="text-center">{timestamp2text(item.time)}</div>
|
||||
<div className="">
|
||||
<ButtonWithIcon
|
||||
href={`/notes/${item.id}`}
|
||||
reverse={true}
|
||||
icon={ChevronDoubleRightIcon}
|
||||
text={locals.Open}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
if (n.length === 0) {
|
||||
return (
|
||||
<div className="md">
|
||||
<h3>{locals.NoNotesYet}</h3>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<input
|
||||
type="text"
|
||||
className={`mb-2 md:w-1/6 w-full ${inputStyle}`}
|
||||
placeholder={locals.Search}
|
||||
onChange={(e) => {
|
||||
setSearch(e.target.value);
|
||||
}}
|
||||
/>
|
||||
{notes}
|
||||
{found.length === 0 && (
|
||||
<div className="md">
|
||||
<h3>{locals.NoNotesFound}</h3>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Notes;
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { timestamp2text } from "../components/utils";
|
||||
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
|
||||
function PubError() {
|
||||
const [searchParams] = useSearchParams();
|
||||
let err = searchParams.get("err");
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<ButtonWithIcon
|
||||
className="mb-4"
|
||||
href="/"
|
||||
text={locals.Back}
|
||||
icon={ChevronDoubleLeftIcon}
|
||||
/>
|
||||
|
||||
<div className="border border-blue-300 rounded-lg p-4">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="font-medium text-center lg:text-left leading-tight text-4xl mt-0 mb-2">
|
||||
{locals.PubError}
|
||||
</h2>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
{timestamp2text(Date.now())}
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full md">{err ? err : locals.PubErrorMsg}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default PubError;
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import RenderMarkdown from "../components/markdown";
|
||||
import { useState } from "react";
|
||||
import { Navigate, useParams } from "react-router-dom";
|
||||
import { timestamp2text } from "../components/utils";
|
||||
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
|
||||
function PubNote() {
|
||||
let params = useParams();
|
||||
|
||||
let [note, setNote] = useState(false);
|
||||
|
||||
if (note === false)
|
||||
fetch(`/get-note/del/${params.id}`)
|
||||
.then((data) => {
|
||||
data
|
||||
.json()
|
||||
.then((data) => {
|
||||
setNote(data);
|
||||
})
|
||||
.catch(() => {
|
||||
setNote({
|
||||
text: "Такой публичной заметки не сущуествует",
|
||||
name: "Меня не существует",
|
||||
time: Date.now(),
|
||||
save: false,
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
setNote({
|
||||
text: "Такой публичной заметки не сущуествует",
|
||||
name: "Меня не существует",
|
||||
time: Date.now(),
|
||||
save: false,
|
||||
});
|
||||
});
|
||||
else {
|
||||
if (note.save !== false) {
|
||||
localStorage.setItem("NotePubTime", note.time);
|
||||
localStorage.setItem("NoteName", note.name);
|
||||
localStorage.setItem("NoteText", note.text);
|
||||
return <Navigate to="/notes/save-local" replace={true} />;
|
||||
} else {
|
||||
return (
|
||||
<div className="">
|
||||
<ButtonWithIcon
|
||||
className="mb-4"
|
||||
href="/"
|
||||
text="Писать"
|
||||
icon={ChevronDoubleLeftIcon}
|
||||
/>
|
||||
<div className="border border-blue-300 rounded-lg p-4">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="font-medium text-center lg:text-left leading-tight text-4xl mt-0 mb-2">
|
||||
{note.name || "Загрузка..."}
|
||||
</h2>
|
||||
<div className="justify-self-center lg:justify-self-end">
|
||||
{timestamp2text(note.time || Date.now())}
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full md break-words">
|
||||
<RenderMarkdown>{note.text || "Загрузка..."}</RenderMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default PubNote;
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import { CopyToClipboard } from "../components/copytocb";
|
||||
import Note from "../components/note";
|
||||
|
||||
function PubNoteSafe() {
|
||||
let params = useParams();
|
||||
|
||||
let [note, setNote] = useState(false);
|
||||
let nullNote = {
|
||||
text: locals.PubNoteNotExist,
|
||||
name: locals.Idontexists,
|
||||
time: Date.now(),
|
||||
code: 0,
|
||||
};
|
||||
|
||||
if (note === false)
|
||||
fetch(`/get-note/safe/${params.id}`)
|
||||
.then((data) => {
|
||||
data
|
||||
.json()
|
||||
.then((data) => {
|
||||
data.code = 1;
|
||||
setNote(data);
|
||||
})
|
||||
.catch(() => {
|
||||
setNote(nullNote);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
setNote(nullNote);
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
<ButtonWithIcon
|
||||
className="mb-4"
|
||||
href="/"
|
||||
text={locals.Write}
|
||||
icon={ChevronDoubleLeftIcon}
|
||||
/>
|
||||
|
||||
{note?.code === 1 && (
|
||||
<div className="p-4 mb-2">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2">
|
||||
<h2 className="font-medium text-center lg:text-left p-2">
|
||||
{locals.PubUrlPlaceholder}
|
||||
</h2>
|
||||
<CopyToClipboard
|
||||
text={`${window.location.origin}/pubNotes/${params.id}`}
|
||||
></CopyToClipboard>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Note note={note} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default PubNoteSafe;
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
|
||||
function Publish() {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
let err = false;
|
||||
|
||||
let note;
|
||||
|
||||
if (searchParams.get("local_id")) {
|
||||
let localNote =
|
||||
localStorage.getObj("Notes")[searchParams.get("local_id")];
|
||||
note = {
|
||||
name: localNote.name,
|
||||
text: localNote.text,
|
||||
};
|
||||
} else {
|
||||
note = {
|
||||
name: localStorage.getItem("NoteName"),
|
||||
text: localStorage.getItem("NoteText"),
|
||||
};
|
||||
}
|
||||
|
||||
if (!note.name) {
|
||||
err = locals.PubErrorMsgNoName;
|
||||
}
|
||||
if (!note.text) {
|
||||
err = locals.PubErrorMsgNoText;
|
||||
}
|
||||
|
||||
fetch(`/publish`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=utf-8",
|
||||
},
|
||||
body: JSON.stringify(note),
|
||||
})
|
||||
.then((data) => {
|
||||
data
|
||||
.json()
|
||||
.then((data) => {
|
||||
localStorage.removeItem("NoteName");
|
||||
localStorage.removeItem("NoteText");
|
||||
navigate(`/pubNotesSafe/${data.id}`, { replace: true });
|
||||
})
|
||||
.catch(() => {
|
||||
if (err == false) {
|
||||
navigate(`/pubError`, { replace: true });
|
||||
} else navigate(`/pubError?err=${err}`, { replace: true });
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
navigate(`/pubError`, { replace: true });
|
||||
});
|
||||
});
|
||||
|
||||
return <div />;
|
||||
}
|
||||
|
||||
export default Publish;
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Navigate } from "react-router-dom";
|
||||
import { timestamp2text } from "../components/utils";
|
||||
|
||||
function Save() {
|
||||
let name = localStorage.getItem("NoteName");
|
||||
let text = localStorage.getItem("NoteText");
|
||||
let pubTime = Number(localStorage.getItem("NotePubTime"));
|
||||
|
||||
if (!name || !text) return <Navigate to={`/notes`} replace={true} />;
|
||||
|
||||
let notesObj = localStorage.getObj("Notes");
|
||||
|
||||
let time = Date.now();
|
||||
|
||||
notesObj[time] = {
|
||||
id: time,
|
||||
name,
|
||||
text,
|
||||
time,
|
||||
textTime: timestamp2text(time),
|
||||
pubTime,
|
||||
pub: !!pubTime,
|
||||
};
|
||||
|
||||
localStorage.setObj("Notes", notesObj);
|
||||
|
||||
localStorage.removeItem("NoteName");
|
||||
localStorage.removeItem("NoteText");
|
||||
localStorage.removeItem("NotePubTime");
|
||||
|
||||
return <Navigate to={`/notes/${id}`} replace={true} />;
|
||||
}
|
||||
|
||||
export default Save;
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2023 artegoser (Artemy Egorov)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
SettingsCheckBox,
|
||||
SettingsTextInput,
|
||||
SettingsSelectInput,
|
||||
SettingsSection,
|
||||
setSetting,
|
||||
} from "../components/settingsInputs";
|
||||
import { ButtonWithIcon } from "../components/button";
|
||||
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
||||
import { localesProcess, reRenderPage } from "../components/utils";
|
||||
import { langChoices } from "../localisation/main";
|
||||
|
||||
function Settings() {
|
||||
let lastName = settings.userName;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-center lg:text-left leading-tight text-2xl font-bold">
|
||||
{locals.Settings}
|
||||
</h1>
|
||||
|
||||
<SettingsSection name={locals.User}>
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Name}
|
||||
label={locals.UserName}
|
||||
settingName="userName"
|
||||
onChange={() => {
|
||||
if (settings.userName == "bruh") {
|
||||
lastName = settings.userName;
|
||||
reRenderPage();
|
||||
} else if (lastName == "bruh") {
|
||||
lastName = settings.userName;
|
||||
reRenderPage();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Url}
|
||||
label={locals.PhotoUrl}
|
||||
settingName="userPhoto"
|
||||
/>
|
||||
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Status}
|
||||
label={locals.UserStatus}
|
||||
settingName="userStatus"
|
||||
/>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection name={locals.Notes}>
|
||||
<SettingsCheckBox
|
||||
label={locals.EditPreview}
|
||||
title={locals.EditPreviewWarn}
|
||||
settingName="editPreview"
|
||||
/>
|
||||
|
||||
<SettingsCheckBox
|
||||
label={locals.PublicNote}
|
||||
title={locals.PublicNoteTitle}
|
||||
settingName="publicNote"
|
||||
/>
|
||||
|
||||
<SettingsCheckBox
|
||||
label={locals.AdditionalFeatures}
|
||||
settingName="additionalFeatures"
|
||||
/>
|
||||
|
||||
<SettingsCheckBox label={locals.CollabEdit} settingName="CollabEdit" />
|
||||
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Password}
|
||||
label={locals.CollabEditPassword}
|
||||
settingName="CollabEditPassword"
|
||||
onChange={() => {
|
||||
window.alreadyConnected = false;
|
||||
}}
|
||||
/>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection name={locals.Sync}>
|
||||
<SettingsCheckBox
|
||||
label={locals.BroadcastSync}
|
||||
onClick={(e) => {
|
||||
if (e.target.checked) {
|
||||
socket.emit("joinRoom", settings.SyncPassword);
|
||||
} else {
|
||||
socket.emit("leaveRoom");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Password}
|
||||
label={locals.SyncPassword}
|
||||
secret
|
||||
settingName="SyncPassword"
|
||||
/>
|
||||
|
||||
<ButtonWithIcon
|
||||
icon={ChevronDoubleRightIcon}
|
||||
text={locals.SyncAll}
|
||||
className="m-1"
|
||||
w="w-full lg:w-96"
|
||||
onClick={() => {
|
||||
socket.emit("broadcastSync", {
|
||||
data: {
|
||||
settings: localStorage.getItem("settings"),
|
||||
Notes: localStorage.getItem("Notes"),
|
||||
NoteText: localStorage.getItem("NoteText"),
|
||||
NoteName: localStorage.getItem("NoteName"),
|
||||
},
|
||||
room: settings.SyncPassword,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection name={locals.Interface}>
|
||||
<SettingsSelectInput
|
||||
label={locals.Language}
|
||||
settingName="language"
|
||||
options={langChoices}
|
||||
onChange={() => {
|
||||
localesProcess(true);
|
||||
setSetting("newNotes", false);
|
||||
}}
|
||||
/>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection name={locals.ThirdPartyApi}>
|
||||
<SettingsTextInput
|
||||
placeholder={locals.Key}
|
||||
label={locals.OpenAiKey}
|
||||
settingName="openAiKey"
|
||||
secret
|
||||
/>
|
||||
</SettingsSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Settings;
|
Loading…
Add table
Reference in a new issue