@tiptap/extension-ordered-list
Advanced tools
Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5
@@ -6,2 +6,10 @@ # Change Log | ||
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-ordered-list@2.0.0-alpha.4...@tiptap/extension-ordered-list@2.0.0-alpha.5) (2020-12-18) | ||
**Note:** Version bump only for package @tiptap/extension-ordered-list | ||
# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-ordered-list@2.0.0-alpha.3...@tiptap/extension-ordered-list@2.0.0-alpha.4) (2020-12-02) | ||
@@ -8,0 +16,0 @@ |
@@ -1,19 +0,3 @@ | ||
import { Command, Node } from '@tiptap/core'; | ||
export interface OrderedListOptions { | ||
HTMLAttributes: { | ||
[key: string]: any; | ||
}; | ||
} | ||
export declare const inputRegex: RegExp; | ||
declare const OrderedList: Node<OrderedListOptions, { | ||
/** | ||
* Toggle an ordered list | ||
*/ | ||
toggleOrderedList: () => Command; | ||
}>; | ||
import { OrderedList } from './ordered-list'; | ||
export * from './ordered-list'; | ||
export default OrderedList; | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
OrderedList: typeof OrderedList; | ||
} | ||
} |
@@ -63,4 +63,5 @@ 'use strict'; | ||
exports.OrderedList = OrderedList; | ||
exports.default = OrderedList; | ||
exports.inputRegex = inputRegex; | ||
//# sourceMappingURL=tiptap-extension-ordered-list.cjs.js.map |
@@ -60,3 +60,3 @@ import { Node, mergeAttributes } from '@tiptap/core'; | ||
export default OrderedList; | ||
export { inputRegex }; | ||
export { OrderedList, inputRegex }; | ||
//# sourceMappingURL=tiptap-extension-ordered-list.esm.js.map |
@@ -62,2 +62,3 @@ (function (global, factory) { | ||
exports.OrderedList = OrderedList; | ||
exports.default = OrderedList; | ||
@@ -64,0 +65,0 @@ exports.inputRegex = inputRegex; |
{ | ||
"name": "@tiptap/extension-ordered-list", | ||
"description": "ordered list extension for tiptap", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0-alpha.5", | ||
"homepage": "https://tiptap.dev", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "a884cb81de8783d0097741c1ddb97a82ea88ae0e" | ||
"gitHead": "0371cb0a5d803a44d93532aa34419ec7ffffdc24" | ||
} |
@@ -1,87 +0,5 @@ | ||
import { Command, Node, mergeAttributes } from '@tiptap/core' | ||
import { wrappingInputRule } from 'prosemirror-inputrules' | ||
import { OrderedList } from './ordered-list' | ||
export interface OrderedListOptions { | ||
HTMLAttributes: { | ||
[key: string]: any | ||
}, | ||
} | ||
export * from './ordered-list' | ||
export const inputRegex = /^(\d+)\.\s$/ | ||
const OrderedList = Node.create({ | ||
name: 'orderedList', | ||
defaultOptions: <OrderedListOptions>{ | ||
HTMLAttributes: {}, | ||
}, | ||
group: 'block list', | ||
content: 'listItem+', | ||
addAttributes() { | ||
return { | ||
start: { | ||
default: 1, | ||
parseHTML: element => ({ | ||
start: 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 { | ||
/** | ||
* Toggle an ordered list | ||
*/ | ||
toggleOrderedList: (): Command => ({ commands }) => { | ||
return commands.toggleList('orderedList', 'listItem') | ||
}, | ||
} | ||
}, | ||
addKeyboardShortcuts() { | ||
return { | ||
'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(), | ||
} | ||
}, | ||
addInputRules() { | ||
return [ | ||
wrappingInputRule( | ||
inputRegex, | ||
this.type, | ||
match => ({ order: +match[1] }), | ||
(match, node) => node.childCount + node.attrs.order === +match[1], | ||
), | ||
] | ||
}, | ||
}) | ||
export default OrderedList | ||
declare module '@tiptap/core' { | ||
interface AllExtensions { | ||
OrderedList: typeof OrderedList, | ||
} | ||
} |
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 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
461705
16
608