@diplodoc/transform 4.77.11 → 4.77.12
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/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/base.min.css.map +1 -1
- package/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css.map +1 -1
- package/dist/css/yfm.min.css.map +1 -1
- package/lib/plugins/images/index.js +10 -0
- package/lib/plugins/images/index.js.map +1 -1
- package/lib/plugins/imsize/plugin.js +14 -9
- package/lib/plugins/imsize/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/transform/plugins/images/index.ts +13 -0
- package/src/transform/plugins/imsize/plugin.ts +17 -6
|
@@ -155,6 +155,11 @@ function collectDataAttrs(
|
|
|
155
155
|
continue;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
if (key === 'gallery-id' && value !== '') {
|
|
159
|
+
result['data-gallery-id'] = value;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
158
163
|
const gallerySrc = resolveGallerySrcAttr(
|
|
159
164
|
key,
|
|
160
165
|
value,
|
|
@@ -173,6 +178,7 @@ function collectDataAttrs(
|
|
|
173
178
|
if (
|
|
174
179
|
key.startsWith('data-') &&
|
|
175
180
|
key !== 'data-gallery-src' &&
|
|
181
|
+
(key !== 'data-gallery-id' || value !== '') &&
|
|
176
182
|
(key !== 'data-gallery' || isGalleryValid(value))
|
|
177
183
|
) {
|
|
178
184
|
result[key] = value;
|
|
@@ -182,10 +188,17 @@ function collectDataAttrs(
|
|
|
182
188
|
image.attrs = image.attrs.filter(
|
|
183
189
|
([key, value]) =>
|
|
184
190
|
key !== 'gallery' &&
|
|
191
|
+
key !== 'gallery-id' &&
|
|
185
192
|
key !== 'gallery-src' &&
|
|
186
193
|
(key !== 'data-gallery' || isGalleryValid(value)) &&
|
|
194
|
+
(key !== 'data-gallery-id' || value !== '') &&
|
|
187
195
|
(key !== 'data-gallery-src' || value !== ''),
|
|
188
196
|
);
|
|
197
|
+
|
|
198
|
+
if (result['data-gallery-id']) {
|
|
199
|
+
result['data-gallery'] = 'true';
|
|
200
|
+
}
|
|
201
|
+
|
|
189
202
|
return result;
|
|
190
203
|
}
|
|
191
204
|
|
|
@@ -307,19 +307,26 @@ function isOwnAttr(key: string): boolean {
|
|
|
307
307
|
key === 'height' ||
|
|
308
308
|
key === 'inline' ||
|
|
309
309
|
key === 'gallery' ||
|
|
310
|
+
key === 'gallery-id' ||
|
|
310
311
|
key === 'gallery-src' ||
|
|
311
312
|
key.startsWith('data-')
|
|
312
313
|
);
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
function resolveDataAttr(key: string, value: string): [string, string] | null {
|
|
316
|
-
|
|
317
|
+
if (key === 'gallery' || key === 'data-gallery') {
|
|
318
|
+
const isGalleryValid = value === 'true' || value === 'false';
|
|
317
319
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (key
|
|
322
|
-
|
|
320
|
+
return isGalleryValid ? ['data-gallery', value] : null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (key === 'gallery-id' || key === 'gallery-src') {
|
|
324
|
+
if (value === '') return null;
|
|
325
|
+
|
|
326
|
+
return [`data-${key}`, value];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return key.startsWith('data-') ? [key, value] : null;
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
function parseInlineAttributes(attrsStr: string): ParsedAttrs {
|
|
@@ -358,6 +365,10 @@ function parseInlineAttributes(attrsStr: string): ParsedAttrs {
|
|
|
358
365
|
}
|
|
359
366
|
}
|
|
360
367
|
|
|
368
|
+
if (result.dataAttrs?.['data-gallery-id']) {
|
|
369
|
+
result.dataAttrs['data-gallery'] = 'true';
|
|
370
|
+
}
|
|
371
|
+
|
|
361
372
|
// The block is fully ours only if it carries our attributes and nothing
|
|
362
373
|
// foreign is left over — otherwise someone downstream has to parse it.
|
|
363
374
|
result.foreign = own === 0 || ownChars !== dense(attrsStr);
|