opacacms 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +3 -3
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -119
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2017,12 +2017,12 @@ var init_init = __esm(() => {
|
|
|
2017
2017
|
}
|
|
2018
2018
|
const srcDir = fs3.existsSync(resolve(targetDir, "src")) ? "src/" : "";
|
|
2019
2019
|
const nextPathPrefix = framework === "nextjs" ? `${srcDir}app/(opaca)/` : "";
|
|
2020
|
-
const cfPathPrefix = framework === "cloudflare-workers" ? "src/" : "";
|
|
2020
|
+
const cfPathPrefix = framework === "cloudflare-workers" ? "src/(opaca)/" : "";
|
|
2021
2021
|
const pathPrefix = framework === "nextjs" ? nextPathPrefix : cfPathPrefix;
|
|
2022
2022
|
const configCode = `import { defineConfig } from 'opacacms/config';
|
|
2023
2023
|
${dbImport}
|
|
2024
|
-
import { posts } from './${pathPrefix}
|
|
2025
|
-
import { siteSettings } from './${pathPrefix}
|
|
2024
|
+
import { posts } from './${pathPrefix}_collections/posts';
|
|
2025
|
+
import { siteSettings } from './${pathPrefix}_globals/site-settings';
|
|
2026
2026
|
|
|
2027
2027
|
${dbType === "d1" ? `const getConfig = (env: any, request: Request) => defineConfig({
|
|
2028
2028
|
appName: "My OpacaCMS App",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,134 +32,15 @@ import {
|
|
|
32
32
|
import"./chunk-jq1drsen.js";
|
|
33
33
|
import"./chunk-h8v093av.js";
|
|
34
34
|
import"./chunk-8sqjbsgt.js";
|
|
35
|
-
// src/client/RichText.tsx
|
|
36
|
-
import { CodeNode } from "@lexical/code";
|
|
37
|
-
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
38
|
-
import { ListItemNode, ListNode } from "@lexical/list";
|
|
39
|
-
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
40
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
41
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
42
|
-
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
43
|
-
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
44
|
-
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
45
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
46
|
-
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
47
|
-
import { useMemo } from "react";
|
|
48
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
49
|
-
"use client";
|
|
50
|
-
var theme = {
|
|
51
|
-
ltr: "ltr",
|
|
52
|
-
rtl: "rtl",
|
|
53
|
-
placeholder: "opaca-rich-text-placeholder",
|
|
54
|
-
paragraph: "opaca-rich-text-p",
|
|
55
|
-
quote: "opaca-rich-text-quote",
|
|
56
|
-
heading: {
|
|
57
|
-
h1: "opaca-rich-text-h1",
|
|
58
|
-
h2: "opaca-rich-text-h2",
|
|
59
|
-
h3: "opaca-rich-text-h3"
|
|
60
|
-
},
|
|
61
|
-
list: {
|
|
62
|
-
ol: "opaca-rich-text-ol",
|
|
63
|
-
ul: "opaca-rich-text-ul",
|
|
64
|
-
listitem: "opaca-rich-text-li"
|
|
65
|
-
},
|
|
66
|
-
link: "opaca-rich-text-link",
|
|
67
|
-
text: {
|
|
68
|
-
bold: "opaca-rich-text-bold",
|
|
69
|
-
italic: "opaca-rich-text-italic",
|
|
70
|
-
underline: "opaca-rich-text-underline",
|
|
71
|
-
strikethrough: "opaca-rich-text-strikethrough",
|
|
72
|
-
code: "opaca-rich-text-code"
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function RichText({ content, className }) {
|
|
76
|
-
const initialConfig = useMemo(() => {
|
|
77
|
-
let editorState = content;
|
|
78
|
-
if (typeof content === "string" && content.startsWith("{")) {
|
|
79
|
-
try {
|
|
80
|
-
editorState = content;
|
|
81
|
-
} catch (e) {
|
|
82
|
-
editorState = undefined;
|
|
83
|
-
}
|
|
84
|
-
} else if (typeof content === "object" && content !== null) {
|
|
85
|
-
editorState = JSON.stringify(content);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
namespace: "OpacaRichTextRenderer",
|
|
89
|
-
theme,
|
|
90
|
-
editable: false,
|
|
91
|
-
nodes: [HeadingNode, ListNode, ListItemNode, QuoteNode, CodeNode, LinkNode, AutoLinkNode],
|
|
92
|
-
onError: (error) => {
|
|
93
|
-
console.error("RichText Renderer Error:", error);
|
|
94
|
-
},
|
|
95
|
-
editorState
|
|
96
|
-
};
|
|
97
|
-
}, [content]);
|
|
98
|
-
if (!content)
|
|
99
|
-
return null;
|
|
100
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
101
|
-
className: `opaca-rich-text-renderer ${className || ""}`,
|
|
102
|
-
children: /* @__PURE__ */ jsxDEV(LexicalComposer, {
|
|
103
|
-
initialConfig,
|
|
104
|
-
children: [
|
|
105
|
-
/* @__PURE__ */ jsxDEV(RichTextPlugin, {
|
|
106
|
-
contentEditable: /* @__PURE__ */ jsxDEV(ContentEditable, {
|
|
107
|
-
className: "opaca-rich-text-content"
|
|
108
|
-
}, undefined, false, undefined, this),
|
|
109
|
-
placeholder: null,
|
|
110
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
111
|
-
}, undefined, false, undefined, this),
|
|
112
|
-
/* @__PURE__ */ jsxDEV(ListPlugin, {}, undefined, false, undefined, this),
|
|
113
|
-
/* @__PURE__ */ jsxDEV(LinkPlugin, {}, undefined, false, undefined, this),
|
|
114
|
-
/* @__PURE__ */ jsxDEV(HistoryPlugin, {}, undefined, false, undefined, this)
|
|
115
|
-
]
|
|
116
|
-
}, undefined, true, undefined, this)
|
|
117
|
-
}, undefined, false, undefined, this);
|
|
118
|
-
}
|
|
119
|
-
// src/client/rich-text-utils.ts
|
|
120
|
-
function getRichTextText(content) {
|
|
121
|
-
if (!content)
|
|
122
|
-
return "";
|
|
123
|
-
if (typeof content === "string") {
|
|
124
|
-
if (content.startsWith("{") && content.includes('"root"')) {
|
|
125
|
-
try {
|
|
126
|
-
return getRichTextText(JSON.parse(content));
|
|
127
|
-
} catch {
|
|
128
|
-
return content;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return content;
|
|
132
|
-
}
|
|
133
|
-
if (content.root) {
|
|
134
|
-
return extractLexicalNodes(content.root.children);
|
|
135
|
-
}
|
|
136
|
-
if (Array.isArray(content)) {
|
|
137
|
-
return extractLexicalNodes(content);
|
|
138
|
-
}
|
|
139
|
-
return "";
|
|
140
|
-
}
|
|
141
|
-
function extractLexicalNodes(nodes) {
|
|
142
|
-
if (!nodes || !Array.isArray(nodes))
|
|
143
|
-
return "";
|
|
144
|
-
return nodes.map((node) => {
|
|
145
|
-
if (node.text)
|
|
146
|
-
return node.text;
|
|
147
|
-
if (node.children)
|
|
148
|
-
return extractLexicalNodes(node.children);
|
|
149
|
-
return "";
|
|
150
|
-
}).join(" ").replace(/\s+/g, " ").trim();
|
|
151
|
-
}
|
|
152
35
|
export {
|
|
153
36
|
zodToOpacaFields,
|
|
154
37
|
z,
|
|
155
38
|
sanitizeConfig,
|
|
156
|
-
getRichTextText,
|
|
157
39
|
defineGlobal,
|
|
158
40
|
defineConfig,
|
|
159
41
|
defineCollection,
|
|
160
42
|
createClient,
|
|
161
43
|
createAuth,
|
|
162
|
-
RichText,
|
|
163
44
|
OpacaError,
|
|
164
45
|
$ZodString,
|
|
165
46
|
$ZodOptional,
|