makes the height adjustment more clean

(no more sleep(100))
main
Paul Schneider 9 years ago
parent 7350cdb668
commit 12ba223dc4
3 changed files with 40 additions and 39 deletions

@ -126,24 +126,24 @@ WriteLiteral(@">
['clean'] // remove formatting button ['clean'] // remove formatting button
]; ];
var quill = new Quill('#bubble-container', {
modules: { $(document).ready(function () {
toolbar: toolbarOptions var quill = new Quill('#bubble-container', {
}, modules: {
placeholder: 'Composez votre texte ...', toolbar: toolbarOptions
theme: 'snow' },
}); placeholder: 'Composez votre texte ...',
theme: 'snow'
function getMD() { });
return markdownize($('#bubble-container div.ql-editor').html())
} function getMD() {
quill.on('text-change', function (delta, oldDelta, source) return markdownize($('#bubble-container div.ql-editor').html())
{ }
if (source === ""user"") { quill.on('text-change', function (delta, oldDelta, source) {
invokeCSharpAction(getMD()); if (source === ""user"") {
} invokeCSharpAction(getMD());
}); }
$(document).ready(function () { });
// TODO implement a dedicated injection // TODO implement a dedicated injection
invokeCSharpAction(getMD()); invokeCSharpAction(getMD());
}); });

@ -46,24 +46,24 @@
['clean'] // remove formatting button ['clean'] // remove formatting button
]; ];
var quill = new Quill('#bubble-container', {
modules: { $(document).ready(function () {
toolbar: toolbarOptions var quill = new Quill('#bubble-container', {
}, modules: {
placeholder: 'Composez votre texte ...', toolbar: toolbarOptions
theme: 'snow' },
}); placeholder: 'Composez votre texte ...',
theme: 'snow'
});
function getMD() { function getMD() {
return markdownize($('#bubble-container div.ql-editor').html()) return markdownize($('#bubble-container div.ql-editor').html())
} }
quill.on('text-change', function (delta, oldDelta, source) quill.on('text-change', function (delta, oldDelta, source) {
{ if (source === "user") {
if (source === "user") { invokeCSharpAction(getMD());
invokeCSharpAction(getMD()); }
} });
});
$(document).ready(function () {
// TODO implement a dedicated injection // TODO implement a dedicated injection
invokeCSharpAction(getMD()); invokeCSharpAction(getMD());
}); });

@ -29,7 +29,7 @@ namespace BookAStar.Droid
if (hybridWebViewRenderer != null && hybridWebViewRenderer.TryGetTarget(out hybridRenderer)) if (hybridWebViewRenderer != null && hybridWebViewRenderer.TryGetTarget(out hybridRenderer))
{ {
hybridRenderer.Element.Markdown = data; hybridRenderer.Element.Markdown = data;
MarkdownViewRenderer.ProperOnPageFinished(hybridRenderer.Element, MarkdownViewRenderer.AdjustHeightRequest(hybridRenderer.Element,
hybridRenderer.EditorView); hybridRenderer.EditorView);
} }
} }
@ -58,8 +58,10 @@ namespace BookAStar.Droid
/// <param name="view"></param> /// <param name="view"></param>
public static async void AdjustHeightRequest(MarkdownView xview, WebView view) public static async void AdjustHeightRequest(MarkdownView xview, WebView view)
{ {
xview.BatchBegin(); xview.BatchBegin();
xview.HeightRequest = view.ContentHeight; var vch = view.ContentHeight; // FIXME why not 3?
xview.HeightRequest = vch > xview.MinimumHeightRequest ? vch : xview.MinimumHeightRequest;
xview.BatchCommit(); xview.BatchCommit();
} }
@ -69,7 +71,6 @@ namespace BookAStar.Droid
var html = editorTemplate.GenerateString(); var html = editorTemplate.GenerateString();
EditorView.LoadDataWithBaseURL("file:///android_asset/", EditorView.LoadDataWithBaseURL("file:///android_asset/",
html, "text/html", "utf-8", null); html, "text/html", "utf-8", null);
OnPageFinished(Element, editorView);
} }
protected override void OnElementChanged(ElementChangedEventArgs<MarkdownView> e) protected override void OnElementChanged(ElementChangedEventArgs<MarkdownView> e)
@ -78,6 +79,7 @@ namespace BookAStar.Droid
if (Control == null) if (Control == null)
{ {
SetNativeControl(CreateNativeControl()); SetNativeControl(CreateNativeControl());
InjectJS(JavaScriptFunction);
} }
if (e.OldElement != null) if (e.OldElement != null)
{ {
@ -91,7 +93,6 @@ namespace BookAStar.Droid
EditorView.SetWebViewClient(viewclient); EditorView.SetWebViewClient(viewclient);
Control.AddJavascriptInterface(new JsBridgeMarkdown(this), "jsBridge"); Control.AddJavascriptInterface(new JsBridgeMarkdown(this), "jsBridge");
SetMDEditorText(e.NewElement.Markdown); SetMDEditorText(e.NewElement.Markdown);
InjectJS(JavaScriptFunction);
} }
} }

Loading…