mirror of https://github.com/fantasticit/think.git
tiptap: fix transform title
parent
0510303c7c
commit
5b6f211900
|
@ -74,7 +74,7 @@ export const Title = Node.create<TitleOptions>({
|
|||
|
||||
const $head = state.selection.$head;
|
||||
const titleNode = $head.node($head.depth);
|
||||
const endPos = titleNode.firstChild.nodeSize + 1;
|
||||
const endPos = ((titleNode.firstChild && titleNode.firstChild.nodeSize) || 0) + 1;
|
||||
|
||||
dispatch(state.tr.insert(endPos, paragraph.create()));
|
||||
|
||||
|
|
|
@ -132,7 +132,9 @@ export function openTag(tagName, attrs) {
|
|||
str += Object.entries(attrs || {})
|
||||
.map(([key, value]) => {
|
||||
if ((ignoreAttrs[tagName] || []).includes(key) || defaultAttrs[tagName]?.[key] === value) return '';
|
||||
|
||||
if (!['class', 'id'].includes(key) && !key.startsWith('data-')) {
|
||||
key = `data-${key}`;
|
||||
}
|
||||
return ` ${key}="${htmlEncode(value?.toString())}"`;
|
||||
})
|
||||
.join('');
|
||||
|
|
|
@ -158,7 +158,7 @@ const SerializerConfig = {
|
|||
state.renderList(node, ' ', () => (node.attrs.bullet || '*') + ' ');
|
||||
},
|
||||
[Text.name]: defaultMarkdownSerializer.nodes.text,
|
||||
[Title.name]: renderCustomContainer('title'),
|
||||
[Title.name]: renderHTMLNode('div', false, true, { class: 'title' }),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue