Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions docs/restraml-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const _BRAND_GRADIENTS = [
* "7.15.3" -> {major:7, minor:15, patch:3, pre:"", preNum:Infinity}
*/
function parseVersion(str) {
const m = str.match(/^(\d+)\.(\d+)(?:\.(\d+))?(beta|rc)?(\d+)?$/)
const m = str.match(/^(\d+)\.(\d+)(?:\.(\d+))?(?:(beta|rc)(\d+))?$/)
if (!m) return null
return {
major: parseInt(m[1], 10),
Expand Down Expand Up @@ -208,9 +208,7 @@ function initThemeSwitcher(id) {
const el = document.getElementById(id)
let state = 'auto'

document.addEventListener('DOMContentLoaded', () => {
el.innerHTML = _THEME_ICONS.osDefault
})
el.innerHTML = _THEME_ICONS.osDefault

el.addEventListener('click', e => {
e.preventDefault()
Expand Down Expand Up @@ -422,6 +420,16 @@ function renderChangelogContent(rawText, targetVersion, query, contentEl, itemCo
* @param {string} [opts.diffPage] - Relative URL of the diff page (default: 'diff.html')
* @returns {{ showChangelog: function(version: string): void }}
*/
const _clHeaderRegexCache = new Map()
function _clGetHeaderRegex(version) {
let re = _clHeaderRegexCache.get(version)
if (!re) {
re = new RegExp(`What's new in ${_clEscapeRegex(version)} \\(([^)]+)\\)`, 'i')
_clHeaderRegexCache.set(version, re)
}
return re
}

function initChangelogModal(opts) {
const modal = document.getElementById('changelog-modal')
if (!modal) return { showChangelog: () => {} }
Expand Down Expand Up @@ -498,7 +506,7 @@ function initChangelogModal(opts) {
_rawText = text

// Extract release date for the subtitle
const headerMatch = text.match(new RegExp(`What's new in ${_clEscapeRegex(version)} \\(([^)]+)\\)`, 'i'))
const headerMatch = text.match(_clGetHeaderRegex(version))
if (headerMatch) subtitleEl.textContent = headerMatch[1]

renderChangelogContent(text, version, '', contentEl, itemCountEl)
Expand Down
12 changes: 7 additions & 5 deletions docs/tikapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ <h1><code>/app</code> <mark>YAML Editor</mark>

<div class="toolbar-group">
<button id="load-example-btn" type="button" class="outline secondary toolbar-btn" disabled title="Browse built-in MikroTik /app examples">
<img class="mt-symbol" src="https://mikrotik.com/logo/library/logo/SVG/MT_Symbol_Black.svg" alt="MikroTik">
<img class="mt-symbol" src="https://mikrotik.com/logo/library/logo/SVG/MT_Symbol_Black.svg" alt="">
Examples</button>
<button id="recall-stash-btn" type="button" class="outline secondary toolbar-btn" disabled>
Recall Stash</button>
Expand Down Expand Up @@ -359,14 +359,14 @@ <h3>No schema versions found</h3>
<button id="copy-btn" type="button" class="outline secondary" title="Copy YAML to clipboard" disabled>📋 Copy</button>
<button id="copy-cmd-btn" type="button" class="outline secondary"
title="Copy as RouterOS /app add command" disabled>
<img class="mt-symbol" src="https://mikrotik.com/logo/library/logo/SVG/MT_Symbol_Black.svg" alt="MikroTik">
<img class="mt-symbol" src="https://mikrotik.com/logo/library/logo/SVG/MT_Symbol_Black.svg" alt="">
Copy /app/add
</button>
<button id="share-btn" type="button" class="outline secondary" title="Copy shareable URL to clipboard" disabled>🔗 Share</button>
<span style="flex:1"></span>
<small style="color:var(--pico-muted-color);font-size:0.72rem;align-self:center">
<small>
From <a href="https://tikoci.github.io">TIKOCI</a>. Not affiliated with <a href="https://mikrotik.com">MikroTik</a>. <kbd>v1b</kbd></small>
From <a href="https://tikoci.github.io">TIKOCI</a>. Not affiliated with <a href="https://mikrotik.com">MikroTik</a>. <kbd>v1.0-beta</kbd></small>
</small>
</div>

Expand Down Expand Up @@ -718,10 +718,12 @@ <h3>No schema versions found</h3>
}
}

const INDENT_SIZE = 2

function toSnippetScaffold(text) {
if (!text) return `\${1}`
if (text.includes('""')) return text.replace('""', `\${1}`)
return `${text}\n${' '.repeat(2)}$0`
return `${text}\n${' '.repeat(INDENT_SIZE)}$0`
}

function buildDynamicKeySuggestions(root, merged, pathKeys, indent, range) {
Expand All @@ -731,7 +733,7 @@ <h3>No schema versions found</h3>

if (merged?.patternProperties && Object.keys(merged.patternProperties).length > 0) {
const firstSchema = resolveRef(root, Object.values(merged.patternProperties)[0])
const inner = firstSchema ? scaffoldObject(root, firstSchema, indent + 2) : ''
const inner = firstSchema ? scaffoldObject(root, firstSchema, indent + INDENT_SIZE) : ''
suggestions.push({
label: { label: placeholder, description: 'named entry' },
kind: monaco.languages.CompletionItemKind.Snippet,
Expand Down
2 changes: 1 addition & 1 deletion validate-workflows.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function shouldSuppressRunnerLabelError(err) {
// Match the label surrounded by quotes to avoid false positives from prefix
// matches (e.g. allowed "ubuntu-24.04-arm" must not suppress an error about
// the unknown label "ubuntu-24.04-arm64").
const escapedLabel = label.replace(/[.*+?^${}()|[\\\]]/g, "\\$&");
const escapedLabel = label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const quotedLabelPattern = new RegExp(`"${escapedLabel}"`, "i");
if (quotedLabelPattern.test(message)) {
return true;
Expand Down
Loading