REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.61 KB
Close
/home/byroehnu/.trash/node_modules11/prosemirror-transform/src/attr_step.ts
Text
Base64
import {Fragment, Slice, Node, Schema} from "prosemirror-model" import {Step, StepResult} from "./step" import {StepMap, Mappable} from "./map" /// Update an attribute in a specific node. export class AttrStep extends Step { /// Construct an attribute step. constructor( /// The position of the target node. readonly pos: number, /// The attribute to set. readonly attr: string, // The attribute's new value. readonly value: any ) { super() } apply(doc: Node) { let node = doc.nodeAt(this.pos) if (!node) return StepResult.fail("No node at attribute step's position") let attrs = Object.create(null) for (let name in node.attrs) attrs[name] = node.attrs[name] attrs[this.attr] = this.value let updated = node.type.create(attrs, null, node.marks) return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1)) } getMap() { return StepMap.empty } invert(doc: Node) { return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos)!.attrs[this.attr]) } map(mapping: Mappable) { let pos = mapping.mapResult(this.pos, 1) return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value) } toJSON(): any { return {stepType: "attr", pos: this.pos, attr: this.attr, value: this.value} } static fromJSON(schema: Schema, json: any) { if (typeof json.pos != "number" || typeof json.attr != "string") throw new RangeError("Invalid input for AttrStep.fromJSON") return new AttrStep(json.pos, json.attr, json.value) } } Step.jsonID("attr", AttrStep) /// Update an attribute in the doc node. export class DocAttrStep extends Step { /// Construct an attribute step. constructor( /// The attribute to set. readonly attr: string, // The attribute's new value. readonly value: any ) { super() } apply(doc: Node) { let attrs = Object.create(null) for (let name in doc.attrs) attrs[name] = doc.attrs[name] attrs[this.attr] = this.value let updated = doc.type.create(attrs, doc.content, doc.marks) return StepResult.ok(updated) } getMap() { return StepMap.empty } invert(doc: Node) { return new DocAttrStep(this.attr, doc.attrs[this.attr]) } map(mapping: Mappable) { return this } toJSON(): any { return {stepType: "docAttr", attr: this.attr, value: this.value} } static fromJSON(schema: Schema, json: any) { if (typeof json.attr != "string") throw new RangeError("Invalid input for DocAttrStep.fromJSON") return new DocAttrStep(json.attr, json.value) } } Step.jsonID("docAttr", DocAttrStep)
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 11
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
attr_step.ts
2.61 KB
lrw-r--r--
2026-02-28 00:28:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
561 B
lrw-r--r--
2026-02-28 00:28:24
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
map.ts
10.71 KB
lrw-r--r--
2026-02-28 00:28:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mark.ts
3.86 KB
lrw-r--r--
2026-02-28 00:28:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mark_step.ts
7.18 KB
lrw-r--r--
2026-02-28 00:28:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
README.md
1.56 KB
lrw-r--r--
2026-02-28 00:28:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
replace.ts
19.77 KB
lrw-r--r--
2026-02-28 00:28:32
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
replace_step.ts
7.04 KB
lrw-r--r--
2026-02-28 00:28:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
step.ts
3.92 KB
lrw-r--r--
2026-02-28 00:28:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
structure.ts
15.09 KB
lrw-r--r--
2026-02-28 00:28:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
transform.ts
10.18 KB
lrw-r--r--
2026-02-28 00:28:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).