Skip to content

Commit

Permalink
Bump marked to ^14.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Nov 9, 2024
1 parent 5480462 commit adce820
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 237 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Changed `source` view to take `source`, `syntax`, `lineNum`, `refs` and `maxSourceSizeToHighlight` options. It attempts to derive these values from `data` when options are not explicitly provided for backward compatibility. The `source` can be derived from `data` as `content` (for backward compatibility) or `source` property
- Removed `mime`, `binary` and `size` data options for `source` view
- Bumped `marked` to `^14.1.4` (used in `markdown` view)
- Added styles for `<kbd>` in `markdown` view
- Improved string rendering in the values popup of `signature` view
- Fixed optional values statistics in `signature` view
Expand Down
50 changes: 42 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@
"dependencies": {
"@discoveryjs/json-ext": "^0.6.3",
"codemirror": "^5.65.2",
"github-slugger": "^2.0.0",
"hitext": "^1.0.0-beta.1",
"jora": "1.0.0-beta.13",
"marked": "^4.3.0"
"marked": "^14.1.4"
},
"devDependencies": {
"@discoveryjs/cli": "^2.11.1",
Expand Down
5 changes: 4 additions & 1 deletion src/main/view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,10 @@ export class ViewModel<
const pageHeaderEl: HTMLElement | null = pageEl.querySelector('.view-page-header'); // TODO: remove, should be abstract

el.style.scrollMargin = pageHeaderEl ? pageHeaderEl.offsetHeight + 'px' : '';
el.scrollIntoView(true);
// FIXME: Broken for some reason. In previous versions (including 1.0.0-beta.89)
// it worked just fine. But now it requires a next tick. Don't know what changed.
// el.scrollIntoView(true);
setTimeout(() => el.scrollIntoView(true), 0);
}
}
});
Expand Down
36 changes: 15 additions & 21 deletions src/views/text/headers.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
/* eslint-env browser */
import { Slugger } from 'marked';
import { slug as generateSlug } from 'github-slugger';
import { createElement } from '../../core/utils/dom.js';
import usage from './headers.usage.js';

export default function(host) {
const slugger = new Slugger;

function render(el, config, data, context) {
async function render(el, config, data, context) {
const { content, anchor = false } = config;

el.classList.add('view-header');

const render = host.view.render(el, content || 'text', data, context);
await host.view.render(el, content || 'text', data, context);

if (anchor) {
render.then(() => {
const slug = slugger.slug(anchor === true ? el.textContent : String(anchor), { dryrun: true });
const href = host.encodePageHash(
host.pageId,
host.pageRef,
{ ...host.pageParams, '!anchor': slug }
);

el.prepend(createElement('a', {
class: 'view-header__anchor',
id: `!anchor:${slug}`,
href
}));
});
const slug = generateSlug(anchor === true ? el.textContent : String(anchor));
const href = host.encodePageHash(
host.pageId,
host.pageRef,
{ ...host.pageParams, '!anchor': slug }
);

el.prepend(createElement('a', {
class: 'view-header__anchor',
id: `!anchor:${slug}`,
href
}));
}

return render;
}

host.view.define('header', render, { tag: 'h4', usage });
Expand Down
5 changes: 4 additions & 1 deletion src/views/text/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@

.view-markdown .check-list-item {
list-style: none;
margin-left: -22px;
}
.view-markdown .check-list-item > .view-checkbox:first-child {
width: 20px;
margin-left: -20px;
}
Loading

0 comments on commit adce820

Please sign in to comment.