Skip to content

Commit

Permalink
fix: 移除调试日志,优化段落处理逻辑,调整节点类型为'paragraph'
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jan 30, 2025
1 parent 54c7041 commit 567fd5c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/MarkdownEditor/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ export const MEditor = observer(
}

const types = event.clipboardData.types;
console.log('types', types);
if (types.includes('application/x-slate-fragment')) {
const encoded = event.clipboardData.getData(
'application/x-slate-fragment',
Expand Down
8 changes: 7 additions & 1 deletion src/MarkdownEditor/editor/plugins/insertParsedHtmlNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,15 @@ export const insertParsedHtmlNodes = async (
],
};
}
if (fragment.type === 'p' && fragment.children.length === 1) {
return {
type: 'paragraph',
children: fragment.children,
};
}
return fragment;
});
console.log(fragmentList);

hideLoading();

if (!fragmentList?.length) return false;
Expand Down
1 change: 0 additions & 1 deletion src/MarkdownEditor/editor/plugins/useKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const useKeyboard = (
const enter = new EnterKey(store, backspace);
const match = new MatchKey(markdownEditorRef.current);
return (e: React.KeyboardEvent) => {
console.log('keyword----->', e);
if (
store.openInsertCompletion &&
(isHotkey('up', e) || isHotkey('down', e))
Expand Down
8 changes: 6 additions & 2 deletions src/MarkdownEditor/editor/utils/docx/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const makeDeserializer = (jsx: any) => {
.flat();

if (el.nodeName === 'BODY') {
const filler = jsx('element', { type: 'p', className: 'P' }, [
const filler = jsx('element', { type: 'paragraph', className: 'P' }, [
{ text: ' ' },
]);
children.unshift(filler);
Expand All @@ -117,7 +117,11 @@ export const makeDeserializer = (jsx: any) => {
if (nodeName === 'H3' || nodeName === 'H2' || nodeName === 'H1') {
return jsx(
'element',
{ type: nodeName, className: nodeName },
{
type: 'head',
className: nodeName,
level: nodeName?.replace('H', ''),
},
children,
);
}
Expand Down

1 comment on commit 567fd5c

@vercel
Copy link

@vercel vercel bot commented on 567fd5c Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.