Sha256: 2b4c04a4205368d92d10c2a08dceedfdf28c6e6eea7a4e38603fe5bcf4c1349a
Contents?: true
Size: 1.02 KB
Versions: 11
Compression:
Stored size: 1.02 KB
Contents
import { Controller } from "@hotwired/stimulus"; import Item from "utils/content/editor/item"; export default class ItemController extends Controller { get item() { return new Item(this.li); } get ol() { return this.element.closest("ol"); } get li() { return this.element.closest("li"); } connect() { if (this.element.dataset.hasOwnProperty("delete")) { this.remove(); } // if index is not already set, re-index will set it else if (!(this.item.index >= 0)) { this.reindex(); } // if item has been replaced via turbo, re-index will run the rules engine // update our depth and index with values from the li's data attributes else if (this.item.hasItemIdChanged()) { this.item.updateAfterChange(); this.reindex(); } } remove() { // capture ol const ol = this.ol; // remove self from dom this.li.remove(); // reindex ol this.reindex(); } reindex() { this.dispatch("reindex", { bubbles: true, prefix: "content" }); } }
Version data entries
11 entries across 11 versions & 1 rubygems