mirror of https://github.com/fantasticit/think.git
client: improve export
This commit is contained in:
parent
5f773ec988
commit
bd6e63d80c
|
@ -30,6 +30,10 @@ export const DocumentExporter: React.FC<IProps> = ({ document, render }) => {
|
|||
editable: false,
|
||||
extensions: AllExtensions,
|
||||
content: '',
|
||||
editorProps: {
|
||||
// @ts-ignore
|
||||
print: true,
|
||||
},
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
@ -132,6 +136,7 @@ export const DocumentExporter: React.FC<IProps> = ({ document, render }) => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('doc', editor, document);
|
||||
const c = safeJSONParse(document && document.content);
|
||||
const json = c.default || c;
|
||||
editor.commands.setContent(json);
|
||||
|
|
|
@ -46,6 +46,7 @@ import { Superscript } from 'tiptap/core/extensions/superscript';
|
|||
import { Table } from 'tiptap/core/extensions/table';
|
||||
import { TableCell } from 'tiptap/core/extensions/table-cell';
|
||||
import { TableHeader } from 'tiptap/core/extensions/table-header';
|
||||
import { TableOfContents } from 'tiptap/core/extensions/table-of-contents';
|
||||
import { TableRow } from 'tiptap/core/extensions/table-row';
|
||||
import { TaskItem } from 'tiptap/core/extensions/task-item';
|
||||
import { TaskList } from 'tiptap/core/extensions/task-list';
|
||||
|
@ -94,6 +95,7 @@ export const AllExtensions = [
|
|||
TableCell,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableOfContents,
|
||||
Text,
|
||||
TextAlign,
|
||||
TextStyle,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
code {
|
||||
width: 100%;
|
||||
max-height: 370px;
|
||||
padding: 0;
|
||||
margin: 8px;
|
||||
overflow: auto;
|
||||
|
|
|
@ -12,4 +12,10 @@
|
|||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&.maxHeight {
|
||||
code {
|
||||
max-height: 370px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,16 @@ import styles from './index.module.scss';
|
|||
|
||||
export const CodeBlockWrapper = ({ editor, node: { attrs }, updateAttributes, extension }) => {
|
||||
const isEditable = editor.isEditable;
|
||||
const isPrint = editor?.options?.editorProps?.print;
|
||||
const { language: defaultLanguage } = attrs;
|
||||
const $container = useRef<HTMLPreElement>();
|
||||
|
||||
return (
|
||||
<DragableWrapper editor={editor} extensionName={CodeBlock.name} className={cls(styles.wrap, 'render-wrapper')}>
|
||||
<DragableWrapper
|
||||
editor={editor}
|
||||
extensionName={CodeBlock.name}
|
||||
className={cls(styles.wrap, !isPrint && styles.maxHeight, 'render-wrapper')}
|
||||
>
|
||||
<div className={styles.handleWrap}>
|
||||
<Select
|
||||
size="small"
|
||||
|
|
|
@ -68,7 +68,7 @@ const nodeSerializer = {
|
|||
state.closeBlock(node);
|
||||
},
|
||||
[CodeBlock.name](state, node) {
|
||||
state.renderInline(node.content?.content ?? '');
|
||||
state.renderContent(node);
|
||||
state.closeBlock(node);
|
||||
},
|
||||
[Status.name](state, node) {
|
||||
|
|
Loading…
Reference in New Issue