Open jordancurve opened 4 years ago
I assume a common scenario you have in mind is copying html content and pasting in plain text into SuperMemo ?
Yes.
Will make it in same plugin as supermemo/SuperMemoAssistant.Plugins.EditorPlusPlus#1 "SuperMemoAssistant.Plugins.EditorPlusPlus" ?
See supermemo/SuperMemoAssistant#37
made a simple attempt at this here: https://github.com/bjsi/SuperMemoAssistant.Plugins.EditorPlusPlus/tree/add-plain-text-paste
Can you describe your implementation ? How does it work ? (from a user perspective mostly, but also tech if there are interesting bits)
Basically open an "advanced paste" window with radio dials. Select plain text paste and hit enter. Get text from user's clipboard, remove all HTML tags with HTMLAgilityPack. Finally replace the currently selected text with the filtered clipboard text. For that I used this snippet I took from one of your plugins.
private void PasteText(string text)
{
IControlHtml ctrlHtml = Svc.SM.UI.ElementWdw.ControlGroup.FocusedControl.AsHtml();
if (ctrlHtml != null)
{
var htmlDoc = ctrlHtml.GetDocument();
var htmlSelObj = htmlDoc?.selection;
if (htmlSelObj?.createRange() is IHTMLTxtRange textSel)
textSel.text = text;
}
}
Sounds good. Will your send a PR ?
Chrome and Office have built-in keyboard shortcuts for pasting plain text. It would be convenient if SuperMemo did as well.