prosemirror-flat-list
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -1017,14 +1017,18 @@ // src/commands/dedent-list.ts | ||
const content = []; | ||
let updated = false; | ||
for (const node of nodes) { | ||
if (node.type === "bullet_list" || node.type === "bulletList") { | ||
updated = true; | ||
for (const child of (_a = node.content) != null ? _a : []) { | ||
content.push(migrateNode(child, { type: "bullet" })); | ||
content.push(migrateNode(child, { type: "bullet" })[0]); | ||
} | ||
} else if (node.type === "ordered_list" || node.type === "orderedList") { | ||
updated = true; | ||
for (const child of (_b = node.content) != null ? _b : []) { | ||
content.push(migrateNode(child, { type: "ordered" })); | ||
content.push(migrateNode(child, { type: "ordered" })[0]); | ||
} | ||
} else if (node.type === "task_list" || node.type === "taskList") { | ||
updated = true; | ||
for (const child of (_c = node.content) != null ? _c : []) { | ||
content.push(migrateNode(child, { type: "task" })); | ||
content.push(migrateNode(child, { type: "task" })[0]); | ||
} | ||
@@ -1035,3 +1039,3 @@ } else { | ||
} | ||
return content; | ||
return [content, updated]; | ||
} | ||
@@ -1041,20 +1045,25 @@ function migrateNode(node, { type } = {}) { | ||
if (node.type === "list_item" || node.type === "listItem" || node.type === "taskListItem") { | ||
return { | ||
...node, | ||
type: "list", | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
return [ | ||
{ | ||
...node, | ||
type: "list", | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
}, | ||
content: node.content ? migrateNodes(node.content)[0] : void 0 | ||
}, | ||
content: node.content ? migrateNodes(node.content) : void 0 | ||
}; | ||
true | ||
]; | ||
} else if (node.content) { | ||
const [content, updated] = migrateNodes(node.content); | ||
return [{ ...node, content }, updated]; | ||
} else { | ||
return [node, false]; | ||
} | ||
return { | ||
...node, | ||
content: node.content ? migrateNodes(node.content) : void 0 | ||
}; | ||
} | ||
function migrateDocJSON(docJSON) { | ||
return migrateNode(docJSON); | ||
const [migrated, updated] = migrateNode(docJSON); | ||
return updated ? migrated : null; | ||
} | ||
@@ -1061,0 +1070,0 @@ |
@@ -184,4 +184,10 @@ import { Attrs } from 'prosemirror-model'; | ||
/** @public */ | ||
export declare function migrateDocJSON(docJSON: ProsemirrorNodeJSON): ProsemirrorNodeJSON; | ||
/** | ||
* Migrate a ProseMirror document JSON object from the old list structure to the | ||
* new. A new document JSON object is returned if the document is updated, | ||
* otherwise `null` is returned. | ||
* | ||
* @public | ||
*/ | ||
export declare function migrateDocJSON(docJSON: ProsemirrorNodeJSON): ProsemirrorNodeJSON | null; | ||
@@ -188,0 +194,0 @@ /** |
@@ -1017,14 +1017,18 @@ // src/commands/dedent-list.ts | ||
const content = []; | ||
let updated = false; | ||
for (const node of nodes) { | ||
if (node.type === "bullet_list" || node.type === "bulletList") { | ||
updated = true; | ||
for (const child of (_a = node.content) != null ? _a : []) { | ||
content.push(migrateNode(child, { type: "bullet" })); | ||
content.push(migrateNode(child, { type: "bullet" })[0]); | ||
} | ||
} else if (node.type === "ordered_list" || node.type === "orderedList") { | ||
updated = true; | ||
for (const child of (_b = node.content) != null ? _b : []) { | ||
content.push(migrateNode(child, { type: "ordered" })); | ||
content.push(migrateNode(child, { type: "ordered" })[0]); | ||
} | ||
} else if (node.type === "task_list" || node.type === "taskList") { | ||
updated = true; | ||
for (const child of (_c = node.content) != null ? _c : []) { | ||
content.push(migrateNode(child, { type: "task" })); | ||
content.push(migrateNode(child, { type: "task" })[0]); | ||
} | ||
@@ -1035,3 +1039,3 @@ } else { | ||
} | ||
return content; | ||
return [content, updated]; | ||
} | ||
@@ -1041,20 +1045,25 @@ function migrateNode(node, { type } = {}) { | ||
if (node.type === "list_item" || node.type === "listItem" || node.type === "taskListItem") { | ||
return { | ||
...node, | ||
type: "list", | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
return [ | ||
{ | ||
...node, | ||
type: "list", | ||
attrs: { | ||
collapsed: (_a = node.attrs) == null ? void 0 : _a.closed, | ||
...node.attrs, | ||
type: type != null ? type : "bullet" | ||
}, | ||
content: node.content ? migrateNodes(node.content)[0] : void 0 | ||
}, | ||
content: node.content ? migrateNodes(node.content) : void 0 | ||
}; | ||
true | ||
]; | ||
} else if (node.content) { | ||
const [content, updated] = migrateNodes(node.content); | ||
return [{ ...node, content }, updated]; | ||
} else { | ||
return [node, false]; | ||
} | ||
return { | ||
...node, | ||
content: node.content ? migrateNodes(node.content) : void 0 | ||
}; | ||
} | ||
function migrateDocJSON(docJSON) { | ||
return migrateNode(docJSON); | ||
const [migrated, updated] = migrateNode(docJSON); | ||
return updated ? migrated : null; | ||
} | ||
@@ -1061,0 +1070,0 @@ |
{ | ||
"name": "prosemirror-flat-list", | ||
"type": "module", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "", | ||
@@ -51,2 +51,3 @@ "author": "ocavue <ocavue@gmail.com>", | ||
"dedent": "^0.7.0", | ||
"execa": "^7.0.0", | ||
"jest-prosemirror": "^2.1.1", | ||
@@ -53,0 +54,0 @@ "jest-remirror": "^2.1.3", |
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
117106
3731
29