Skip to content

Commit

Permalink
newsedit: Add table, indent and noembed plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed Jan 8, 2023
1 parent f12156a commit 1a94d4d
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 11 deletions.
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
public/style/bs/**
public/style/bsext/**
public/style/jquery/**
public/style/trumbowyg/**
public/style/leaflet/**

# Exclude fonts
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions public/js/lib/trumbowyg/plugins/table/trumbowyg.table.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 31 additions & 11 deletions public/js/module/admin/newsEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,39 @@
define([
'underscore', 'jquery', 'Browser', 'Utils', 'socket!', 'Params', 'knockout', 'knockout.mapping', 'm/_moduleCliche',
'globalVM', 'model/User', 'model/storage', 'noties', 'text!tpl/admin/newsEdit.pug', 'css!style/admin/newsEdit',
'trumbowyg', 'css!style/trumbowyg/trumbowyg.css', 'bs/ext/datetimepicker/datetimepicker',
'trumbowyg', 'css!style/trumbowyg/trumbowyg.css', 'css!style/trumbowyg/trumbowyg.table.css', 'bs/ext/datetimepicker/datetimepicker',
], function (_, $, Browser, Utils, socket, P, ko, koMapping, Cliche, globalVM, User, storage, noties, pug) {
'use strict';

const trumbowygOptions = {
lang: P.settings.lang,
imageWidthModalEdit: true,
svgPath: '/img/trumbowyg/icons.svg',
/*buttons: [
'html', 'formatting', 'bold', 'italic', 'underline', 'deleted', 'unorderedlist', 'orderedlist',
'outdent', 'indent', 'image', 'video', 'file', 'table', 'link', 'alignment', '|',
'horizontalrule',
],*/
btns: [
['viewHTML'],
['undo', 'redo'], // Only supported in Blink browsers
['formatting'],
['strong', 'em', 'del'],
['superscript', 'subscript'],
['link'],
['insertImage'],
['noembed'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['unorderedList', 'orderedList'],
['indent', 'outdent'],
['table'],
['horizontalRule'],
['removeformat'],
['fullscreen'],
],
};

const trumbowygAddons = [
'trumbowyg-plugins/indent/trumbowyg.indent.min',
'trumbowyg-plugins/table/trumbowyg.table.min',
'trumbowyg-plugins/noembed/trumbowyg.noembed.min',
];

return Cliche.extend({
pug: pug,
options: {},
Expand All @@ -42,12 +60,13 @@ define([


if (trumbowygOptions.lang !== 'en') {
require([`trumbowyg-langs/${trumbowygOptions.lang}.min`], () => {
this.$dom.find('textarea#newsPrimary').trumbowyg(trumbowygOptions);
});
} else {
this.$dom.find('textarea#newsPrimary').trumbowyg(trumbowygOptions);
trumbowygAddons.push(`trumbowyg-langs/${trumbowygOptions.lang}.min`);
}

require(trumbowygAddons, () => {
this.$dom.find('textarea#newsPrimary').trumbowyg(trumbowygOptions);
});

this.$dom.find('#newsPdate').datetimepicker({ defaultDate: new Date(), collapse: false });

this.subscriptions.route = globalVM.router.routeChanged.subscribe(this.routeHandler, this);
Expand Down Expand Up @@ -89,6 +108,7 @@ define([
//TODO: проверить флоу с переходом на другие новости
resetData: function () {
this.$dom.find('textarea#newsPrimary').trumbowyg('empty');

const pickerP = this.$dom.find('#newsPdate').data('DateTimePicker');

pickerP.date(new Date());
Expand Down
38 changes: 38 additions & 0 deletions public/style/trumbowyg/trumbowyg.table.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Trumbowyg v2.26.0 - A lightweight WYSIWYG editor
* Trumbowyg plugin stylesheet
* ------------------------
* @link http://alex-d.github.io/Trumbowyg
* @license MIT
* @author Alexandre Demode (Alex-D)
* Twitter : @AlexandreDemode
* Website : alex-d.fr
*/

.trumbowyg-editor table {
width: 100%; }
.trumbowyg-editor table td {
border: 1px dotted #e7eaec;
padding: 8px; }

.trumbowyg-dropdown-table table {
margin: 10px;
display: inline-block; }

.trumbowyg-dropdown-table table td {
display: inline-block;
height: 20px;
width: 20px;
margin: 1px;
padding: 0;
background-color: #fff;
-webkit-box-shadow: 0 0 0 1px #cecece inset;
box-shadow: 0 0 0 1px #cecece inset; }
.trumbowyg-dropdown-table table td.active {
background-color: #00b393;
-webkit-box-shadow: none;
box-shadow: none;
cursor: pointer; }

.trumbowyg-dropdown-table .trumbowyg-table-size {
text-align: center; }

0 comments on commit 1a94d4d

Please sign in to comment.