Skip to content

Commit

Permalink
Add a status bar
Browse files Browse the repository at this point in the history
It shows information to links and images while the mouse pointer is over them.
  • Loading branch information
c3er committed May 21, 2018
1 parent 926f337 commit 6d08a24
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ You can use and copy this tool under the conditions of the MIT license.

External resources that are loaded from the Internet shall be blocked

A status bar showing the link destination of the link that is currently hovered by the mouse pointer

A context menu:

- Copy currently selected text
Expand Down
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,32 @@
.markdown-body ol ol ol {
list-style-type: decimal;
}

#status-bar {
background-color: #ddd;
color: black;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 25px;
}

#status-text {
font-family: Sans-serif;
font-size: 10pt;
line-height: 0;
vertical-align: middle;
padding-left: 10px;
}

body {
margin-bottom: 25px;
}
</style>
</head>
<body>
<div class="markdown-body" id="content"></div>
<div id="status-bar"><p id="status-text"></p></div>
</body>
</html>
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function alterTags(tagName, handler) {
}
}

function setStatusBar(element, text) {
const statusTextElement = document.getElementById("status-text")
element.addEventListener("mouseover", () => statusTextElement.innerHTML = text)
element.addEventListener("mouseout", () => statusTextElement.innerHTML = "")
}

const markdown = require("markdown-it")({
highlight: (text, language) => {
// Originated from VS Code
Expand Down Expand Up @@ -56,12 +62,14 @@ ipcRenderer.on("fileOpen", (event, filePath, isMarkdownFile) => {
}
event.preventDefault()
})
setStatusBar(link, target)
})
alterTags("img", image => {
const imageUrl = image.getAttribute("src")
if (!isInternetUrl(imageUrl)) {
image.src = path.join(documentDirectory, imageUrl)
}
setStatusBar(image, `${image.getAttribute("alt")} (${imageUrl})`)
})

document.title = `${filePath} - ${TITLE}`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mdview",
"version": "0.9.1",
"version": "0.9.2",
"description": "Standalone Markdown viewer",
"keywords": [
"markdown",
Expand Down

0 comments on commit 6d08a24

Please sign in to comment.