Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: send json to and from the server

Brad Barbin60a84af70695
diff --git a/apps/carbon/app/routes/x+/scheduling+/wysiwyg.tsx b/apps/carbon/app/routes/x+/scheduling+/wysiwyg.tsx
index 54f3964628..89cec0d4c4 100644
--- a/apps/carbon/app/routes/x+/scheduling+/wysiwyg.tsx
+++ b/apps/carbon/app/routes/x+/scheduling+/wysiwyg.tsx
@@ -1,21 +1,63 @@
import type { JSONContent } from "@carbon/react";
-import { Editor } from "@carbon/react";
+import { Editor, useDebounce } from "@carbon/react";
+import { useFetcher, useLoaderData } from "@remix-run/react";
import { useState } from "react";
import ProseMirror from "~/styles/prosemirror.css?url";
+import type { ActionFunctionArgs } from "@remix-run/node";
+
export function links() {
return [{ rel: "stylesheet", href: ProseMirror }];
}
+export async function loader() {
+ return {
+ content: {
+ type: "doc",
+ content: [
+ {
+ type: "heading",
+ attrs: { level: 2 },
+ content: [{ type: "text", text: "Work Instruction" }],
+ },
+ { type: "paragraph" },
+ { type: "paragraph" },
+ ],
+ },
+ };
+}
+
+export async function action({ request }: ActionFunctionArgs) {
+ // get form data from request
+ const formData = await request.formData();
+ const content = JSON.parse(formData.get("content") as string);
+
+ console.log({ content });
+ return null;
+}
+
export default function WysiwygRoute() {
- const [value, setValue] = useState<JSONContent>({
- type: "doc",
- content: [{ type: "paragraph", content: [{ text: "Hello, CarbonOS!" }] }],
- });
+ const { content } = useLoaderData<{ content: JSONContent }>();
+ const [value, setValue] = useState<JSONContent>(content);
+ const fetcher = useFetcher();
+
+ const debounceSearch = useDebounce((c: JSONContent) => {
+ const formData = new FormData();
+ formData.append("content", JSON.stringify(c));
+
+ fetcher.submit(formData, {
+ method: "post",
+ });
+ }, 3000);
+
+ const onChange = (c: JSONContent) => {
+ setValue(c);
+ debounceSearch(c);
+ };
return (
<div className="flex flex-col h-full max-h-full overflow-auto relative">
- <Editor initialValue={value} onChange={setValue} />
+ <Editor initialValue={value} onChange={onChange} />
</div>
);
}
diff --git a/apps/carbon/tailwind.config.js b/apps/carbon/tailwind.config.js
index 0ea1cf06ca..5856bc01d7 100644
--- a/apps/carbon/tailwind.config.js
+++ b/apps/carbon/tailwind.config.js
@@ -1 +1,4 @@
-module.exports = require("@carbon/tailwind/tailwind.config");
+module.exports = {
+ "tailwindcss/nesting": {},
+ ...require("@carbon/tailwind/tailwind.config"),
+};
diff --git a/package-lock.json b/package-lock.json
index 2a4fd1bd96..d865095221 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -31866,6 +31866,90 @@
"node": ">=4"
}
},
+ "node_modules/postcss-nesting": {
+ "version": "12.1.5",
+ "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-12.1.5.tgz",
+ "integrity": "sha512-N1NgI1PDCiAGWPTYrwqm8wpjv0bgDmkYHH72pNsqTCv9CObxjxftdYu6AKtGN+pnJa7FQjMm3v4sp8QJbFsYdQ==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/csstools"
+ },
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/csstools"
+ }
+ ],
+ "peer": true,
+ "dependencies": {
+ "@csstools/selector-resolve-nested": "^1.1.0",
+ "@csstools/selector-specificity": "^3.1.1",
+ "postcss-selector-parser": "^6.1.0"
+ },
+ "engines": {
+ "node": "^14 || ^16 || >=18"
+ },
+ "peerDependencies": {
+ "postcss": "^8.4"
+ }
+ },
+ "node_modules/postcss-nesting/node_modules/@csstools/selector-resolve-nested": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@csstools/selector-resolve-nested/-/selector-resolve-nested-1.1.0.tgz",
+ "integrity": "sha512-uWvSaeRcHyeNenKg8tp17EVDRkpflmdyvbE0DHo6D/GdBb6PDnCYYU6gRpXhtICMGMcahQmj2zGxwFM/WC8hCg==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/csstools"
+ },
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/csstools"
+ }
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^14 || ^16 || >=18"
+ },
+ "peerDependencies": {
+ "postcss-selector-parser": "^6.0.13"
+ }
+ },
+ "node_modules/postcss-nesting/node_modules/@csstools/selector-specificity": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-3.1.1.tgz",
+ "integrity": "sha512-a7cxGcJ2wIlMFLlh8z2ONm+715QkPHiyJcxwQlKOz/03GPw1COpfhcmC9wm4xlZfp//jWHNNMwzjtqHXVWU9KA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/csstools"
+ },
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/csstools"
+ }
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^14 || ^16 || >=18"
+ },
+ "peerDependencies": {
+ "postcss-selector-parser": "^6.0.13"
+ }
+ },
+ "node_modules/postcss-nesting/node_modules/postcss-selector-parser": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.0.tgz",
+ "integrity": "sha512-UMz42UD0UY0EApS0ZL9o1XnLhSTtvvvLe5Dc2H2O56fvRZi+KulDyf5ctDhhtYJBGKStV2FL1fy6253cmLgqVQ==",
+ "peer": true,
+ "dependencies": {
+ "cssesc": "^3.0.0",
+ "util-deprecate": "^1.0.2"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/postcss-selector-parser": {
"version": "6.0.10",
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz",
@@ -40721,6 +40805,7 @@
"autoprefixer": "10.4.14",
"eslint-config-carbon": "*",
"postcss": "^8.4.33",
+ "postcss-nesting": "12.1.5",
"tailwind-merge": "^2.2.1",
"tailwind-scrollbar": "^3.0.5",
"tailwind-scrollbar-hide": "^1.1.7",
diff --git a/packages/tailwind/package.json b/packages/tailwind/package.json
index dd95b88706..1e399058e5 100644
--- a/packages/tailwind/package.json
+++ b/packages/tailwind/package.json
@@ -13,6 +13,7 @@
"autoprefixer": "10.4.14",
"eslint-config-carbon": "*",
"postcss": "^8.4.33",
+ "postcss-nesting": "12.1.5",
"tailwind-merge": "^2.2.1",
"tailwind-scrollbar": "^3.0.5",
"tailwind-scrollbar-hide": "^1.1.7",
diff --git a/packages/tailwind/postcss.config.js b/packages/tailwind/postcss.config.js
index dd07c71ef8..57faaad39f 100644
--- a/packages/tailwind/postcss.config.js
+++ b/packages/tailwind/postcss.config.js
@@ -1,3 +1,7 @@
module.exports = {
- plugins: [require("tailwindcss")(), require("autoprefixer")()],
+ plugins: [
+ require("tailwindcss")(),
+ require("autoprefixer")(),
+ require("postcss-nesting")(),
+ ],
};