Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #1415 from ecency/bugfix/editor-preview
Browse files Browse the repository at this point in the history
Editor preview: fixed submit page preview
  • Loading branch information
feruzm authored Jul 21, 2023
2 parents f4fec71 + 7d5106c commit af28620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/common/components/post-body-lazy-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import { renderPostBody } from "@ecency/render-helper";
import md5 from "js-md5";
import { useMappedStore } from "../store/use-mapped-store";

interface Props {
rawBody: string;
Expand All @@ -10,6 +11,7 @@ interface Props {
export function PostBodyLazyRenderer({ rawBody, className }: Props) {
const [result, setResult] = useState<Element[]>([]);
const [hashes, setHashes] = useState<string[]>([]);
const { global } = useMappedStore();

useEffect(() => {
lazyBuild();
Expand All @@ -19,7 +21,7 @@ export function PostBodyLazyRenderer({ rawBody, className }: Props) {
}, [rawBody]);

const lazyBuild = () => {
const renderedBody = renderPostBody(rawBody);
const renderedBody = renderPostBody(rawBody, false, global.canUseWebp);
const tree = document.createElement("div");
tree.innerHTML = renderedBody;

Expand Down Expand Up @@ -48,7 +50,7 @@ export function PostBodyLazyRenderer({ rawBody, className }: Props) {
return (
<div className={className}>
{result.map((line, i) => (
<p key={hashes[i]} dangerouslySetInnerHTML={{ __html: line.innerHTML }} />
<div key={hashes[i]} dangerouslySetInnerHTML={{ __html: line.outerHTML }} />
))}
</div>
);
Expand Down
12 changes: 3 additions & 9 deletions src/common/pages/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import { Button, Col, Form, FormControl, Row, Spinner } from "react-bootstrap";
import moment, { Moment } from "moment";

import defaults from "../constants/defaults.json";
import {
postBodySummary,
proxifyImageSrc,
renderPostBody,
setProxyBase
} from "@ecency/render-helper";
import { postBodySummary, proxifyImageSrc, setProxyBase } from "@ecency/render-helper";
import { Entry } from "../store/entries/types";
import { Global } from "../store/global/types";
import { FullAccount } from "../store/accounts/types";
Expand All @@ -32,7 +27,7 @@ import Feedback, { error, success } from "../components/feedback";
import NavBar from "../components/navbar";
import NavBarElectron from "../../desktop/app/components/navbar";
import FullHeight from "../components/full-height";
import EditorToolbar from "../components/editor-toolbar";
import EditorToolbar, { detectEvent, toolbarEventListener } from "../components/editor-toolbar";
import TagSelector from "../components/tag-selector";
import CommunitySelector from "../components/community-selector";
import Tag from "../components/tag";
Expand All @@ -43,7 +38,6 @@ import MdHandler from "../components/md-handler";
import BeneficiaryEditor from "../components/beneficiary-editor";
import PostScheduler from "../components/post-scheduler";
import ClickAwayListener from "../components/clickaway-listener";
import { detectEvent, toolbarEventListener } from "../components/editor-toolbar";
import "./submit.scss";

import {
Expand Down Expand Up @@ -79,7 +73,7 @@ import * as ls from "../util/local-storage";

import { version } from "../../../package.json";

import { checkSvg, contentSaveSvg, contentLoadSvg, helpIconSvg } from "../img/svg";
import { checkSvg, contentLoadSvg, contentSaveSvg, helpIconSvg } from "../img/svg";

import { pageMapDispatchToProps, pageMapStateToProps, PageProps } from "./common";
import ModalConfirm from "../components/modal-confirm";
Expand Down

0 comments on commit af28620

Please sign in to comment.