Merge pull request #4161 from zyhfish/task/fix-issue-4158
Fix #4158: insert image into correct position.
This commit is contained in:
		| @ -122,6 +122,7 @@ | ||||
|  | ||||
|     private string _message = string.Empty; | ||||
|     private bool _contentchanged = false; | ||||
|     private int _editorIndex; | ||||
|  | ||||
|     [Parameter] | ||||
|     public string Content { get; set; } | ||||
| @ -275,18 +276,18 @@ | ||||
|                 // return original raw html content | ||||
|                 return _originalrawhtml; | ||||
|             } | ||||
|  		} | ||||
| 	} | ||||
|         } | ||||
|     } | ||||
|  | ||||
| 	public async Task InsertRichImage() | ||||
| 	{ | ||||
| 		_message = string.Empty; | ||||
| 		if (_richfilemanager) | ||||
| 		{ | ||||
| 			var file = _fileManager.GetFile(); | ||||
|     public async Task InsertRichImage() | ||||
|     { | ||||
|         _message = string.Empty; | ||||
|         if (_richfilemanager) | ||||
|         {             | ||||
|             var file = _fileManager.GetFile(); | ||||
| 			if (file != null) | ||||
| 			{ | ||||
| 				await interop.InsertImage(_editorElement, file.Url, ((!string.IsNullOrEmpty(file.Description)) ? file.Description : file.Name)); | ||||
|                 await interop.InsertImage(_editorElement, file.Url, ((!string.IsNullOrEmpty(file.Description)) ? file.Description : file.Name), _editorIndex); | ||||
|                 _richhtml = await interop.GetHtml(_editorElement); | ||||
|                 _richfilemanager = false; | ||||
| 			} | ||||
| @ -297,6 +298,7 @@ | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|             _editorIndex = await interop.GetCurrentCursor(_editorElement); | ||||
| 			_richfilemanager = true; | ||||
| 		} | ||||
| 		StateHasChanged(); | ||||
|  | ||||
| @ -105,13 +105,25 @@ namespace Oqtane.Modules.Controls | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public Task InsertImage(ElementReference quillElement, string imageUrl, string altText) | ||||
|         public ValueTask<int> GetCurrentCursor(ElementReference quillElement) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 return _jsRuntime.InvokeAsync<int>("Oqtane.RichTextEditor.getCurrentCursor", quillElement); | ||||
|             } | ||||
|             catch | ||||
|             { | ||||
|                 return new ValueTask<int>(Task.FromResult(0)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public Task InsertImage(ElementReference quillElement, string imageUrl, string altText, int editorIndex) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _jsRuntime.InvokeAsync<object>( | ||||
|                     "Oqtane.RichTextEditor.insertQuillImage", | ||||
|                     quillElement, imageUrl, altText); | ||||
|                     quillElement, imageUrl, altText, editorIndex); | ||||
|                 return Task.CompletedTask; | ||||
|             } | ||||
|             catch | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker