我正在製作一個Web應用程序,用戶可以在其中發佈自己的文章,就像medium.com一樣。我的應用程序處於角度,我已將它與Firebase連接起來。現在,我希望用戶應該能夠在他們的帖子中添加圖片。我已經在我的應用程序中實現了中等編輯器,但無法實現其需要jquery的insert-image plugin。 我是angularjs的新手,無法找到解決方案。在angularjs和firebase應用程序中集成medium.js插入圖像插件
0
A
回答
0
var editor = new MediumEditor('.editable', {
toolbar: {
/* These are the default options for the toolbar,
if nothing is passed this is what is used */
allowMultiParagraphSelection: true,
buttons: ['bold', 'italic', 'underline', 'anchor', 'strikethrough', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'quote', 'subscript', 'superscript', 'orderedlist', 'unorderedlist', 'indent', 'outdent', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'image'],
diffLeft: 0,
diffTop: -10,
firstButtonClass: 'medium-editor-button-first',
lastButtonClass: 'medium-editor-button-last',
relativeContainer: null,
standardizeSelectionStart: false,
static: false,
/* options which only apply when static is true */
align: 'center',
sticky: false,
updateOnEmptySelection: false
},
anchor: {
/* These are the default options for anchor form,
if nothing is passed this is what it used */
customClassOption: null,
customClassOptionText: 'Button',
linkValidation: true,
placeholderText: 'Paste or type a link',
targetCheckbox: false,
targetCheckboxText: 'Open in new window'
},
anchorPreview: {
/* These are the default options for anchor preview,
if nothing is passed this is what it used */
hideDelay: 500,
previewValueSelector: 'a',
color: "black"
},
autoLink: true,
});
$(function() {
$('.editable').mediumInsert({
editor: editor,
addons: { // (object) Addons configuration
images: { // (object) Image addon configuration
label: '<span class="fa fa-camera"></span>', // (string) A label for an image addon
uploadScript: null, // DEPRECATED: Use fileUploadOptions instead
deleteScript: 'delete.php', // (string) A relative path to a delete script
deleteMethod: 'POST',
fileDeleteOptions: {}, // (object) extra parameters send on the delete ajax request, see http://api.jquery.com/jquery.ajax/
preview: true, // (boolean) Show an image before it is uploaded (only in browsers that support this feature)
captions: true, // (boolean) Enable captions
captionPlaceholder: 'Type caption for image (optional)', // (string) Caption placeholder
autoGrid: 3, // (integer) Min number of images that automatically form a grid
formData: {}, // DEPRECATED: Use fileUploadOptions instead
fileUploadOptions: { // (object) File upload configuration. See https://github.com/blueimp/jQuery-File-Upload/wiki/Options
url: 'upload.php', // (string) A relative path to an upload script
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i // (regexp) Regexp of accepted file types
},
styles: { // (object) Available image styles configuration
wide: { // (object) Image style configuration. Key is used as a class name added to an image, when the style is selected (.medium-insert-images-wide)
label: '<span class="fa fa-align-justify"></span>', // (string) A label for a style
added: function($el) {}, // (function) Callback function called after the style was selected. A parameter $el is a current active paragraph (.medium-insert-active)
removed: function($el) {} // (function) Callback function called after a different style was selected and this one was removed. A parameter $el is a current active paragraph (.medium-insert-active)
},
left: {
label: '<span class="fa fa-align-left"></span>'
},
right: {
label: '<span class="fa fa-align-right"></span>'
},
grid: {
label: '<span class="fa fa-th"></span>'
}
},
actions: { // (object) Actions for an optional second toolbar
remove: { // (object) Remove action configuration
label: '<span class="fa fa-times"></span>', // (string) Label for an action
clicked: function($el) { // (function) Callback function called when an action is selected
var $event = $.Event('keydown');
$event.which = 8;
$(document).trigger($event);
}
}
},
messages: {
acceptFileTypesError: 'This file is not in a supported format: ',
maxFileSizeError: 'This file is too big: '
},
uploadCompleted: function($el, data) {}, // (function) Callback function called when upload is completed
uploadFailed: function(uploadErrors, data) {
alert('There is a problem in uploading the image');
console.log(uploadErrors);
console.log(data);
} // (function) Callback function called when upload failed
}
}
});
});
這是控制器代碼。
<textarea class="editable" ng-model="full"></textarea>
這是HTML。
0
默認情況下,MediumEditor支持將圖像直接拖放到編輯器中。我不確定這是否是您正在尋找的功能,但它應該允許用戶至少以這種方式拖動圖像。
相關問題
- 1. Angularjs與jQuery插件集成
- 2. 如何在PhoneGap應用程序中集成/使用`WKWebView`插件
- 3. Firebase和應用程序indexeddb鏡像集成不起作用
- 4. 如何同時在Android應用程序中插入圖像和按鈕?
- 5. 集成一個圖像畫廊插件與圖像放大功能插件
- 6. Facebook,Twitter與PhoneGap應用程序集成,無需使用插件
- 7. 像fb應用程序url的插件
- 8. 插件和應用程序插件在扭曲的區別?
- 9. 從C#應用程序中插入和檢索Access 2007 DB中的圖像
- 10. 在AngularJS指令中集成jQuery插件調用
- 11. 如何將Raque插件與Rails 2.3.5應用程序集成?
- 12. 插入到SD卡後圖像應用程序中不顯示圖像
- 13. 在GtkLabel中插入圖像?
- 14. 在Blobstore中插入圖像?
- 15. 在vba中插入圖像
- 16. 如何插入圖像插入在Java
- 17. 在Windows 8通用應用程序中集成Cordova插件IBM MobileFirst
- 18. 將徽標圖像插入到應用程序
- 19. MFC應用程序的地圖插件
- 20. 在ASP文件中插入圖像
- 21. 在firebase中插入數據
- 22. CRichEditCtrl和插入圖像(JPG)
- 23. WP:acf圖像字段和簡單的燈箱插件集成
- 24. 插入圖像
- 25. 服務應用程序和com插件
- 26. 插入圖片圖像在iPhone應用程序聯繫人頁面ABUnknownPersonViewController視圖
- 27. 應用程序插件
- 28. AngularJS應用程序模板中的JS插件不工作
- 29. 如何鏈接通過dlopen插入應用程序的插件()
- 30. 如何在基於Web的Python應用程序中插入圖像?