mirror of
https://github.com/outline/outline.git
synced 2026-11-24 23:00:18 +03:00
stash
This commit is contained in:
1 parent
98c9af53c4
commit
bd75caec22
2 files changed
+41
No files matched your search
@@ -6,7 +6,9 @@ import * as React from "react";
|
||||
import { mergeRefs } from "react-merge-refs";
|
||||
import { Optional } from "utility-types";
|
||||
import insertFiles from "@shared/editor/commands/insertFiles";
|
||||
import EditorContainer from "@shared/editor/components/Styles";
|
||||
import { AttachmentPreset } from "@shared/types";
|
||||
import { ProsemirrorHelper } from "@shared/utils/ProsemirrorHelper";
|
||||
import { getDataTransferFiles } from "@shared/utils/files";
|
||||
import { AttachmentValidation } from "@shared/validations";
|
||||
import ClickablePadding from "~/components/ClickablePadding";
|
||||
@@ -183,6 +185,23 @@ function Editor(props: Props, ref: React.RefObject<SharedEditor> | null) {
|
||||
[updateComments]
|
||||
);
|
||||
|
||||
const paragraphs =
|
||||
props.readOnly && typeof props.value === "object"
|
||||
? ProsemirrorHelper.getPlainParagrahs(props.value)
|
||||
: undefined;
|
||||
|
||||
console.log({ paragraphs });
|
||||
|
||||
if (paragraphs) {
|
||||
return (
|
||||
<EditorContainer>
|
||||
{paragraphs.map((paragraph, index) => (
|
||||
<p key={index}>{paragraph.content.map((content) => content.text)}</p>
|
||||
))}
|
||||
</EditorContainer>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorBoundary component="div" reloadOnChunkMissing>
|
||||
<>
|
||||
|
||||
@@ -346,4 +346,26 @@ export class ProsemirrorHelper {
|
||||
|
||||
return replace(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the paragraphs from the data if there are only plain paragraphs
|
||||
* without any formatting. Otherwise returns undefined.
|
||||
*
|
||||
* @param data The ProsemirrorData object
|
||||
* @returns An array of paragraph nodes or undefined
|
||||
*/
|
||||
static getPlainParagrahs(data: ProsemirrorData) {
|
||||
const paragraphs = [];
|
||||
for (const node of data.content) {
|
||||
if (
|
||||
node.type === "paragraph" &&
|
||||
!node.content.some((item) => item.marks)
|
||||
) {
|
||||
paragraphs.push(node);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return paragraphs;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user