aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/MenuItem.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/MenuItem.mjs')
-rw-r--r--src/MenuItem.mjs36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs
index 0fea539..8b54539 100644
--- a/src/MenuItem.mjs
+++ b/src/MenuItem.mjs
@@ -1,15 +1,28 @@
1import { shiftByWindow } from './utils.mjs' 1import { shiftByWindow } from './utils.mjs'
2 2
3/** 3/**
4 * Item. Basic Element for menu item 4 * @typedef {Object} RefLink
5 * @property {string} ref -- name of link
6 * @property {string} link -- content of link
7 * @property {string|null} title -- title of link
8 */
9
10/**
11 * Basic Element for menu item
5 * 12 *
6 * @extends {window.HTMLDivElement} 13 * @extends {window.HTMLDivElement}
7 */ 14 */
8export class Item extends window.HTMLDivElement { 15export class Item extends window.HTMLDivElement {
9 /** 16 /**
10 * constructor. 17 * Creates a new Item instance
11 * 18 *
12 * @param {Object} 19 * @param {Object} options - The options for the item
20 * @param {string} [options.text] - The text content of the item
21 * @param {string} [options.innerHTML] - The HTML content of the item
22 * @param {string} [options.title] - The title attribute for the item
23 * @param {Function} [options.onclick] - The click event handler
24 * @param {string} [options.style] - The CSS style string
25 * @param {string[]} [options.className] - Additional CSS classes
13 */ 26 */
14 constructor ({ text, innerHTML, title, onclick, style, className }) { 27 constructor ({ text, innerHTML, title, onclick, style, className }) {
15 super() 28 super()
@@ -30,15 +43,18 @@ export class Item extends window.HTMLDivElement {
30window.customElements.define('menu-item', Item, { extends: 'div' }) 43window.customElements.define('menu-item', Item, { extends: 'div' })
31 44
32/** 45/**
33 * Folder. Basic Element for menu item, it generate submenu on hover 46 * Basic Element for menu item that generates a submenu on hover
34 * 47 *
35 * @extends {window.HTMLDivElement} 48 * @extends {window.HTMLDivElement}
36 */ 49 */
37export class Folder extends window.HTMLDivElement { 50export class Folder extends window.HTMLDivElement {
38 /** 51 /**
39 * constructor. 52 * Creates a new Folder instance
40 * 53 *
41 * @param {} 54 * @param {Object} options - The options for the folder
55 * @param {string} [options.text] - The text content of the folder
56 * @param {string} [options.innerHTML] - The HTML content of the folder
57 * @param {Item[]} options.items - The submenu items
42 */ 58 */
43 constructor ({ text, innerHTML, items }) { 59 constructor ({ text, innerHTML, items }) {
44 super() 60 super()
@@ -67,9 +83,11 @@ export class Folder extends window.HTMLDivElement {
67window.customElements.define('menu-folder', Folder, { extends: 'div' }) 83window.customElements.define('menu-folder', Folder, { extends: 'div' })
68 84
69/** 85/**
70 * pickMapItem. 86 * Creates a menu item for picking a map
71 * 87 *
72 * @param {Function[]} options.utils 88 * @param {Object} options - The options object
89 * @param {Object} options.utils - Utility functions
90 * @returns {Folder} A Folder instance for picking a map
73 */ 91 */
74export const pickMapItem = ({ utils }) => 92export const pickMapItem = ({ utils }) =>
75 new Folder({ 93 new Folder({
@@ -372,7 +390,7 @@ export const restoreCamera = map =>
372 * addRefLink. replace selected text into markdown link by reference style links 390 * addRefLink. replace selected text into markdown link by reference style links
373 * 391 *
374 * @param {CodeMirror} cm 392 * @param {CodeMirror} cm
375 * @param {Object[]} refLinks -- object for { ref, link } 393 * @param {RefLink[]} refLinks
376 */ 394 */
377export const addRefLink = (cm, refLinks) => 395export const addRefLink = (cm, refLinks) =>
378 new Folder({ 396 new Folder({