Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelfan committed Dec 13, 2023
2 parents 1ba09c8 + 62bfd14 commit 881f3dc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
unoptimized: true,
remotePatterns: [
{
protocol: "https",
Expand Down
10 changes: 7 additions & 3 deletions src/components/inputs/editor/BottomEditorBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import EmojiPicker from "./EmojiPicker";
import type { Editor } from "@tiptap/react";
import type { Editor, JSONContent } from "@tiptap/react";
import AdultContentPicker from "./AdultContentPicker";
import ImagePicker from "./ImagePicker";
import CharacterCount from "./CharacterCount";
Expand All @@ -8,10 +8,12 @@ import { useState } from "react";
import { useDropzone } from "react-dropzone";
import { Icon } from "@iconify/react/dist/iconify.js";
import UploadPreview from "./UploadPreview";
import { RichText } from "@atproto/api";
import { jsonToText } from "@/lib/utils/text";

interface Props {
editor: Editor;
charCount: number;
text: JSONContent;
label: string;
languages: Language[];
images?: UploadImage[];
Expand All @@ -25,7 +27,7 @@ interface Props {
export default function BottomEditorBar(props: Props) {
const {
editor,
charCount,
text,
label,
languages,
images,
Expand All @@ -35,6 +37,8 @@ export default function BottomEditorBar(props: Props) {
} = props;

const [showDropzone, setShowDropzone] = useState(false);
const richText = new RichText({ text: jsonToText(text) });
const charCount = richText.graphemeLength;

const { getRootProps, getInputProps, isDragActive, isDragReject } =
useDropzone({
Expand Down
4 changes: 2 additions & 2 deletions src/components/inputs/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function Editor(props: Props) {
listItem: false,
}),
CharacterCount.configure({
limit: 600,
limit: 600,
}),
Placeholder.configure({
placeholder: placeholderText,
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function Editor(props: Props) {
editor={editor}
label={label}
onSelectLabel={setLabel}
charCount={editor?.storage.characterCount.characters()}
text={editor.getJSON()}
languages={languages}
onSelectLanguages={setLanguages}
images={images}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hooks/bsky/feed/usePublishPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function usePublishPost(props: Props) {
return useMutation({
mutationKey: ["publishPost"],
mutationFn: async () => {
const richText = new RichText({ text: jsonToText(text).trimEnd() });
const richText = new RichText({ text: jsonToText(text)});
await richText.detectFacets(agent);

if (richText.graphemeLength > MAX_POST_LENGTH) {
Expand Down

0 comments on commit 881f3dc

Please sign in to comment.