Browse Source

富文本增加缩进扩展

tags/6.0.3
tianya 2 years ago
parent
commit
3892d6be5e
6 changed files with 99 additions and 4 deletions
  1. +1
    -1
      src/dede/sys_safetest.php
  2. +1
    -1
      src/include/inc/inc_fun_funAdmin.php
  3. +2
    -2
      src/static/ckeditor/config.js
  4. BIN
      src/static/ckeditor/plugins/textindent/icons/hidpi/textindent.png
  5. BIN
      src/static/ckeditor/plugins/textindent/icons/textindent.png
  6. +95
    -0
      src/static/ckeditor/plugins/textindent/plugin.js

+ 1
- 1
src/dede/sys_safetest.php View File

@@ -28,7 +28,7 @@ foreach ($filelist as $key => $ff) {
$alter = "";
if (count($offFiles) == 0) {
$alter = 'EOT
$alter = '
<div class="alert alert-danger maintable mb-2" style="margin:0 auto;" role="alert">
无法同官方网站文件服务器通信,校验时候无法保证本地文件是否同官方服务器文件是否一致。
</div>';


+ 1
- 1
src/include/inc/inc_fun_funAdmin.php View File

@@ -173,7 +173,7 @@ function SpGetEditor($fname, $fvalue, $nheight = "350", $etype = "Basic", $gtype
} else if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
$addConfig = "";
if (defined("DEDEADMIN")) {
$addConfig = ",{allowedContent:true,filebrowserImageUploadUrl:'./dialog/select_images_post.php',filebrowserUploadUrl:'./dialog/select_media_post.php?ck=1',extraPlugins:'html5video,dedepagebreak,ddfilebrowser'}";
$addConfig = ",{allowedContent:true,filebrowserImageUploadUrl:'./dialog/select_images_post.php',filebrowserUploadUrl:'./dialog/select_media_post.php?ck=1',extraPlugins:'html5video,dedepagebreak,ddfilebrowser,textindent'}";
// $addConfig = ",{filebrowserImageUploadUrl:'./dialog/select_images_post.php'}";
}
$code = <<<EOT


+ 2
- 2
src/static/ckeditor/config.js View File

@@ -11,7 +11,7 @@ CKEDITOR.editorConfig = function (config) {
{ name: 'forms', groups: ['forms'] },
'/',
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi', 'paragraph'] },
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi', 'paragraph','textindent'] },
{ name: 'links', groups: ['links'] },
{ name: 'insert', groups: ['insert'] },
'/',
@@ -20,7 +20,7 @@ CKEDITOR.editorConfig = function (config) {
{ name: 'tools', groups: ['tools'] }
];
config.extraPlugins = 'html5video,dedepagebreak';
config.extraPlugins = 'html5video,dedepagebreak,textindent';
config.removeButtons = 'About,ShowBlocks,Iframe,Flash,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField';


BIN
src/static/ckeditor/plugins/textindent/icons/hidpi/textindent.png View File

Before After
Width: 32  |  Height: 32  |  Size: 917B

BIN
src/static/ckeditor/plugins/textindent/icons/textindent.png View File

Before After
Width: 16  |  Height: 16  |  Size: 600B

+ 95
- 0
src/static/ckeditor/plugins/textindent/plugin.js View File

@@ -0,0 +1,95 @@
CKEDITOR.plugins.add( 'textindent', {
icons: 'textindent',
init: function( editor ) {
var indentation = editor.config.indentation;
var indentationKey = editor.config.indentationKey;
if(typeof(indentation) == 'undefined')
indentation = '2em';
if(typeof(indentationKey) == 'undefined')
indentationKey = 'tab';
editor.ui.addButton( 'textindent', {
label: '缩进',
command: 'ident-paragraph',
toolbar: "textindent"
});
if( indentationKey !== false){
editor.on('key', function(ev) {
if(ev.data.domEvent.$.key.toLowerCase() === indentationKey.toLowerCase().trim() || ev.data.keyCode === indentationKey){
editor.execCommand('ident-paragraph');
ev.cancel();
}
});
}
editor.on( 'selectionChange', function()
{
var style_textindente = new CKEDITOR.style({
element: 'p',
styles: { 'text-indent': indentation },
overrides: [{
element: 'text-indent', attributes: { 'size': '0'}
}]
});
if( style_textindente.checkActive(editor.elementPath(), editor) )
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_ON);
else
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_OFF);
});
editor.addCommand("ident-paragraph", {
allowedContent: 'p{text-indent}',
requiredContent: 'p',
exec: function(evt) {
var range = editor.getSelection().getRanges()[0];
var walker = new CKEDITOR.dom.walker( range ),
node;
var state = editor.getCommand('ident-paragraph').state;
while ( ( node = walker.next() ) ) {
if ( node.type == CKEDITOR.NODE_ELEMENT ) {
if(node.getName() === "p"){
editor.fire('saveSnapshot');
if( state == CKEDITOR.TRISTATE_ON){
node.removeStyle("text-indent");
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_OFF);
}
else{
node.setStyle( "text-indent", indentation );
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_ON);
}
}
}
}
if(node === null){
node = editor.getSelection().getStartElement().getAscendant('p', true);
editor.fire('saveSnapshot');
if( state == CKEDITOR.TRISTATE_ON){
node.removeStyle("text-indent");
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_OFF);
}
else{
node.setStyle( "text-indent", indentation );
editor.getCommand('ident-paragraph').setState(CKEDITOR.TRISTATE_ON);
}
}
}
});
}
});

Loading…
Cancel
Save