Comments (9)
Well I have a solution for this case. You will need to provide a custom clipboard service when adding services in MauiProgram.cs
as it is shown down below:
builder.Services.AddMudMarkdownClipboardService<ClipboardService>();
// Implementation
public class ClipboardService : IMudMarkdownClipboardService
{
public async ValueTask CopyToClipboardAsync(string text)
{
await Clipboard.Default.SetTextAsync(text)
.ConfigureAwait(false);
}
}
I will finalise the MR and make a new NuGet version a bit later today.
from mudblazor.markdown.
Link to sample repository: https://github.com/Jeffcole1/MudblazorMarkdownAndroidTest
Instructions to set up and run Android Emulator:
- In Visual Studio (I'm using Community 2022), ensure that the ".NET Multi-Platform App UI Development" workload is installed.
- With the solution open, select Tools -> Android -> Android Device Manager.
- Check that at least one virtual device is shown in the table. If there are none, click New. If there are any, skip to step 6.
- Give the virtual device a name and select a base device and Android API to use (I used Pixel 5 with Android 9.0 - API 28).
- Click Create to create the virtual device.
- The virtual device should appear in the table. Click the Start button to start the virtual device and ensure it runs properly.
- In Visual Studio, select the virtual device in the device list (next to the Configuration dropdowns), then click the Start button to start debugging. If you did it properly, the app should begin running in the virtual device. It may take a couple of minutes for the app to build and deploy to the virtual device.
from mudblazor.markdown.
It might be related to permissions as it is specified here: Interact with the clipboard. Could you try to run navigator.permissions.query({ name: "clipboard-write" })
directly and see what happens?
Alternatively, it might be a problem with the browser you used on mobile as it is stated here: Copy to clipboard is worked fine on PC but not works on Android device
and the same error occurred
By the way, what was the same error? Was null
just printed in the browser console after you had executed the clipboard command directly?
from mudblazor.markdown.
I'm not using an actual browser. This is a .NET MAUI Blazor app written in Visual Studio and deployed to an Android emulator for testing. I used chrome://inspect#devices to open a dev tools page on the running app in the emulator.
When I click the copy button on the code block, this message appears:
Running the query command gave me a TypeError; polling the navigator.permissions
property returned undefined
, and polling navigator
by itself returned this:
For comparison, here is the message I got when I opened Chrome on the emulator and ran the same command:
from mudblazor.markdown.
I see, so probably more work will be needed - like trying to create a workaround for this issue in the JS section of the code.
Something like
const element = document.createElement("textarea");
element.value = clipboardData;
document.body.appendChild(element)
element.select();
document.execCommand("copy");
document.body.removeChild(element);
But could you provide a sample solution where the error can be reproduced easily. I have neither MAUI nor android emulators installed on my PC, so it will take me some time to analyse this issue, sorry for trouble, but if it is possible could you provide a link to a GitHub repo where this issue can be reproduced?
Maybe some instructions about "deploying it to the Android enulator" would also come in handy
from mudblazor.markdown.
Thanks, I will try to take a look as soon as I can. It will take some time so please understand it 🙇
from mudblazor.markdown.
Thanks, I will try to take a look as soon as I can. It will take some time so please understand it 🙇
Any update on this? I am having the same issue.
from mudblazor.markdown.
@amtdev Sorry, not so much time I can devote to this project lately :(
Maybe this weekend I will have time...
from mudblazor.markdown.
I've been working on this issue today and copying to clibboard in maui does not work as expected (well, it does not work even with document.execCommand('copy')
which works in a browser, e.g. Chrome).
I have come across this issue - dotnet/maui#6846. Does it make sense to you?
I have only found out that it is possible to use the following in MainPage.cs
, but I have no idea how to grant copy permissions in this callback. MAUI documentation (or the afore cited issue) does not provide any details how to do it. In any case I can try to open the same issue and hopefully someone will give an example how to do it.
blazorWebView.BlazorWebViewInitialized += BlazorWebView_BlazorWebViewInitialized;
from mudblazor.markdown.
Related Issues (20)
- Render <details> HOT 2
- tested issue #114, still problems HOT 3
- Style overrides HOT 1
- Line breaks not preserved following code blocks HOT 2
- Table not showing when indented HOT 1
- Table shows if not indented but numbering is restarted HOT 2
- Copy code block to clipboard HOT 2
- After a cascading value changes, MudMarkDown is failing to update the corresponding value. HOT 3
- Please let the padding-bottom be changed by the user HOT 2
- Big images do not fit the page
- Edit HOT 1
- 🐛 Margin-Bottom for Quote wrong HOT 2
- Feature Request: Custom Pipeline HOT 12
- Feature Request: Extensible rendering HOT 8
- After binding value changes, the code block fails to update the corresponding value even if call StateHasChanged HOT 4
- Nested text is not rendered correctly in list items
- new feature: add option to show image alt text below image HOT 1
- Add Src HOT 1
- Issue when code block is empty HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mudblazor.markdown.