@diplodoc/transform 4.28.2 → 4.29.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/print.css.map +2 -2
- package/dist/css/yfm.css +52 -45
- package/dist/css/yfm.css.map +3 -3
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +3 -3
- package/dist/js/yfm.js +58 -49
- package/dist/js/yfm.js.map +4 -4
- package/dist/js/yfm.min.js +1 -1
- package/dist/js/yfm.min.js.map +4 -4
- package/lib/plugins/anchors/index.js +3 -1
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/cut.d.ts +4 -3
- package/lib/plugins/cut.js +2 -68
- package/lib/plugins/cut.js.map +1 -1
- package/package.json +3 -2
- package/src/js/index.ts +1 -1
- package/src/scss/yfm.scss +1 -1
- package/src/transform/plugins/anchors/index.ts +5 -1
- package/src/transform/plugins/cut.ts +2 -97
- package/src/js/cut.ts +0 -57
package/src/js/cut.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {getEventTarget, isCustom} from './utils';
|
|
2
|
-
|
|
3
|
-
const Selector = {
|
|
4
|
-
CUT: '.yfm .yfm-cut',
|
|
5
|
-
TITLE: '.yfm .yfm-cut-title',
|
|
6
|
-
CONTENT: '.yfm .yfm-cut-content',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const ClassName = {
|
|
10
|
-
OPEN: 'open',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function toggleCut(element: HTMLElement) {
|
|
14
|
-
const cutNode = element.parentNode;
|
|
15
|
-
|
|
16
|
-
if (!(cutNode instanceof HTMLElement)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
cutNode.classList.toggle(ClassName.OPEN);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function matchTitle(target: EventTarget | null) {
|
|
24
|
-
if (!(target instanceof HTMLElement)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return target?.matches?.(Selector.TITLE);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function findTitleInPath(event: MouseEvent): HTMLElement | undefined {
|
|
32
|
-
const target = getEventTarget(event);
|
|
33
|
-
|
|
34
|
-
if (matchTitle(target)) {
|
|
35
|
-
return target as HTMLElement;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const path = event.composedPath?.();
|
|
39
|
-
|
|
40
|
-
return path?.find(matchTitle) as HTMLElement | undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof document !== 'undefined') {
|
|
44
|
-
document.addEventListener('click', (event) => {
|
|
45
|
-
if (isCustom(event)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const title = findTitleInPath(event);
|
|
50
|
-
|
|
51
|
-
if (!title) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
toggleCut(title);
|
|
56
|
-
});
|
|
57
|
-
}
|