beta/code-blocks (#1)

Reviewed-on: #1
Co-authored-by: obvTiger <obvtiger@epilogue.team>
Co-committed-by: obvTiger <obvtiger@epilogue.team>
This commit is contained in:
obvTiger 2025-04-01 15:22:15 +02:00 committed by obvtiger
parent 362b7aa15e
commit d125640fe7
26 changed files with 1816 additions and 102 deletions

View file

@ -52,8 +52,23 @@ const safeStringify = (obj) => {
}
};
/**
* Generates a random ID string suitable for use as an HTML element ID.
* @param {number} [length=8] - The length of the random ID
* @returns {string} - A random alphanumeric ID with bp_ prefix
*/
const generateRandomId = (length = 8) => {
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
let result = 'bp_';
for (let i = 0; i < length; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length));
}
return result;
};
module.exports = {
escapeHTML,
toKebabCase,
safeStringify
safeStringify,
generateRandomId
};