You are here

ueditor.module in UEditor - 百度编辑器 8

Same filename and directory in other branches
  1. 7.3 ueditor.module
  2. 7 ueditor.module
  3. 7.2 ueditor.module

Provides integration with the UEditor WYSIWYG editor.

File

ueditor.module
View source
<?php

/**
 * @file
 * Provides integration with the UEditor WYSIWYG editor.
 */
use Drupal\editor\Entity\Editor;
use Drupal\Core\Site\Settings;

/**
 * Implements hook_page_attachments().
 */
function ueditor_page_attachments(array &$attachments) {
  $config = \Drupal::config('ueditor.settings')
    ->get('ueditor_global_settings');
  if ($config['ueditor_highlighting_format']) {
    $attachments['#attached']['library'][] = 'ueditor/ueditor.highlighting';
  }
}

/**
 * Change %path to realpath.
 */
function _ueditor_realpath($path, $auto = FALSE) {
  $site_path = \Drupal::service('site.path');
  $lib_path = drupal_get_path('module', 'ueditor') . '/lib';
  $mod_path = drupal_get_path('module', 'ueditor');
  $path = strtr($path, array(
    '%b' => base_path(),
    '%m' => $mod_path,
    '%l' => $lib_path,
    '%f' => Settings::get('file_public_path', $site_path . '/files'),
    '%d' => strtr(DRUPAL_ROOT, '\\', '/'),
    '%u' => \Drupal::currentUser()
      ->id(),
  ));
  $path = strtr($path, '\\', '/');
  if ($auto) {
    $path .= '/';
  }
  $path = str_replace('//', '/', $path);
  return $path;
}

/**  
 * ueditor get the save path.
 */
function ueditor_get_savepath($path) {
  global $base_root;
  $site_path = \Drupal::service('site.path');
  $basePath = base_path();
  $filedir = Settings::get('file_public_path', $site_path . '/files');
  if ($path) {
    $savePath = str_replace($basePath . $filedir . '/', "", $path);
    $savePath = str_replace($base_root, "", $savePath);
  }
  return $savePath;
}

Functions

Namesort descending Description
ueditor_get_savepath ueditor get the save path.
ueditor_page_attachments Implements hook_page_attachments().
_ueditor_realpath Change %path to realpath.