mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
editor: fix duplicate block-id when pasting content from note
This commit is contained in:
@@ -43,11 +43,18 @@ export class ClipboardDOMParser extends ProsemirrorDOMParser {
|
||||
formatCodeblocks(dom);
|
||||
convertBrToSingleSpacedParagraphs(dom);
|
||||
removeImages(dom);
|
||||
removeBlockId(dom);
|
||||
}
|
||||
return super.parseSlice(dom, options);
|
||||
}
|
||||
}
|
||||
|
||||
export function removeBlockId(dom: HTMLElement | Document) {
|
||||
for (const element of dom.querySelectorAll("[data-block-id]")) {
|
||||
element.removeAttribute("data-block-id");
|
||||
}
|
||||
}
|
||||
|
||||
export function formatCodeblocks(dom: HTMLElement | Document) {
|
||||
for (const pre of dom.querySelectorAll("pre")) {
|
||||
pre.innerHTML = pre.innerHTML?.replaceAll(/<br.*?>/g, "\n");
|
||||
|
||||
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Fragment, Schema } from "prosemirror-model";
|
||||
import { DOMSerializer } from "@tiptap/pm/model";
|
||||
import { Fragment, Schema } from "prosemirror-model";
|
||||
|
||||
export class ClipboardDOMSerializer extends DOMSerializer {
|
||||
static fromSchema(schema: Schema): ClipboardDOMSerializer {
|
||||
@@ -43,6 +43,10 @@ export class ClipboardDOMSerializer extends DOMSerializer {
|
||||
p.remove();
|
||||
}
|
||||
|
||||
for (const element of dom.querySelectorAll("[data-block-id]")) {
|
||||
element.removeAttribute("data-block-id");
|
||||
}
|
||||
|
||||
for (const p of dom.querySelectorAll('p[data-spacing="single"]')) {
|
||||
if (!p.previousElementSibling || p.previousElementSibling.tagName !== "P")
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user