|
1 | 1 | <script lang="ts">
|
2 | 2 | import type { StatblockItem } from "src/data/constants";
|
3 | 3 |
|
4 |
| - import Group from "./Blocks/GroupBlock.svelte"; |
5 | 4 | import PropertyBlock from "./Blocks/PropertyBlock.svelte";
|
6 | 5 | import type StatBlockPlugin from "src/main";
|
7 |
| - import { ExtraButtonComponent, Menu } from "obsidian"; |
| 6 | + import { ExtraButtonComponent } from "obsidian"; |
8 | 7 | import { createEventDispatcher } from "svelte";
|
9 |
| - import { generate } from "../add"; |
10 | 8 | import { BlockModal } from "./block";
|
11 | 9 | import Rule from "src/view/ui/Rule.svelte";
|
12 |
| - import copy from "fast-copy"; |
13 | 10 |
|
14 | 11 | export let block: StatblockItem;
|
15 | 12 | export let plugin: StatBlockPlugin;
|
16 | 13 |
|
17 | 14 | const dispatch = createEventDispatcher();
|
18 | 15 |
|
19 |
| - const group = block.type == "group"; |
20 |
| - const inline = block.type == "inline"; |
21 |
| -
|
22 | 16 | const editBlock = () => {
|
23 | 17 | const modal = new BlockModal(plugin, block);
|
24 | 18 |
|
25 | 19 | modal.onClose = () => {
|
26 | 20 | if (!modal.saved) return;
|
27 | 21 | dispatch("edited", modal.block);
|
28 |
| - /* block = copy(modal.block); */ |
29 | 22 | };
|
30 | 23 | modal.open();
|
31 | 24 | };
|
|
45 | 38 | .setTooltip("Delete Block")
|
46 | 39 | .onClick(() => dispatch("trash", block));
|
47 | 40 | };
|
48 |
| -
|
49 |
| - const dropdown = (node: HTMLDivElement) => { |
50 |
| - new ExtraButtonComponent(node).setIcon("vertical-three-dots"); |
51 |
| - node.onclick = (evt) => { |
52 |
| - new Menu(plugin.app) |
53 |
| - .addItem((item) => { |
54 |
| - item.setTitle("Add") |
55 |
| - .setIcon("plus-with-circle") |
56 |
| - .onClick(async () => { |
57 |
| - if ( |
58 |
| - block.type == "group" || |
59 |
| - block.type == "inline" |
60 |
| - ) { |
61 |
| - const gen = await generate(plugin, evt); |
62 |
| - if (gen) { |
63 |
| - block.nested = [...block.nested, gen]; |
64 |
| - block = block; |
65 |
| - } |
66 |
| - dispatch("added"); |
67 |
| - } |
68 |
| - }); |
69 |
| - }) |
70 |
| - .addItem((item) => |
71 |
| - item |
72 |
| - .setTitle("Edit") |
73 |
| - .setIcon("pencil") |
74 |
| - .onClick(() => { |
75 |
| - editBlock(); |
76 |
| - }) |
77 |
| - ) |
78 |
| - .addItem((item) => |
79 |
| - item |
80 |
| - .setTitle("Delete") |
81 |
| - .setIcon("trash") |
82 |
| - .onClick(() => dispatch("trash", block)) |
83 |
| - ) |
84 |
| - .showAtMouseEvent(evt); |
85 |
| - }; |
86 |
| - }; |
87 | 41 | </script>
|
88 | 42 |
|
89 |
| -<div class="statblock-creator-container" class:group class:inline> |
| 43 | +<div class="statblock-creator-container"> |
90 | 44 | {#key block}
|
91 | 45 | <div class="statblock-creator-block">
|
92 |
| - {#if block.type == "group" || block.type == "inline"} |
93 |
| - <Group inline={block.type == "inline"} {block} {plugin} /> |
94 |
| - {:else} |
95 |
| - <PropertyBlock {block} /> |
96 |
| - {/if} |
| 46 | + <PropertyBlock {block} /> |
97 | 47 | </div>
|
98 | 48 | {/key}
|
99 |
| - {#if group || inline} |
100 |
| - <div class="icons" use:dropdown /> |
101 |
| - {:else} |
102 |
| - <div class="icons"> |
103 |
| - <div class="icon" use:edit /> |
104 |
| - <div class="icon" use:trash /> |
105 |
| - </div> |
106 |
| - {/if} |
107 |
| -</div> |
108 |
| -{#if block.hasRule} |
109 |
| - <div aria-label="Block Has Rule"> |
110 |
| - <Rule /> |
| 49 | + <div class="icons"> |
| 50 | + <div class="icon" use:edit /> |
| 51 | + <div class="icon" use:trash /> |
111 | 52 | </div>
|
112 |
| -{/if} |
| 53 | +</div> |
113 | 54 |
|
114 | 55 | <style>
|
115 | 56 | .statblock-creator-container {
|
116 | 57 | display: flex;
|
117 | 58 | justify-content: space-between;
|
118 | 59 | /* align-items: center; */
|
119 |
| - padding: 2px; |
120 |
| - margin: 2px; |
121 | 60 | width: 100%;
|
122 | 61 | height: 100%;
|
123 | 62 | }
|
124 | 63 |
|
125 | 64 | :global(body:not(.is-mobile))
|
126 |
| - .statblock-creator-container:not(:hover):not(.group):not(.inline) |
| 65 | + .statblock-creator-container:not(:hover) |
127 | 66 | > .icons {
|
128 | 67 | visibility: hidden;
|
129 | 68 | }
|
|
134 | 73 | display: flex;
|
135 | 74 | justify-content: flex-end;
|
136 | 75 | }
|
137 |
| - .statblock-creator-container:not(.group):not(.inline) .icons { |
| 76 | + .statblock-creator-container .icons { |
138 | 77 | align-items: center;
|
139 | 78 | }
|
140 | 79 | .icon:not(:first-child) :global(.clickable-icon) {
|
|
0 commit comments