Инструменты пользователя

Инструменты сайта


software:development:web:docs:web:wysiwyg:sceditor_plugins_dragdrop

Плагин DragDrop


Добавляет поддержку перетаскивания файлов в SCEditor. Пример использования для загрузки изображений на imgur доступен здесь.

Инициализация


Чтобы включить плагин для работы с обычным текстом, добавьте dragdrop в plugins параметры и укажите параметры перетаскивания. Например:

script.js
<script>
sceditor.create(textarea, {
	plugins: 'dragdrop',
    style: 'minified/themes/content/default.min.css',
    dragdrop: {
        allowedTypes: ...,
        handleFile: function (file, createPlaceholder) {
            ...
        }
    }
});
</script>


Параметры


Плагин поддерживает следующие параметры:

script.js
dragdrop: {
    // Array of allowed mime types or null to allow all
    allowedTypes: ['image/jpeg', 'image/png'],
    // Function to return if a file is allowed or not,
    // defaults to always returning true
    isAllowed: function(file) {
        return true;
    },
    // If to extract pasted files like images pasted as
    // base64 encoded URI's. Defaults to true
    handlePaste: true,
    // Method that handles the files / uploading etc.
    handleFile: function (file, createPlaceholder) {
        // createPlaceholder function will insert a
        // loading placeholder into the editor and
        // return an object with inert(html) and
        // cancel() methods
 
        // For example:
        var placeholder = createPlaceholder();
 
        asyncUpload(file).then(function (url) {
            // Replace the placeholder with the image HTML
            placeholder.insert('<img src=\'' + url + '\' />');
        }).catch(function () {
            // Error so remove the placeholder
            placeholder.cancel();
        });
    }
}

Дополнения и Файлы

Только авторизованные участники могут оставлять комментарии.
software/development/web/docs/web/wysiwyg/sceditor_plugins_dragdrop.txt · Последнее изменение: VladPolskiy

Если не указано иное, содержимое этой вики предоставляется на условиях следующей лицензии: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki