Socket
Socket
Sign inDemoInstall

@tiptap/extension-task-item

Package Overview
Dependencies
2
Maintainers
2
Versions
142
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6

dist/packages/extension-task-item/src/task-item.d.ts

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-task-item@2.0.0-alpha.5...@tiptap/extension-task-item@2.0.0-alpha.6) (2020-12-18)
**Note:** Version bump only for package @tiptap/extension-task-item
# [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-task-item@2.0.0-alpha.4...@tiptap/extension-task-item@2.0.0-alpha.5) (2020-12-02)

@@ -8,0 +16,0 @@

16

dist/packages/extension-task-item/src/index.d.ts

@@ -1,15 +0,3 @@

import { Node } from '@tiptap/core';
export interface TaskItemOptions {
nested: boolean;
HTMLAttributes: {
[key: string]: any;
};
}
export declare const inputRegex: RegExp;
declare const TaskItem: Node<TaskItemOptions, unknown>;
import { TaskItem } from './task-item';
export * from './task-item';
export default TaskItem;
declare module '@tiptap/core' {
interface AllExtensions {
TaskItem: typeof TaskItem;
}
}

@@ -107,4 +107,5 @@ 'use strict';

exports.TaskItem = TaskItem;
exports.default = TaskItem;
exports.inputRegex = inputRegex;
//# sourceMappingURL=tiptap-extension-task-item.cjs.js.map

@@ -104,3 +104,3 @@ import { Node, mergeAttributes } from '@tiptap/core';

export default TaskItem;
export { inputRegex };
export { TaskItem, inputRegex };
//# sourceMappingURL=tiptap-extension-task-item.esm.js.map

@@ -106,2 +106,3 @@ (function (global, factory) {

exports.TaskItem = TaskItem;
exports.default = TaskItem;

@@ -108,0 +109,0 @@ exports.inputRegex = inputRegex;

{
"name": "@tiptap/extension-task-item",
"description": "task item extension for tiptap",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"homepage": "https://tiptap.dev",

@@ -30,3 +30,3 @@ "keywords": [

},
"gitHead": "cf47ceb4c6a1c8e8aadc3bc45009e2d88056e7b9"
"gitHead": "0371cb0a5d803a44d93532aa34419ec7ffffdc24"
}

@@ -1,148 +0,5 @@

import { Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
import { TaskItem } from './task-item'
export interface TaskItemOptions {
nested: boolean,
HTMLAttributes: {
[key: string]: any
},
}
export * from './task-item'
export const inputRegex = /^\s*(\[([ |x])\])\s$/
const TaskItem = Node.create({
name: 'taskItem',
defaultOptions: <TaskItemOptions>{
nested: false,
HTMLAttributes: {},
},
content() {
return this.options.nested ? '(paragraph|taskList)+' : 'paragraph+'
},
defining: true,
addAttributes() {
return {
checked: {
default: false,
parseHTML: element => ({
checked: element.getAttribute('data-checked') === 'true',
}),
renderHTML: attributes => ({
'data-checked': attributes.checked,
}),
},
}
},
parseHTML() {
return [
{
tag: 'li[data-type="taskItem"]',
priority: 51,
},
]
},
renderHTML({ HTMLAttributes }) {
return ['li', mergeAttributes(
this.options.HTMLAttributes,
HTMLAttributes,
{ 'data-type': 'taskItem' },
), 0]
},
addKeyboardShortcuts() {
const shortcuts = {
Enter: () => this.editor.commands.splitListItem('taskItem'),
'Shift-Tab': () => this.editor.commands.liftListItem('taskItem'),
}
if (!this.options.nested) {
return shortcuts
}
return {
...shortcuts,
Tab: () => this.editor.commands.sinkListItem('taskItem'),
}
},
addNodeView() {
return ({
node,
HTMLAttributes,
getPos,
editor,
}) => {
const { view } = editor
const listItem = document.createElement('li')
const checkbox = document.createElement('input')
const content = document.createElement('div')
checkbox.type = 'checkbox'
checkbox.contentEditable = 'false'
checkbox.addEventListener('change', event => {
const { checked } = event.target as any
if (typeof getPos === 'function') {
view.dispatch(view.state.tr.setNodeMarkup(getPos(), undefined, {
checked,
}))
editor.commands.focus()
}
})
if (node.attrs.checked) {
checkbox.setAttribute('checked', 'checked')
}
listItem.append(checkbox, content)
Object.entries(HTMLAttributes).forEach(([key, value]) => {
listItem.setAttribute(key, value)
})
return {
dom: listItem,
contentDOM: content,
update: updatedNode => {
if (updatedNode.type !== this.type) {
return false
}
if (updatedNode.attrs.checked) {
checkbox.setAttribute('checked', 'checked')
} else {
checkbox.removeAttribute('checked')
}
return true
},
}
}
},
addInputRules() {
return [
wrappingInputRule(
inputRegex,
this.type,
match => ({
checked: match[match.length - 1] === 'x',
}),
),
]
},
})
export default TaskItem
declare module '@tiptap/core' {
interface AllExtensions {
TaskItem: typeof TaskItem,
}
}

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc