-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show images in documentation #10205
Show images in documentation #10205
Conversation
…ormatting-toolbar
ExtendedMenu. - DropdownMenu: Encapsulates the dropdown pattern, i.e. a toggle button that opens a floating pane. - MenuButton: A low-level control that adds button behavior to any element; all other buttons are now implemented using it.
- Recognize markdown image syntax; render images in editor - Images with local paths are fetched from the project directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong objections from my side.
if (url.includes('//')) { | ||
// Not a relative URL, custom fetching not needed. | ||
return undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, inside paths, double /
is treated as single /
, at least on Linuxes. Maybe check for :
presence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll use the URL
API.
} else { | ||
// Relative to current module. | ||
const segments = url.split('/') | ||
if (segments[0] === '..') { | ||
return Ok({ rootId, segments: segments.slice(1) }) | ||
} else { | ||
return Ok({ rootId, segments: ['src', ...segments] }) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We assume we're in src
module. Let's put the current module's path somewhere (graph store?) so once we implement opening modules, this part will continue working.
get: () => props.node.documentation ?? '', | ||
set: (value) => (astDocumentation.value = value), | ||
}) | ||
// This returns the same value as `astDocumentation.state`, but with fewer reactive dependencies. | ||
const documentation = computed(() => props.node.documentation ?? '') | ||
|
||
syncRef(editing, useFocusDelayed(textEditor).focused) | ||
</script> | ||
<template> | ||
<div v-if="editing || props.node.documentation?.trimStart()" class="GraphNodeComment"> | ||
<PlainTextEditor | ||
ref="textEditor" | ||
v-model="documentation" | ||
:modelValue="documentation" | ||
@update:modelValue="astDocumentation.set" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a matter of taste, but I preferred the old solution here. Or maybe it has some drawbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It relied on a side effect in a computed setter; Paweł suggested replacing that pattern with a state getter and updating separately.
Pull Request Description
Render markdown image syntax in documentation. Relative URLs are fetched from the project directory; absolute URLs are hotlinked from wherever they point.
Syntax and URL resolution:
doc-images.mov
Closes #10058.
Important Notes
Stacked on #10064.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.