@diplodoc/tabs-extension 3.10.7 → 3.10.8-transform5.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/README.md +12 -0
- package/build/plugin/find.d.ts +3 -2
- package/build/plugin/generate.d.ts +1 -2
- package/build/plugin/index-node.d.ts +1 -1
- package/build/plugin/index-node.js +27 -21
- package/build/plugin/index-node.js.map +3 -3
- package/build/plugin/index.js +27 -21
- package/build/plugin/index.js.map +3 -3
- package/build/plugin/markdown-it.d.ts +5 -0
- package/build/plugin/transform.d.ts +6 -2
- package/build/plugin/types.d.ts +1 -1
- package/build/plugin/utils/tabs.d.ts +1 -1
- package/build/plugin/variants/types.d.ts +1 -2
- package/build/runtime/index.js +1 -1
- package/package.json +6 -3
package/build/plugin/index.js
CHANGED
|
@@ -1136,7 +1136,6 @@ function generateTabsTokens(tabs, state, props2) {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
// src/plugin/find.ts
|
|
1139
|
-
var import_token = __toESM(require("markdown-it/lib/token"));
|
|
1140
1139
|
function findCloseTokenIndex(tokens, idx) {
|
|
1141
1140
|
let level = 0;
|
|
1142
1141
|
let i = idx;
|
|
@@ -1235,14 +1234,14 @@ function tryToFindTabs(tokens, index) {
|
|
|
1235
1234
|
extraTokensAfterClose
|
|
1236
1235
|
};
|
|
1237
1236
|
}
|
|
1238
|
-
function findTabs(tokens, idx, closeTokenIdx) {
|
|
1237
|
+
function findTabs(tokens, idx, closeTokenIdx, TokenConstructor) {
|
|
1239
1238
|
const tabs = [];
|
|
1240
1239
|
let i = idx;
|
|
1241
1240
|
let nestedLevel = -1;
|
|
1242
1241
|
let pending = {
|
|
1243
1242
|
name: "",
|
|
1244
1243
|
tokens: [],
|
|
1245
|
-
listItem: new
|
|
1244
|
+
listItem: new TokenConstructor("list_item_open", "", 0)
|
|
1246
1245
|
};
|
|
1247
1246
|
while (i < tokens.length) {
|
|
1248
1247
|
const token = tokens[i];
|
|
@@ -1305,21 +1304,22 @@ var defaultFeatures = {
|
|
|
1305
1304
|
}
|
|
1306
1305
|
};
|
|
1307
1306
|
var runsCounter = 0;
|
|
1308
|
-
function transform({
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1307
|
+
function transform(options = {}) {
|
|
1308
|
+
const {
|
|
1309
|
+
runtimeJsPath = "_assets/tabs-extension.js",
|
|
1310
|
+
runtimeCssPath = "_assets/tabs-extension.css",
|
|
1311
|
+
containerClasses = "",
|
|
1312
|
+
bundle = true,
|
|
1313
|
+
features = defaultFeatures,
|
|
1314
|
+
onBundle
|
|
1315
|
+
} = options;
|
|
1316
|
+
return function tabs(md, options2) {
|
|
1317
|
+
const { output = ".", generateID: externalGenerateID } = options2 || {};
|
|
1318
1318
|
const generateID = externalGenerateID != null ? externalGenerateID : (0, import_utils6.createIDGeneratorByStrategy)("random");
|
|
1319
1319
|
const plugin = (state) => {
|
|
1320
|
-
const {
|
|
1320
|
+
const { tokens } = state;
|
|
1321
|
+
const env = addHiddenProperty(state.env, "bundled", /* @__PURE__ */ new Set());
|
|
1321
1322
|
const runId = String(++runsCounter);
|
|
1322
|
-
addHiddenProperty(env, "bundled", /* @__PURE__ */ new Set());
|
|
1323
1323
|
let i = 0;
|
|
1324
1324
|
let tabsAreInserted = false;
|
|
1325
1325
|
while (i < tokens.length) {
|
|
@@ -1333,7 +1333,7 @@ function transform({
|
|
|
1333
1333
|
if (!features.enabledVariants[parsedProps.variant]) {
|
|
1334
1334
|
parsedProps.variant = "regular" /* Regular */;
|
|
1335
1335
|
}
|
|
1336
|
-
const tabs2 = findTabs(state.tokens, i + 3, closeTokenIndex);
|
|
1336
|
+
const tabs2 = findTabs(state.tokens, i + 3, closeTokenIndex, state.Token);
|
|
1337
1337
|
if (tabs2.length > 0) {
|
|
1338
1338
|
const tabsTokens = generateTabsTokens(tabs2, state, {
|
|
1339
1339
|
containerClasses,
|
|
@@ -1354,11 +1354,17 @@ function transform({
|
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
1356
|
if (tabsAreInserted) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1357
|
+
const meta = env.meta || (env.meta = {});
|
|
1358
|
+
if (typeof meta !== "object" || meta === null) {
|
|
1359
|
+
throw new TypeError("Expected env.meta to be an object.");
|
|
1360
|
+
}
|
|
1361
|
+
if (!("script" in meta) || !meta.script) Object.assign(meta, { script: [] });
|
|
1362
|
+
if (!("style" in meta) || !meta.style) Object.assign(meta, { style: [] });
|
|
1363
|
+
if (!("script" in meta) || !Array.isArray(meta.script) || !("style" in meta) || !Array.isArray(meta.style)) {
|
|
1364
|
+
throw new TypeError("Expected runtime script and style arrays.");
|
|
1365
|
+
}
|
|
1366
|
+
meta.script.push(runtimeJsPath);
|
|
1367
|
+
meta.style.push(runtimeCssPath);
|
|
1362
1368
|
if (bundle && onBundle) {
|
|
1363
1369
|
onBundle({ runtimeJsPath, runtimeCssPath, output }, env.bundled);
|
|
1364
1370
|
}
|