Socket
Socket
Sign inDemoInstall

tiptap-markdown

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiptap-markdown - npm Package Compare versions

Comparing version 0.8.5 to 0.8.6

src/parse/Renderer.js

2

package.json
{
"name": "tiptap-markdown",
"version": "0.8.5",
"version": "0.8.6",
"description": "Edit markdown content in tiptap editor.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -16,3 +16,11 @@ import { Node } from "@tiptap/core";

markdown: {
serialize: defaultMarkdownSerializer.nodes.ordered_list,
serialize(state,node) {
const start = node.attrs.start || 1
const maxW = String(start + node.childCount - 1).length
const space = state.repeat(" ", maxW + 2)
state.renderList(node, space, i => {
const nStr = String(start + i)
return state.repeat(" ", maxW - nStr.length) + nStr + ". "
})
},
parse: {

@@ -19,0 +27,0 @@ // handled by markdown-it

import markdownit from "markdown-it";
import { elementFromString, extractElement, unwrapElement } from "../util/dom";
import { getMarkdownSpec } from "../util/extensions";
import { Renderer } from "./Renderer.js";
export class MarkdownParser {

@@ -15,2 +15,6 @@ /**

md = null;
/**
* @type {Renderer}
*/
renderer = null;

@@ -24,2 +28,3 @@ constructor(editor, { html, linkify, breaks }) {

});
this.renderer = new Renderer();
}

@@ -29,9 +34,7 @@

if(typeof content === 'string') {
const renderer = this.md;
this.editor.extensionManager.extensions.forEach(extension =>
getMarkdownSpec(extension)?.parse?.setup?.call({ editor:this.editor, options:extension.options }, renderer)
getMarkdownSpec(extension)?.parse?.setup?.call({ editor:this.editor, options:extension.options }, this.md)
);
const renderedHTML = renderer.render(content);
const renderedHTML = this.renderer.render(this.md.parse(content, {}), this.md.options, {});
const element = elementFromString(renderedHTML);

@@ -92,3 +95,3 @@

const firstParagraph = node.firstElementChild;
const { nextSibling, nextElementSibling } = firstParagraph;
const { nextElementSibling } = firstParagraph;
const startSpaces = content.match(/^\s+/)?.[0] ?? '';

@@ -95,0 +98,0 @@ const endSpaces = !nextElementSibling

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc