generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from chhoumann/md-choice-name
feat: render markdown & HTML in choice names
- Loading branch information
Showing
4 changed files
with
104 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,62 @@ | ||
<script lang="ts"> | ||
import IChoice from "../../types/choices/IChoice"; | ||
import RightButtons from "./ChoiceItemRightButtons.svelte"; | ||
import {createEventDispatcher} from "svelte"; | ||
export let choice: IChoice; | ||
export let dragDisabled: boolean; | ||
let showConfigureButton: boolean = true; | ||
const dispatcher = createEventDispatcher(); | ||
function deleteChoice() { | ||
dispatcher('deleteChoice', {choice}); | ||
} | ||
function configureChoice() { | ||
dispatcher('configureChoice', {choice}); | ||
} | ||
function toggleCommandForChoice() { | ||
dispatcher('toggleCommand', {choice}); | ||
} | ||
function duplicateChoice() { | ||
dispatcher('duplicateChoice', {choice}); | ||
} | ||
import IChoice from "../../types/choices/IChoice"; | ||
import RightButtons from "./ChoiceItemRightButtons.svelte"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { Component, htmlToMarkdown, MarkdownRenderer } from "obsidian"; | ||
export let choice: IChoice; | ||
export let dragDisabled: boolean; | ||
let showConfigureButton: boolean = true; | ||
const dispatcher = createEventDispatcher(); | ||
function deleteChoice() { | ||
dispatcher("deleteChoice", { choice }); | ||
} | ||
function configureChoice() { | ||
dispatcher("configureChoice", { choice }); | ||
} | ||
function toggleCommandForChoice() { | ||
dispatcher("toggleCommand", { choice }); | ||
} | ||
function duplicateChoice() { | ||
dispatcher("duplicateChoice", { choice }); | ||
} | ||
let nameElement: HTMLSpanElement; | ||
$: { | ||
if (nameElement) { | ||
nameElement.innerHTML = ""; | ||
const nameHTML = htmlToMarkdown(choice.name); | ||
MarkdownRenderer.renderMarkdown( | ||
nameHTML, | ||
nameElement, | ||
"/", | ||
null as unknown as Component | ||
); | ||
} | ||
} | ||
</script> | ||
|
||
<div class="choiceListItem"> | ||
<span class="choiceListItemName">{choice.name}</span> | ||
|
||
<RightButtons | ||
on:mousedown | ||
on:touchstart | ||
on:deleteChoice={deleteChoice} | ||
on:configureChoice={configureChoice} | ||
on:toggleCommand={toggleCommandForChoice} | ||
on:duplicateChoice={duplicateChoice} | ||
bind:choiceName={choice.name} | ||
bind:commandEnabled={choice.command} | ||
bind:showConfigureButton | ||
bind:dragDisabled | ||
showDuplicateButton={true} | ||
/> | ||
<span class="choiceListItemName" bind:this={nameElement} /> | ||
|
||
<RightButtons | ||
on:mousedown | ||
on:touchstart | ||
on:deleteChoice={deleteChoice} | ||
on:configureChoice={configureChoice} | ||
on:toggleCommand={toggleCommandForChoice} | ||
on:duplicateChoice={duplicateChoice} | ||
bind:choiceName={choice.name} | ||
bind:commandEnabled={choice.command} | ||
bind:showConfigureButton | ||
bind:dragDisabled | ||
showDuplicateButton={true} | ||
/> | ||
</div> | ||
|
||
<style> | ||
.choiceListItem { | ||
display: flex; | ||
font-size: 16px; | ||
align-items: center; | ||
margin: 12px 0 0 0; | ||
transition: 1000ms ease-in-out; | ||
} | ||
.choiceListItemName { | ||
flex: 1 0 0; | ||
} | ||
</style> | ||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
655e7ae
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.
Successfully deployed to the following URLs:
quickadd – ./
quickadd.obsidian.guide
quickadd-git-master-chrisbbh.vercel.app
quickadd-chrisbbh.vercel.app