@diplodoc/transform 4.21.0 → 4.23.0
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 +1 -1
- package/dist/css/yfm.css +102 -0
- 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 +114 -0
- 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/table/attrs.d.ts +18 -0
- package/lib/plugins/table/attrs.js +172 -0
- package/lib/plugins/table/attrs.js.map +1 -0
- package/lib/plugins/table/index.js +21 -5
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/sanitize.js +1 -0
- package/lib/sanitize.js.map +1 -1
- package/package.json +1 -1
- package/src/js/index.ts +1 -0
- package/src/js/wide-mode/apply.ts +34 -0
- package/src/js/wide-mode/constants.ts +1 -0
- package/src/js/wide-mode/globals.d.ts +12 -0
- package/src/js/wide-mode/icons/close.ts +1 -0
- package/src/js/wide-mode/icons/expand.ts +1 -0
- package/src/js/wide-mode/index.ts +5 -0
- package/src/js/wide-mode/modal.ts +111 -0
- package/src/scss/_modal.scss +123 -0
- package/src/scss/yfm.scss +1 -0
- package/src/transform/plugins/table/attrs.ts +199 -0
- package/src/transform/plugins/table/index.ts +14 -4
- package/src/transform/sanitize.ts +1 -0
- package/lib/plugins/table/utils.d.ts +0 -1
- package/lib/plugins/table/utils.js +0 -82
- package/lib/plugins/table/utils.js.map +0 -1
- package/src/transform/plugins/table/utils.ts +0 -107
package/lib/sanitize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/transform/sanitize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAyC;AACzC,aAAa;AACb,0DAAkC;AAClC,iDAAmC;AACn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ACP,MAAM;IACN,MAAM;IACN,SAAS;IACT,MAAM;IACN,KAAK;IACL,KAAK;IACL,WAAW;IACX,OAAO;IACP,QAAQ;IACR,KAAK;IACL,WAAW;IACX,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,aAAa;IACb,aAAa;IACb,QAAQ;IACR,SAAS;IACT,SAAS;IACT,YAAY;IACZ,UAAU;IACV,KAAK;IACL,UAAU;IACV,KAAK;IACL,UAAU;IACV,MAAM;IACN,MAAM;IACN,SAAS;IACT,YAAY;IACZ,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;IACV,OAAO;IACP,WAAW;IACX,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,aAAa;IACb,WAAW;IACX,OAAO;IACP,QAAQ;IACR,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,QAAQ;
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/transform/sanitize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAyC;AACzC,aAAa;AACb,0DAAkC;AAClC,iDAAmC;AACnC,8CAAsB;AAEtB,MAAM,QAAQ,GAAG;IACb,GAAG;IACH,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,GAAG;IACH,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;IACZ,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;I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I,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzF,OAAO,IAAA,uBAAY,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AARD,2BAQC"}
|
package/package.json
CHANGED
package/src/js/index.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {WIDE_ELEMENTS_SELECTOR} from './constants';
|
|
2
|
+
import expand from './icons/expand';
|
|
3
|
+
import {modal} from './modal';
|
|
4
|
+
|
|
5
|
+
const wrap = (target: HTMLElement) => {
|
|
6
|
+
if (target.parentElement?.classList.contains('wide-element-wrapper')) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
target.classList.add('wide-inner-element');
|
|
11
|
+
|
|
12
|
+
const handler = document.createElement('div');
|
|
13
|
+
|
|
14
|
+
handler.innerHTML = expand;
|
|
15
|
+
handler.classList.add('wide-content-viewer');
|
|
16
|
+
handler.addEventListener('click', () => modal.render(target));
|
|
17
|
+
|
|
18
|
+
const container = document.createElement('div');
|
|
19
|
+
|
|
20
|
+
container.classList.add('wide-element-wrapper');
|
|
21
|
+
|
|
22
|
+
target.before(container);
|
|
23
|
+
|
|
24
|
+
container.appendChild(handler);
|
|
25
|
+
container.appendChild(target);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const applyWideMode = () => {
|
|
29
|
+
const allWideElements = Array.from(
|
|
30
|
+
document.querySelectorAll(WIDE_ELEMENTS_SELECTOR),
|
|
31
|
+
) as HTMLElement[];
|
|
32
|
+
|
|
33
|
+
allWideElements.forEach(wrap);
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const WIDE_ELEMENTS_SELECTOR = '[wide-content]';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default `<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg" class="close-action"><path fillRule="evenodd" clipRule="evenodd" d="M9.46967 9.46967C9.76256 9.17678 10.2374 9.17678 10.5303 9.46967L14 12.9393L17.4697 9.46967C17.7626 9.17678 18.2374 9.17678 18.5303 9.46967C18.8232 9.76256 18.8232 10.2374 18.5303 10.5303L15.0607 14L18.5303 17.4697C18.8232 17.7626 18.8232 18.2374 18.5303 18.5303C18.2374 18.8232 17.7626 18.8232 17.4697 18.5303L14 15.0607L10.5303 18.5303C10.2374 18.8232 9.76256 18.8232 9.46967 18.5303C9.17678 18.2374 9.17678 17.7626 9.46967 17.4697L12.9393 14L9.46967 10.5303C9.17678 10.2374 9.17678 9.76256 9.46967 9.46967Z" fill="var(--g-color-text-primary)" fillOpacity="0.85"/></svg>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.754 2.004a.75.75 0 0 0 0 1.5h4.75v4.742a.75.75 0 0 0 1.5 0V2.754a.75.75 0 0 0-.75-.75zm.492 11.992a.75.75 0 0 0 0-1.5h-4.75V7.754a.75.75 0 0 0-1.5 0v5.492a.75.75 0 0 0 .75.75z" clip-rule="evenodd"/></svg>`;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import closeIcon from './icons/close';
|
|
2
|
+
|
|
3
|
+
const remove = () => {
|
|
4
|
+
if (!window.wideTemplate) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
window.wideTemplate.style.display = 'none';
|
|
9
|
+
window.wideTemplate.content(undefined);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const tbodyOf = (node: HTMLElement) => {
|
|
13
|
+
if (node.tagName !== 'TABLE') {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const elements = Array.from(node.children);
|
|
18
|
+
|
|
19
|
+
const thead = elements.find((child) => child.tagName === 'THEAD');
|
|
20
|
+
|
|
21
|
+
if (thead) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const tbody = elements.find((child) => child.tagName === 'TBODY');
|
|
26
|
+
|
|
27
|
+
return tbody;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ModalContainer = NonNullable<typeof window.wideTemplate>;
|
|
31
|
+
|
|
32
|
+
/* @todo refactor to markup with innerHTML @v8tenko */
|
|
33
|
+
|
|
34
|
+
const container = () => {
|
|
35
|
+
if (window.wideTemplate) {
|
|
36
|
+
return window.wideTemplate;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const template = document.createElement('div') as ModalContainer;
|
|
40
|
+
template.classList.add('dc-doc-page', 'wide-container');
|
|
41
|
+
|
|
42
|
+
const overlay = document.createElement('div');
|
|
43
|
+
overlay.classList.add('wide-content-overlay');
|
|
44
|
+
overlay.addEventListener('click', remove);
|
|
45
|
+
|
|
46
|
+
const wrapper = document.createElement('div');
|
|
47
|
+
wrapper.classList.add('yfm', 'wide-content-wrapper');
|
|
48
|
+
|
|
49
|
+
const toolbar = document.createElement('div');
|
|
50
|
+
toolbar.classList.add('wide-toolbar');
|
|
51
|
+
|
|
52
|
+
const close = document.createElement('div');
|
|
53
|
+
close.classList.add('wide-actions');
|
|
54
|
+
close.addEventListener('click', remove);
|
|
55
|
+
close.innerHTML = closeIcon;
|
|
56
|
+
|
|
57
|
+
const title = document.createElement('p');
|
|
58
|
+
title.classList.add('wide-entity-name');
|
|
59
|
+
|
|
60
|
+
template.label = (content: string) => {
|
|
61
|
+
title.innerHTML = content;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const content = document.createElement('div');
|
|
65
|
+
content.classList.add('wide-content');
|
|
66
|
+
|
|
67
|
+
template.content = (target?: Element) => {
|
|
68
|
+
if (typeof target === 'undefined') {
|
|
69
|
+
content.innerHTML = '';
|
|
70
|
+
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const cloned = target.cloneNode(true) as HTMLElement;
|
|
75
|
+
|
|
76
|
+
const tbody = tbodyOf(cloned);
|
|
77
|
+
|
|
78
|
+
/* used to stretch single tbody to 100% */
|
|
79
|
+
tbody?.classList?.add('wide-thead-content');
|
|
80
|
+
|
|
81
|
+
content.replaceChildren(cloned);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
toolbar.append(title, close);
|
|
85
|
+
wrapper.append(toolbar, content);
|
|
86
|
+
template.append(overlay, wrapper);
|
|
87
|
+
|
|
88
|
+
template.style.display = 'none';
|
|
89
|
+
document.body.appendChild(template);
|
|
90
|
+
|
|
91
|
+
window.wideTemplate = template;
|
|
92
|
+
|
|
93
|
+
return template;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const render = (content: HTMLElement) => {
|
|
97
|
+
const template = container();
|
|
98
|
+
|
|
99
|
+
if (content.title) {
|
|
100
|
+
template.label(content.title);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
template.content(content);
|
|
104
|
+
|
|
105
|
+
template.style.display = 'flex';
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const modal = {
|
|
109
|
+
render,
|
|
110
|
+
remove,
|
|
111
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
.wide-container {
|
|
2
|
+
position: fixed;
|
|
3
|
+
width: 100vw;
|
|
4
|
+
height: 100vh;
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
top: 0px;
|
|
9
|
+
left: 0px;
|
|
10
|
+
z-index: 200;
|
|
11
|
+
|
|
12
|
+
&.dc-doc-page {
|
|
13
|
+
max-width: 100% !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.wide-content-viewer {
|
|
17
|
+
visibility: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.wide-content-wrapper {
|
|
21
|
+
z-index: 200;
|
|
22
|
+
background-color: var(--g-color-base-background);
|
|
23
|
+
height: 90vh;
|
|
24
|
+
width: 70vw;
|
|
25
|
+
border-radius: 10px;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
|
|
29
|
+
.wide-content {
|
|
30
|
+
height: 95%;
|
|
31
|
+
width: 100%;
|
|
32
|
+
|
|
33
|
+
.wide-inner-element {
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
table {
|
|
40
|
+
border-radius: 0px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.wide-thead-content {
|
|
44
|
+
display: table;
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.wide-toolbar {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
width: 100%;
|
|
53
|
+
justify-content: space-between;
|
|
54
|
+
align-items: center;
|
|
55
|
+
padding: 10px 12px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.wide-entity-name {
|
|
59
|
+
margin: 0;
|
|
60
|
+
font-size: 18px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.wide-actions {
|
|
64
|
+
align-self: flex-end;
|
|
65
|
+
|
|
66
|
+
.close-action {
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
border-radius: 3px;
|
|
69
|
+
|
|
70
|
+
transition: background 300ms;
|
|
71
|
+
|
|
72
|
+
&:hover {
|
|
73
|
+
background: var(--g-color-base-simple-hover);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.wide-element-wrapper {
|
|
81
|
+
display: inline-block;
|
|
82
|
+
position: relative;
|
|
83
|
+
padding-right: 30px;
|
|
84
|
+
|
|
85
|
+
&:hover > .wide-content-viewer {
|
|
86
|
+
visibility: visible;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
.wide-inner-element {
|
|
91
|
+
max-width: 700px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.wide-content-viewer {
|
|
96
|
+
position: absolute;
|
|
97
|
+
visibility: hidden;
|
|
98
|
+
width: 30px;
|
|
99
|
+
height: 30px;
|
|
100
|
+
z-index: 100;
|
|
101
|
+
padding: 6px;
|
|
102
|
+
right: -20px;
|
|
103
|
+
box-sizing: content-box;
|
|
104
|
+
color: var(--g-color-text-primary);
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
|
|
107
|
+
& > svg {
|
|
108
|
+
width: 20px;
|
|
109
|
+
height: 20px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
.wide-content-overlay {
|
|
115
|
+
z-index: 100;
|
|
116
|
+
width: 100vw;
|
|
117
|
+
height: 100vh;
|
|
118
|
+
position: fixed;
|
|
119
|
+
top: 0;
|
|
120
|
+
left: 0;
|
|
121
|
+
background-color: black;
|
|
122
|
+
opacity: 0.6;
|
|
123
|
+
}
|
package/src/scss/yfm.scss
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
type Attrs = 'class' | 'id' | 'attr';
|
|
2
|
+
|
|
3
|
+
export class AttrsParser {
|
|
4
|
+
DELIMITER = '=';
|
|
5
|
+
SEPARATOR = ' ';
|
|
6
|
+
QUOTATION = '"';
|
|
7
|
+
/* allowed in keys / values chars */
|
|
8
|
+
ALLOWED_CHARS = /[a-zA-Z0-9_\- {}.|/]/;
|
|
9
|
+
/* allowed in all query chars */
|
|
10
|
+
VALIDATION_CHARS = /[a-zA-Z0-9_\- {}.#="|/]/;
|
|
11
|
+
|
|
12
|
+
#key = '';
|
|
13
|
+
#pending = '';
|
|
14
|
+
#isInsideQuotation = false;
|
|
15
|
+
#didQuotationClosed = false;
|
|
16
|
+
#currentKeyType: Attrs | undefined;
|
|
17
|
+
|
|
18
|
+
#selectors: Record<Attrs, RegExp> = {
|
|
19
|
+
id: /#/,
|
|
20
|
+
class: /\./,
|
|
21
|
+
attr: /[a-zA-Z-_]/,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
#handlers = Object.entries(this.#selectors) as [Attrs, RegExp][];
|
|
25
|
+
#state: Record<string, string[]> = {};
|
|
26
|
+
|
|
27
|
+
parse(target: string): Record<string, string[]> {
|
|
28
|
+
/* escape from {} */
|
|
29
|
+
const content = this.extract(target);
|
|
30
|
+
|
|
31
|
+
if (!content) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const char of content) {
|
|
36
|
+
this.next(char);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* end-of-content mark */
|
|
40
|
+
this.next(this.SEPARATOR);
|
|
41
|
+
|
|
42
|
+
this.clear();
|
|
43
|
+
|
|
44
|
+
return this.#state;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private extract(target: string): string | false {
|
|
48
|
+
if (!target.startsWith('{')) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
let balance = 1;
|
|
52
|
+
|
|
53
|
+
for (let i = 1; i < target.length; i++) {
|
|
54
|
+
const char = target[i];
|
|
55
|
+
|
|
56
|
+
if (char === '}') {
|
|
57
|
+
balance--;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (char === '{') {
|
|
61
|
+
balance++;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (balance === 0) {
|
|
65
|
+
const contentInside = target.slice(1, i).trim();
|
|
66
|
+
|
|
67
|
+
return contentInside;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (balance < 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!this.VALIDATION_CHARS.test(char)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private next(value: string) {
|
|
83
|
+
if (!this.#currentKeyType) {
|
|
84
|
+
this.#currentKeyType = this.type(value);
|
|
85
|
+
|
|
86
|
+
if (this.#currentKeyType === 'attr') {
|
|
87
|
+
this.#pending = value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.isSeparator(value)) {
|
|
94
|
+
if (!this.#pending) {
|
|
95
|
+
/* (name= ) construction */
|
|
96
|
+
if (!this.#isInsideQuotation) {
|
|
97
|
+
this.append(this.#key, ' ');
|
|
98
|
+
this.clear();
|
|
99
|
+
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* single key (.name #id contenteditable) */
|
|
105
|
+
if (!this.#key && this.#pending) {
|
|
106
|
+
this.append();
|
|
107
|
+
this.clear();
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* trying to find close quotation */
|
|
113
|
+
if (this.#isInsideQuotation && !this.#didQuotationClosed) {
|
|
114
|
+
this.#pending += value;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this.#isInsideQuotation && this.#didQuotationClosed) {
|
|
119
|
+
this.append(this.#key, this.#pending);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!this.#isInsideQuotation && !this.#didQuotationClosed) {
|
|
123
|
+
this.append(this.#key, this.#pending);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.clear();
|
|
127
|
+
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.isAllowedChar(value)) {
|
|
132
|
+
this.#pending += value;
|
|
133
|
+
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (this.isQuotation(value)) {
|
|
138
|
+
if (this.#isInsideQuotation) {
|
|
139
|
+
this.#didQuotationClosed = true;
|
|
140
|
+
} else {
|
|
141
|
+
this.#isInsideQuotation = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (this.isDelimiter(value)) {
|
|
146
|
+
/* symbol is not delimiter, adding it to value */
|
|
147
|
+
if (this.#key) {
|
|
148
|
+
this.#pending += value;
|
|
149
|
+
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.#key = this.#pending;
|
|
154
|
+
this.#pending = '';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private type(of: string): Attrs | undefined {
|
|
159
|
+
return this.#handlers.find(([_, regex]) => regex.test(of))?.[0];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private append(key: string | undefined = this.#currentKeyType, value: string = this.#pending) {
|
|
163
|
+
if (!key) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!this.#state[key]) {
|
|
168
|
+
this.#state[key] = [];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.#state[key].push(value);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private clear() {
|
|
175
|
+
this.#key = '';
|
|
176
|
+
this.#pending = '';
|
|
177
|
+
|
|
178
|
+
this.#isInsideQuotation = false;
|
|
179
|
+
this.#didQuotationClosed = false;
|
|
180
|
+
|
|
181
|
+
this.#currentKeyType = undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private isDelimiter(target: string) {
|
|
185
|
+
return target === this.DELIMITER;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private isSeparator(target: string) {
|
|
189
|
+
return target === this.SEPARATOR;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private isQuotation(target: string) {
|
|
193
|
+
return target === this.QUOTATION;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private isAllowedChar(target: string) {
|
|
197
|
+
return this.ALLOWED_CHARS.test(target);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import StateBlock from 'markdown-it/lib/rules_block/state_block';
|
|
2
2
|
import {MarkdownItPluginCb} from '../typings';
|
|
3
3
|
import Token from 'markdown-it/lib/token';
|
|
4
|
-
import {
|
|
4
|
+
import {AttrsParser} from './attrs';
|
|
5
5
|
|
|
6
6
|
const pluginName = 'yfm_table';
|
|
7
7
|
const pipeChar = 0x7c; // |
|
|
@@ -225,7 +225,9 @@ function extractAttributes(state: StateBlock, pos: number): Record<string, strin
|
|
|
225
225
|
const attrsStringStart = state.skipSpaces(pos);
|
|
226
226
|
const attrsString = state.src.slice(attrsStringStart);
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
const attrsParser = new AttrsParser();
|
|
229
|
+
|
|
230
|
+
return attrsParser.parse(attrsString);
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
/**
|
|
@@ -243,7 +245,10 @@ function extractAndApplyClassFromToken(contentToken: Token, tdOpenToken: Token):
|
|
|
243
245
|
if (!allAttrs) {
|
|
244
246
|
return;
|
|
245
247
|
}
|
|
246
|
-
|
|
248
|
+
|
|
249
|
+
const attrs = new AttrsParser().parse(allAttrs[0].trim());
|
|
250
|
+
const attrsClass = attrs?.class?.join(' ');
|
|
251
|
+
|
|
247
252
|
if (attrsClass) {
|
|
248
253
|
tdOpenToken.attrSet('class', attrsClass);
|
|
249
254
|
// remove the class from the token so that it's not propagated to tr or table level
|
|
@@ -399,10 +404,15 @@ const yfmTable: MarkdownItPluginCb = (md) => {
|
|
|
399
404
|
const tableStart = state.tokens.length;
|
|
400
405
|
token = state.push('yfm_table_open', 'table', 1);
|
|
401
406
|
|
|
402
|
-
|
|
407
|
+
const {attr: singleKeyAttrs = [], ...fullAttrs} = attrs;
|
|
408
|
+
for (const [property, values] of Object.entries(fullAttrs)) {
|
|
403
409
|
token.attrJoin(property, values.join(' '));
|
|
404
410
|
}
|
|
405
411
|
|
|
412
|
+
for (const attr of singleKeyAttrs) {
|
|
413
|
+
token.attrJoin(attr, 'true');
|
|
414
|
+
}
|
|
415
|
+
|
|
406
416
|
token.map = [startLine, endOfTable];
|
|
407
417
|
|
|
408
418
|
token = state.push('yfm_tbody_open', 'tbody', 1);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function parseAttrs(inputString: string): Record<string, string[]> | null;
|