From 2e7b7c1bb5c83538d4ed18c2e81e99eec08fe6da Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 18 Nov 2022 13:06:22 +0800 Subject: [PATCH] Make warning message on reader match library --- .../Views/WebReader/WebReaderContainer.swift | 5 ++-- .../Sources/ShareExtension/ShareExtension.js | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 74f1238e6..a7848a50d 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -257,8 +257,9 @@ struct WebReaderContainerView: View { .frame(height: readerViewNavBarHeight * navBarVisibilityRatio) .opacity(navBarVisibilityRatio) .background(Color.systemBackground) - .alert("Are you sure?", isPresented: $showDeleteConfirmation) { - Button("Remove Link", role: .destructive) { + .alert("Are you sure you want to remove this item? All associated notes and highlights will be deleted.", + isPresented: $showDeleteConfirmation) { + Button("Remove Item", role: .destructive) { Snackbar.show(message: "Link removed") dataService.removeLink(objectID: item.objectID) #if os(iOS) diff --git a/apple/Sources/ShareExtension/ShareExtension.js b/apple/Sources/ShareExtension/ShareExtension.js index 7474b0ba7..22e7ddda5 100644 --- a/apple/Sources/ShareExtension/ShareExtension.js +++ b/apple/Sources/ShareExtension/ShareExtension.js @@ -11,13 +11,34 @@ function iconURL() { } ShareExtension.prototype = { + getHighlightHTML: function() { + try { + var sel = window.getSelection() + return (function () { + var html = ""; + var sel = window.getSelection(); + if (sel.rangeCount) { + var container = document.createElement("div"); + for (var i = 0, len = sel.rangeCount; i < len; ++i) { + container.appendChild(sel.getRangeAt(i).cloneContents()); + } + html = container.innerHTML; + } + return html; + })() + } catch { + + } + return null + }, run: function(arguments) { arguments.completionFunction({ 'url': window.location.href, 'title': document.title.toString(), 'iconURL': iconURL(), 'contentType': document.contentType, - 'originalHTML': new XMLSerializer().serializeToString(document) + 'originalHTML': new XMLSerializer().serializeToString(document), + 'highlightHTML': this.getHighlightHTML() }); } };