asciidoctor-tabs 1.0.0.alpha.5 → 1.0.0.alpha.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +38 -1
- data/README.adoc +2 -2
- data/data/js/tabs.js +62 -28
- data/lib/asciidoctor/tabs/block.rb +11 -3
- data/lib/asciidoctor/tabs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53a90833ce2142600152bf87248d9470058d6e39495863c644ac7e7bcc8c8ef0
|
4
|
+
data.tar.gz: fd0c9ab6d3e8a27c7bcb48489115b7c7a069a5aee6985626ffb91dc827830baa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f187bad924fd98d618d23b452f5d06551392bb3c2acc25990793af0a2d0a55897a3d1557790df64a9658d9c4dc9a533b7da6e0ae4abb53e9993121a356c2e8e
|
7
|
+
data.tar.gz: '039a9561293145c0717da9f98942d027ee18e89bdd23ab975deec004461e14ac85a1d4aa0540e52d28e9b531d495428f3c4bf74bf3f3c5ea118694ac703547d1'
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,43 @@
|
|
4
4
|
This document provides a curated view of the changes to Asciidoctor Tabs per release.
|
5
5
|
For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
|
6
6
|
|
7
|
+
== 1.0.0-alpha.7 (2022-11-28) - @mojavelinux
|
8
|
+
|
9
|
+
=== Added
|
10
|
+
|
11
|
+
* In tabs script, add `tab` class to tab element
|
12
|
+
* Sync tab selection across tabs blocks if `sync` option is set on tabs block or `tabs-sync-option` attribute is set on document (#28)
|
13
|
+
* Delist tabs block from sync if `nosync` option is set on block (#28)
|
14
|
+
|
15
|
+
=== Changed
|
16
|
+
|
17
|
+
* When inline anchor is used for tab ID, promote value of id attribute to id attribute on tab and remove anchor
|
18
|
+
|
19
|
+
=== Fixed
|
20
|
+
|
21
|
+
* Apply normal substitutions to principal text (first paragraph) of tab's content (#29)
|
22
|
+
|
23
|
+
=== Details
|
24
|
+
|
25
|
+
{url-repo}/releases/tag/v1.0.0-alpha.7[git tag] | {url-repo}/compare/v1.0.0-alpha.6\...v1.0.0-alpha.7[full diff]
|
26
|
+
|
27
|
+
== 1.0.0-alpha.6 (2022-11-16) - @mojavelinux
|
28
|
+
|
29
|
+
=== Added
|
30
|
+
|
31
|
+
* Honor title on tabs block; apply normal subs to it (#26)
|
32
|
+
* Clear location hash (URL fragment) when a tab is clicked (#24)
|
33
|
+
* Register ref for each tab so its ID can be used as target of xref (#24)
|
34
|
+
* Activate tab when selected from an internal xref (#24)
|
35
|
+
|
36
|
+
=== Fixed
|
37
|
+
|
38
|
+
* Decode fragment from URL so it can be matched against tab ID (#27)
|
39
|
+
|
40
|
+
=== Details
|
41
|
+
|
42
|
+
{url-repo}/releases/tag/v1.0.0-alpha.6[git tag] | {url-repo}/compare/v1.0.0-alpha.5\...v1.0.0-alpha.6[full diff]
|
43
|
+
|
7
44
|
== 1.0.0-alpha.5 (2022-10-23) - @mojavelinux
|
8
45
|
|
9
46
|
=== Added
|
@@ -94,7 +131,7 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co
|
|
94
131
|
|
95
132
|
== 1.0.0-alpha.1 (2022-10-01) - @mojavelinux
|
96
133
|
|
97
|
-
_Initial
|
134
|
+
_Initial prerelease._
|
98
135
|
|
99
136
|
=== Details
|
100
137
|
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Asciidoctor Tabs
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
|
3
|
-
v1.0.0-alpha.
|
3
|
+
v1.0.0-alpha.7, 2022-11-28
|
4
4
|
:idprefix:
|
5
5
|
:idseparator: -
|
6
6
|
ifndef::env-github[:icons: font]
|
@@ -84,7 +84,7 @@ The term is used as the tab's label and the description is used as the tab's con
|
|
84
84
|
The contents can be defined as primary text, attached blocks, or both.
|
85
85
|
If the attached blocks are themselves enclosed in a single open block, the open block enclosure itself is discarded upon conversion.
|
86
86
|
|
87
|
-
You may
|
87
|
+
You may choose to extend the block delimiter length from the typical 4 characters to 6 in order to avoid conflicts with any example blocks inside the tab block (or just as a matter of style).
|
88
88
|
|
89
89
|
[,asciidoc]
|
90
90
|
----
|
data/data/js/tabs.js
CHANGED
@@ -1,46 +1,80 @@
|
|
1
|
-
/*! Asciidoctor Tabs | Copyright (c) 2018-present Dan Allen | MIT License */
|
2
|
-
;(function () {
|
1
|
+
;(function () { /*! Asciidoctor Tabs | Copyright (c) 2018-present Dan Allen | MIT License */
|
3
2
|
'use strict'
|
4
3
|
|
5
|
-
var
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
var forEach = Array.prototype.forEach
|
5
|
+
|
6
|
+
init(document.querySelectorAll('.tabset'))
|
7
|
+
|
8
|
+
function init (tabsets) {
|
9
|
+
if (!tabsets.length) return
|
10
|
+
var fragment = getFragment()
|
11
|
+
forEach.call(tabsets, function (tabset) {
|
12
|
+
var tabs = tabset.querySelectorAll('.tabs li')
|
13
|
+
if (!tabs.length) return tabset.classList.remove('is-loading')
|
14
|
+
var active, first, syncId
|
15
|
+
var syncIds = tabset.classList.contains('is-sync') ? {} : undefined
|
16
|
+
forEach.call(tabs, function (tab, idx) {
|
17
|
+
var id = tab.id
|
18
|
+
if (!id) {
|
19
|
+
var anchor = tab.querySelector('a[id]')
|
20
|
+
if (!anchor) return // invalid state
|
21
|
+
tab.id = id = anchor.parentNode.removeChild(anchor).id
|
22
|
+
}
|
23
|
+
tab.className = 'tab'
|
14
24
|
var pane = tabset.querySelector('.tab-pane[aria-labelledby~="' + id + '"]')
|
15
|
-
if (!pane) return
|
16
|
-
|
17
|
-
if (!
|
25
|
+
if (!pane) return // invalid state
|
26
|
+
var instance = { tabset: tabset, tab: tab, pane: pane }
|
27
|
+
if (!idx) first = instance
|
28
|
+
if (!active && fragment === id && (active = true)) {
|
18
29
|
tab.classList.add('is-active')
|
19
|
-
|
20
|
-
}
|
21
|
-
|
22
|
-
|
30
|
+
pane.classList.add('is-active')
|
31
|
+
}
|
32
|
+
if (syncIds && !((syncId = tab.textContent.trim()) in syncIds)) {
|
33
|
+
syncIds[(tab.dataset.syncId = syncId)] = true
|
34
|
+
tab.addEventListener('click', activateTabSync.bind(instance))
|
35
|
+
} else {
|
36
|
+
tab.addEventListener('click', activateTab.bind(instance))
|
23
37
|
}
|
24
|
-
tab.addEventListener('click', activateTab.bind({ tabset: tabset, tab: tab, pane: pane }))
|
25
38
|
})
|
26
39
|
if (!active && first) {
|
27
40
|
first.tab.classList.add('is-active')
|
28
|
-
|
41
|
+
first.pane.classList.add('is-active')
|
29
42
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
43
|
+
tabset.classList.remove('is-loading')
|
44
|
+
})
|
45
|
+
window.addEventListener('hashchange', onHashChange)
|
46
|
+
}
|
33
47
|
|
34
48
|
function activateTab (e) {
|
35
49
|
var tab = this.tab
|
36
|
-
var
|
37
|
-
|
38
|
-
|
50
|
+
var tabset = this.tabset || tab.closest('.tabset')
|
51
|
+
var pane = this.pane || tabset.querySelector('.tab-pane[aria-labelledby~="' + tab.id + '"]')
|
52
|
+
forEach.call(tabset.querySelectorAll('.tabs li, .tab-pane'), function (el) {
|
53
|
+
el === tab || el === pane ? el.classList.add('is-active') : el.classList.remove('is-active')
|
39
54
|
})
|
55
|
+
if (!e) return
|
56
|
+
var loc = window.location
|
57
|
+
var hashIdx = loc.hash ? loc.href.indexOf('#') : -1
|
58
|
+
if (~hashIdx) window.history.replaceState(null, '', loc.href.slice(0, hashIdx))
|
40
59
|
e.preventDefault()
|
41
60
|
}
|
42
61
|
|
43
|
-
function
|
44
|
-
|
62
|
+
function activateTabSync (e) {
|
63
|
+
activateTab.call(this, e)
|
64
|
+
var thisTab = this.tab
|
65
|
+
forEach.call(document.querySelectorAll('.tabs li'), function (tab) {
|
66
|
+
if (tab !== thisTab && tab.dataset.syncId === thisTab.dataset.syncId) activateTab.call({ tab: tab })
|
67
|
+
})
|
68
|
+
}
|
69
|
+
|
70
|
+
function getFragment (hash) {
|
71
|
+
return (hash = window.location.hash) && (~hash.indexOf('%') ? decodeURIComponent(hash.slice(1)) : hash.slice(1))
|
72
|
+
}
|
73
|
+
|
74
|
+
function onHashChange () {
|
75
|
+
var id = getFragment()
|
76
|
+
if (!id) return
|
77
|
+
var tab = document.getElementById(id)
|
78
|
+
if (tab && tab.classList.contains('tab')) activateTab.call({ tab: tab })
|
45
79
|
}
|
46
80
|
})()
|
@@ -18,7 +18,11 @@ module Asciidoctor
|
|
18
18
|
end
|
19
19
|
tabset_number = doc.counter 'tabset-number'
|
20
20
|
tabs_id = attrs['id'] || (generate_id %(tabset #{tabset_number}), doc)
|
21
|
-
|
21
|
+
sync = !(block.option? 'nosync') && ((block.option? 'sync') || (doc.option? 'tabs-sync')) ? ' is-sync' : nil
|
22
|
+
parent << (create_html_fragment parent, %(<div id="#{tabs_id}" class="tabset#{sync || ''} is-loading">))
|
23
|
+
if (title = attrs['title'])
|
24
|
+
parent << (create_html_fragment parent, %(<div class="title">#{parent.apply_subs title}</div>))
|
25
|
+
end
|
22
26
|
(tabs = create_list parent, :ulist).add_role 'tabs'
|
23
27
|
panes = {}
|
24
28
|
set_id_on_tab = (doc.backend == 'html5') || (list_item_supports_id? doc)
|
@@ -26,11 +30,15 @@ module Asciidoctor
|
|
26
30
|
tab_ids = labels.map do |tab|
|
27
31
|
tabs << tab
|
28
32
|
tab_id = generate_id tab.text, doc, tabs_id
|
29
|
-
|
33
|
+
tab_source_text = tab.instance_variable_get :@text
|
34
|
+
set_id_on_tab ? (tab.id = tab_id) : (tab.text = %([[#{tab_id}]]#{tab_source_text}))
|
35
|
+
(doc.register :refs, [tab_id, tab]).set_attr 'reftext', tab_source_text
|
30
36
|
tab_id
|
31
37
|
end
|
32
38
|
if content
|
33
|
-
tab_blocks = content.text? ?
|
39
|
+
tab_blocks = content.text? ?
|
40
|
+
[(create_paragraph parent, (content.instance_variable_get :@text), nil, subs: :normal)]
|
41
|
+
: []
|
34
42
|
if content.blocks?
|
35
43
|
if (block0 = (blocks = content.blocks)[0]).context == :open && blocks.size == 1 && block0.blocks?
|
36
44
|
blocks = block0.blocks
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: 1.3.1
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.3.
|
104
|
+
rubygems_version: 3.3.26
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: An Asciidoctor extension that adds a tabs block to the AsciiDoc syntax.
|