From 8f2d3e3bcd2ea71fa7ce4c7a07e62e23b2ca399d Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 8 Apr 2023 20:06:45 +0000 Subject: [PATCH] Show videos in messages. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4253 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/ssb/tf-utils.js | 35 +++++++++++++++++++++++++++++++++++ apps/todo/script.js | 6 +++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/apps/ssb/tf-utils.js b/apps/ssb/tf-utils.js index 74d8a93e..de09a431 100644 --- a/apps/ssb/tf-utils.js +++ b/apps/ssb/tf-utils.js @@ -1,9 +1,44 @@ import * as linkify from './commonmark-linkify.js'; import * as hashtagify from './commonmark-hashtag.js'; + +function image(node, entering) { + if (node.firstChild?.type === 'text' && + node.firstChild.literal.startsWith('video:')) { + if (entering) { + this.lit(''); + } + } else { + if (entering) { + if (this.disableTags === 0) { + if (this.options.safe && potentiallyUnsafe(node.destination)) { + this.lit('');
+				} else {
+					this.lit('<img src='); + } + } + } +} + export function markdown(md) { var reader = new commonmark.Parser({safe: true}); var writer = new commonmark.HtmlRenderer(); + writer.image = image; var parsed = reader.parse(md || ''); parsed = linkify.transform(parsed); parsed = hashtagify.transform(parsed); diff --git a/apps/todo/script.js b/apps/todo/script.js index b8cdf391..00720b51 100644 --- a/apps/todo/script.js +++ b/apps/todo/script.js @@ -114,13 +114,12 @@ class TodoListElement extends LitElement { @change=${event => self.input_change(event, item)} @keydown=${event => self.input_keydown(event, item)} @blur=${x => self.input_blur(item)}> - self.remove_item(item)}>x + self.remove_item(item)} style="cursor: pointer">❎ `; } else { return html`
self.handle_check(x, item)}> self.editing = index}>${item.text} - self.remove_item(item)} style="cursor: pointer">❎
`; } } @@ -175,7 +174,8 @@ class TodoListElement extends LitElement { return html`
${name} - ${(this.items || []).map(x => self.render_item(x))} + ${(this.items || []).filter(item => !item.x).map(x => self.render_item(x))} + ${(this.items || []).filter(item => item.x).map(x => self.render_item(x))}