@tiptap/extension-ordered-list
Advanced tools
Comparing version 2.0.0-beta.213 to 2.0.0-beta.214
@@ -1,67 +0,66 @@ | ||
// src/ordered-list.ts | ||
import { mergeAttributes, Node, wrappingInputRule } from "@tiptap/core"; | ||
var inputRegex = /^(\d+)\.\s$/; | ||
var OrderedList = Node.create({ | ||
name: "orderedList", | ||
addOptions() { | ||
return { | ||
itemTypeName: "listItem", | ||
HTMLAttributes: {} | ||
}; | ||
}, | ||
group: "block list", | ||
content() { | ||
return `${this.options.itemTypeName}+`; | ||
}, | ||
addAttributes() { | ||
return { | ||
start: { | ||
default: 1, | ||
parseHTML: (element) => { | ||
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1; | ||
} | ||
} | ||
}; | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: "ol" | ||
} | ||
]; | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
const { start, ...attributesWithoutStart } = HTMLAttributes; | ||
return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
}, | ||
addCommands() { | ||
return { | ||
toggleOrderedList: () => ({ commands }) => { | ||
return commands.toggleList(this.name, this.options.itemTypeName); | ||
} | ||
}; | ||
}, | ||
addKeyboardShortcuts() { | ||
return { | ||
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList() | ||
}; | ||
}, | ||
addInputRules() { | ||
return [ | ||
wrappingInputRule({ | ||
find: inputRegex, | ||
type: this.type, | ||
getAttributes: (match) => ({ start: +match[1] }), | ||
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1] | ||
}) | ||
]; | ||
} | ||
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'; | ||
const inputRegex = /^(\d+)\.\s$/; | ||
const OrderedList = Node.create({ | ||
name: 'orderedList', | ||
addOptions() { | ||
return { | ||
itemTypeName: 'listItem', | ||
HTMLAttributes: {}, | ||
}; | ||
}, | ||
group: 'block list', | ||
content() { | ||
return `${this.options.itemTypeName}+`; | ||
}, | ||
addAttributes() { | ||
return { | ||
start: { | ||
default: 1, | ||
parseHTML: element => { | ||
return element.hasAttribute('start') | ||
? parseInt(element.getAttribute('start') || '', 10) | ||
: 1; | ||
}, | ||
}, | ||
}; | ||
}, | ||
parseHTML() { | ||
return [ | ||
{ | ||
tag: 'ol', | ||
}, | ||
]; | ||
}, | ||
renderHTML({ HTMLAttributes }) { | ||
const { start, ...attributesWithoutStart } = HTMLAttributes; | ||
return start === 1 | ||
? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] | ||
: ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
}, | ||
addCommands() { | ||
return { | ||
toggleOrderedList: () => ({ commands }) => { | ||
return commands.toggleList(this.name, this.options.itemTypeName); | ||
}, | ||
}; | ||
}, | ||
addKeyboardShortcuts() { | ||
return { | ||
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(), | ||
}; | ||
}, | ||
addInputRules() { | ||
return [ | ||
wrappingInputRule({ | ||
find: inputRegex, | ||
type: this.type, | ||
getAttributes: match => ({ start: +match[1] }), | ||
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1], | ||
}), | ||
]; | ||
}, | ||
}); | ||
// src/index.ts | ||
var src_default = OrderedList; | ||
export { | ||
OrderedList, | ||
src_default as default, | ||
inputRegex | ||
}; | ||
export { OrderedList, OrderedList as default, inputRegex }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/extension-ordered-list", | ||
"description": "ordered list extension for tiptap", | ||
"version": "2.0.0-beta.213", | ||
"version": "2.0.0-beta.214", | ||
"homepage": "https://tiptap.dev", | ||
@@ -18,3 +18,3 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": "./dist/packages/extension-ordered-list/src/index.d.ts", | ||
"import": "./dist/index.js", | ||
@@ -26,3 +26,4 @@ "require": "./dist/index.cjs" | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"umd": "dist/index.umd.js", | ||
"types": "dist/packages/extension-ordered-list/src/index.d.ts", | ||
"files": [ | ||
@@ -36,3 +37,3 @@ "src", | ||
"devDependencies": { | ||
"@tiptap/core": "^2.0.0-beta.213" | ||
"@tiptap/core": "^2.0.0-beta.214" | ||
}, | ||
@@ -45,15 +46,5 @@ "repository": { | ||
"scripts": { | ||
"build": "tsup" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"src/index.ts" | ||
], | ||
"dts": true, | ||
"splitting": true, | ||
"format": [ | ||
"esm", | ||
"cjs" | ||
] | ||
"clean": "rm -rf dist", | ||
"build": "npm run clean && rollup -c" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
22727
12
303