tiptap-markdown
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -314,53 +314,5 @@ 'use strict'; | ||
var HardBreak = core.Node.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: prosemirrorMarkdown.defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
/** | ||
* Prosemirror-markdown check for specific hard_break node name | ||
* https://github.com/ProseMirror/prosemirror-markdown/blob/5e454a9b4d59c14a5826e112813e78b6b7325668/src/to_markdown.ts#L280 | ||
*/ | ||
function withSchemaHardBreakFix(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
if (hardBreak) { | ||
hardBreak.name = 'hard_break'; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
return result; | ||
} | ||
function withInitialSchema(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
var hardBreakNodeName = hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name; | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = hardBreakNodeName; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Override default MarkdownSerializerState to: | ||
* - handle commonmark delimiters (https://spec.commonmark.org/0.29/#left-flanking-delimiter-run) | ||
* - update schema due to serializer looking at specific node names | ||
*/ | ||
@@ -378,10 +330,2 @@ var MarkdownSerializerState = /*#__PURE__*/function (_BaseMarkdownSerializ) { | ||
_createClass(MarkdownSerializerState, [{ | ||
key: "renderContent", | ||
value: function renderContent(parent) { | ||
var _this2 = this; | ||
this.withSerializableSchema(parent.type.schema, function () { | ||
_get(_getPrototypeOf(MarkdownSerializerState.prototype), "renderContent", _this2).call(_this2, parent); | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
@@ -431,14 +375,2 @@ value: function render(node, parent, index) { | ||
} | ||
/** | ||
* update some nodes name due to serializer requiring on it | ||
*/ | ||
}, { | ||
key: "withSerializableSchema", | ||
value: function withSerializableSchema(schema, render) { | ||
this.nodes.hard_break = this.nodes.hardBreak; | ||
withSchemaHardBreakFix(schema, function () { | ||
return render(); | ||
}); | ||
} | ||
}]); | ||
@@ -543,5 +475,3 @@ return MarkdownSerializerState; | ||
var schema = node.type.schema; | ||
var html = withInitialSchema(schema, function (schema) { | ||
return core.getHTMLFromFragment(model.Fragment.from(node), schema); | ||
}); | ||
var html = core.getHTMLFromFragment(model.Fragment.from(node), schema); | ||
if (node.isBlock && parent.type.name === schema.topNodeType.name) { | ||
@@ -639,2 +569,21 @@ return formatBlock(html); | ||
var HardBreak = core.Node.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: prosemirrorMarkdown.defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
var Heading = core.Node.create({ | ||
@@ -1033,3 +982,5 @@ name: 'heading' | ||
value: function serialize(content) { | ||
var state = new MarkdownSerializerState(this.nodes, this.marks); | ||
var state = new MarkdownSerializerState(this.nodes, this.marks, { | ||
hardBreakNodeName: HardBreak$1.name | ||
}); | ||
state.renderContent(content); | ||
@@ -1036,0 +987,0 @@ return state.out; |
@@ -1,3 +0,3 @@ | ||
import { Extension, Node as Node$1, Mark, getHTMLFromFragment, extensions } from '@tiptap/core'; | ||
import { defaultMarkdownSerializer, MarkdownSerializerState as MarkdownSerializerState$1 } from 'prosemirror-markdown'; | ||
import { Extension, Mark, getHTMLFromFragment, Node as Node$1, extensions } from '@tiptap/core'; | ||
import { MarkdownSerializerState as MarkdownSerializerState$1, defaultMarkdownSerializer } from 'prosemirror-markdown'; | ||
import markdownit from 'markdown-it'; | ||
@@ -305,53 +305,5 @@ import { Fragment } from '@tiptap/pm/model'; | ||
var HardBreak = Node$1.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
/** | ||
* Prosemirror-markdown check for specific hard_break node name | ||
* https://github.com/ProseMirror/prosemirror-markdown/blob/5e454a9b4d59c14a5826e112813e78b6b7325668/src/to_markdown.ts#L280 | ||
*/ | ||
function withSchemaHardBreakFix(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
if (hardBreak) { | ||
hardBreak.name = 'hard_break'; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
return result; | ||
} | ||
function withInitialSchema(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
var hardBreakNodeName = hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name; | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = hardBreakNodeName; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Override default MarkdownSerializerState to: | ||
* - handle commonmark delimiters (https://spec.commonmark.org/0.29/#left-flanking-delimiter-run) | ||
* - update schema due to serializer looking at specific node names | ||
*/ | ||
@@ -369,10 +321,2 @@ var MarkdownSerializerState = /*#__PURE__*/function (_BaseMarkdownSerializ) { | ||
_createClass(MarkdownSerializerState, [{ | ||
key: "renderContent", | ||
value: function renderContent(parent) { | ||
var _this2 = this; | ||
this.withSerializableSchema(parent.type.schema, function () { | ||
_get(_getPrototypeOf(MarkdownSerializerState.prototype), "renderContent", _this2).call(_this2, parent); | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
@@ -422,14 +366,2 @@ value: function render(node, parent, index) { | ||
} | ||
/** | ||
* update some nodes name due to serializer requiring on it | ||
*/ | ||
}, { | ||
key: "withSerializableSchema", | ||
value: function withSerializableSchema(schema, render) { | ||
this.nodes.hard_break = this.nodes.hardBreak; | ||
withSchemaHardBreakFix(schema, function () { | ||
return render(); | ||
}); | ||
} | ||
}]); | ||
@@ -534,5 +466,3 @@ return MarkdownSerializerState; | ||
var schema = node.type.schema; | ||
var html = withInitialSchema(schema, function (schema) { | ||
return getHTMLFromFragment(Fragment.from(node), schema); | ||
}); | ||
var html = getHTMLFromFragment(Fragment.from(node), schema); | ||
if (node.isBlock && parent.type.name === schema.topNodeType.name) { | ||
@@ -630,2 +560,21 @@ return formatBlock(html); | ||
var HardBreak = Node$1.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
var Heading = Node$1.create({ | ||
@@ -1024,3 +973,5 @@ name: 'heading' | ||
value: function serialize(content) { | ||
var state = new MarkdownSerializerState(this.nodes, this.marks); | ||
var state = new MarkdownSerializerState(this.nodes, this.marks, { | ||
hardBreakNodeName: HardBreak$1.name | ||
}); | ||
state.renderContent(content); | ||
@@ -1027,0 +978,0 @@ return state.out; |
@@ -310,53 +310,5 @@ (function (global, factory) { | ||
var HardBreak = core.Node.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: prosemirrorMarkdown.defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
/** | ||
* Prosemirror-markdown check for specific hard_break node name | ||
* https://github.com/ProseMirror/prosemirror-markdown/blob/5e454a9b4d59c14a5826e112813e78b6b7325668/src/to_markdown.ts#L280 | ||
*/ | ||
function withSchemaHardBreakFix(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
if (hardBreak) { | ||
hardBreak.name = 'hard_break'; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
return result; | ||
} | ||
function withInitialSchema(schema, render) { | ||
var hardBreak = schema.nodes.hardBreak; | ||
var hardBreakNodeName = hardBreak === null || hardBreak === void 0 ? void 0 : hardBreak.name; | ||
if (hardBreak) { | ||
hardBreak.name = HardBreak$1.name; | ||
} | ||
var result = render(schema); | ||
if (hardBreak) { | ||
hardBreak.name = hardBreakNodeName; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Override default MarkdownSerializerState to: | ||
* - handle commonmark delimiters (https://spec.commonmark.org/0.29/#left-flanking-delimiter-run) | ||
* - update schema due to serializer looking at specific node names | ||
*/ | ||
@@ -374,10 +326,2 @@ var MarkdownSerializerState = /*#__PURE__*/function (_BaseMarkdownSerializ) { | ||
_createClass(MarkdownSerializerState, [{ | ||
key: "renderContent", | ||
value: function renderContent(parent) { | ||
var _this2 = this; | ||
this.withSerializableSchema(parent.type.schema, function () { | ||
_get(_getPrototypeOf(MarkdownSerializerState.prototype), "renderContent", _this2).call(_this2, parent); | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
@@ -427,14 +371,2 @@ value: function render(node, parent, index) { | ||
} | ||
/** | ||
* update some nodes name due to serializer requiring on it | ||
*/ | ||
}, { | ||
key: "withSerializableSchema", | ||
value: function withSerializableSchema(schema, render) { | ||
this.nodes.hard_break = this.nodes.hardBreak; | ||
withSchemaHardBreakFix(schema, function () { | ||
return render(); | ||
}); | ||
} | ||
}]); | ||
@@ -539,5 +471,3 @@ return MarkdownSerializerState; | ||
var schema = node.type.schema; | ||
var html = withInitialSchema(schema, function (schema) { | ||
return core.getHTMLFromFragment(model.Fragment.from(node), schema); | ||
}); | ||
var html = core.getHTMLFromFragment(model.Fragment.from(node), schema); | ||
if (node.isBlock && parent.type.name === schema.topNodeType.name) { | ||
@@ -635,2 +565,21 @@ return formatBlock(html); | ||
var HardBreak = core.Node.create({ | ||
name: 'hardBreak' | ||
}); | ||
var HardBreak$1 = HardBreak.extend({ | ||
/** | ||
* @return {{markdown: MarkdownNodeSpec}} | ||
*/ | ||
addStorage: function addStorage() { | ||
return { | ||
markdown: { | ||
serialize: prosemirrorMarkdown.defaultMarkdownSerializer.nodes.hard_break, | ||
parse: { | ||
// handled by markdown-it | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
var Heading = core.Node.create({ | ||
@@ -1029,3 +978,5 @@ name: 'heading' | ||
value: function serialize(content) { | ||
var state = new MarkdownSerializerState(this.nodes, this.marks); | ||
var state = new MarkdownSerializerState(this.nodes, this.marks, { | ||
hardBreakNodeName: HardBreak$1.name | ||
}); | ||
state.renderContent(content); | ||
@@ -1032,0 +983,0 @@ return state.out; |
{ | ||
"name": "tiptap-markdown", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "Edit markdown content in tiptap editor.", | ||
@@ -34,3 +34,3 @@ "scripts": { | ||
"markdown-it-task-lists": "^2.1.1", | ||
"prosemirror-markdown": "^1.10.1" | ||
"prosemirror-markdown": "^1.11.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "peerDependencies": { |
import { Fragment } from "@tiptap/pm/model"; | ||
import { getHTMLFromFragment, Node } from "@tiptap/core"; | ||
import { elementFromString } from "../../util/dom"; | ||
import { withInitialSchema } from "../../serialize/helpers"; | ||
@@ -33,5 +32,3 @@ | ||
const schema = node.type.schema; | ||
const html = withInitialSchema(schema, schema => { | ||
return getHTMLFromFragment(Fragment.from(node), schema); | ||
}); | ||
const html = getHTMLFromFragment(Fragment.from(node), schema); | ||
@@ -38,0 +35,0 @@ if(node.isBlock && parent.type.name === schema.topNodeType.name) { |
@@ -5,2 +5,3 @@ import { MarkdownSerializerState } from './state'; | ||
import { getMarkdownSpec } from "../util/extensions"; | ||
import HardBreak from "../extensions/nodes/hard-break"; | ||
@@ -19,3 +20,5 @@ | ||
serialize(content) { | ||
const state = new MarkdownSerializerState(this.nodes, this.marks); | ||
const state = new MarkdownSerializerState(this.nodes, this.marks, { | ||
hardBreakNodeName: HardBreak.name, | ||
}); | ||
@@ -22,0 +25,0 @@ state.renderContent(content); |
import { MarkdownSerializerState as BaseMarkdownSerializerState } from "prosemirror-markdown"; | ||
import { trimInline } from "../util/markdown"; | ||
import { withSchemaHardBreakFix } from "./helpers"; | ||
@@ -9,3 +8,2 @@ | ||
* - handle commonmark delimiters (https://spec.commonmark.org/0.29/#left-flanking-delimiter-run) | ||
* - update schema due to serializer looking at specific node names | ||
*/ | ||
@@ -19,8 +17,2 @@ export class MarkdownSerializerState extends BaseMarkdownSerializerState { | ||
renderContent(parent) { | ||
this.withSerializableSchema(parent.type.schema, () => { | ||
super.renderContent(parent); | ||
}); | ||
} | ||
render(node, parent, index) { | ||
@@ -65,11 +57,2 @@ super.render(node, parent, index); | ||
} | ||
/** | ||
* update some nodes name due to serializer requiring on it | ||
*/ | ||
withSerializableSchema(schema, render) { | ||
this.nodes.hard_break = this.nodes.hardBreak; | ||
withSchemaHardBreakFix(schema, () => render()); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348337
42
4525
Updatedprosemirror-markdown@^1.11.0