Skip to content

Commit

Permalink
Merge pull request #86 from Darginec05/78-copy-and-pasting-from-exter…
Browse files Browse the repository at this point in the history
…nal-source-to-yopta-editor-adds-unwanted-new-lines

78 copy and pasting from external source to yopta editor adds unwanted new lines
  • Loading branch information
Darginec05 authored Sep 22, 2023
2 parents b4470da + 010a4e0 commit 52f36fb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/yoopta-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/editor",
"version": "1.9.24-rc",
"version": "1.9.25-rc",
"license": "MIT",
"private": false,
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Transforms } from 'slate';
import { Text, Transforms } from 'slate';
import { YooEditor } from '../../../types';
import { deserializeHtml } from '../../../utils/deserializeHTML';

Expand All @@ -11,7 +11,9 @@ const withHtml = (editor: YooEditor) => {

if (html) {
const fragment = deserializeHtml(html, editor.plugins);
Transforms.insertFragment(editor, fragment);
const nodes = fragment.filter((node) => !Text.isText(node));

Transforms.insertFragment(editor, nodes);
return;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/yoopta-lists/src/ui/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const ListItemList = createYooptaPlugin<any, ListChildItemElement>({

const { anchor } = editor.selection;
const [listItemNode, listItemPath] = nodeEntry;
const [parentNode, parentPath] = Editor.parent(editor, listItemPath) as NodeEntry<BulletedListElement | NumberedListElement>;
const [parentNode, parentPath] = Editor.parent(editor, listItemPath) as NodeEntry<
BulletedListElement | NumberedListElement
>;

const text = Editor.string(editor, listItemPath);
const isEnd = Editor.isEnd(editor, anchor, listItemPath);
Expand Down Expand Up @@ -192,7 +194,6 @@ const ListItemList = createYooptaPlugin<any, ListChildItemElement>({
},
html: {
serialize: (node, children) => {
console.log('children', children);
return `<li>${children}</li>`;
},
deserialize: {
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@yoopta/callout": "^1.9.15-rc",
"@yoopta/chat-gpt-assistant": "^1.9.16-rc",
"@yoopta/code": "^1.9.15-rc",
"@yoopta/editor": "^1.9.24-rc",
"@yoopta/editor": "^1.9.25-rc",
"@yoopta/embed": "^1.9.18-rc",
"@yoopta/exports": "^1.9.17-rc",
"@yoopta/headings": "^1.9.15-rc",
Expand Down
8 changes: 4 additions & 4 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1615,10 +1615,10 @@
prism-material-themes "^1.0.4"
prismjs "^1.29.0"

"@yoopta/editor@^1.9.23-rc":
version "1.9.23-rc"
resolved "https://registry.yarnpkg.com/@yoopta/editor/-/editor-1.9.23-rc.tgz#aa6f829149a3225d56c2031d21f6c94fc5e4c950"
integrity sha512-+ms9OVWUoio8taYfwe9CaMeKjvQfupwFroVuIUqaXIh6xuZSadhBe12wtuf2I2MJyWKEgifZjiPQ3LrnwemV3Q==
"@yoopta/editor@^1.9.25-rc":
version "1.9.25-rc"
resolved "https://registry.yarnpkg.com/@yoopta/editor/-/editor-1.9.25-rc.tgz#8ff8113a7fed4edd9f7c6fb59ab41731b0a7f614"
integrity sha512-N6n6yWEYEU+U8mA5Pe/w7SN85vbl6+OsdMsAdnjTrKD/qe/gu6tw7ujE+ETjEqRwA5jD6d8xnSIx0Lnl8KjpGw==
dependencies:
body-scroll-lock "^4.0.0-beta.0"
classnames "^2.3.1"
Expand Down

1 comment on commit 52f36fb

@vercel
Copy link

@vercel vercel bot commented on 52f36fb Sep 22, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

yopta-editor – ./

yopta-editor-git-master-darginec05.vercel.app
yopta-editor.vercel.app
yopta-editor-darginec05.vercel.app

Please sign in to comment.