mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added an CKEditor plugin for easy placeholder selection.
This commit is contained in:
parent
726cab1c5a
commit
a39f816422
7 changed files with 221 additions and 0 deletions
|
@ -21,6 +21,7 @@ fos_ck_editor:
|
|||
height: 100
|
||||
enterMode: 2
|
||||
toolbar: label_toolbar
|
||||
extraPlugins: "partdb_label"
|
||||
|
||||
plugins:
|
||||
bbcode:
|
||||
|
@ -32,6 +33,9 @@ fos_ck_editor:
|
|||
specialchar:
|
||||
path: "ckeditor/plugins/specialchar"
|
||||
filename: "plugin.js"
|
||||
partdb_label:
|
||||
path: "ckeditor/plugins/partdb_label/"
|
||||
filename: "plugin.js"
|
||||
|
||||
|
||||
toolbars:
|
||||
|
@ -44,6 +48,7 @@ fos_ck_editor:
|
|||
- "/"
|
||||
- ['Format', 'FontSize']
|
||||
- ['Table', 'HorizontalRule']
|
||||
- ['Placeholders']
|
||||
description_toolbar:
|
||||
- [ 'Bold', 'Italic', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ]
|
||||
- ["SpecialChar"]
|
||||
|
|
BIN
public/ckeditor/plugins/partdb_label/icons/hidpi/placeholder.png
Normal file
BIN
public/ckeditor/plugins/partdb_label/icons/hidpi/placeholder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
public/ckeditor/plugins/partdb_label/icons/placeholder.png
Normal file
BIN
public/ckeditor/plugins/partdb_label/icons/placeholder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
50
public/ckeditor/plugins/partdb_label/lang/de.js
Normal file
50
public/ckeditor/plugins/partdb_label/lang/de.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.setLang( 'partdb_label', 'de', {
|
||||
title: 'Platzhalter einfügen',
|
||||
label: 'Platzhalter',
|
||||
'section.global': 'Global',
|
||||
'section.part': 'Bauteil',
|
||||
'part.id': 'Datenbank ID',
|
||||
'part.name': 'Bauteilename',
|
||||
'part.category': 'Kategorie',
|
||||
'part.category_full': 'Kategorie (Ganzer Pfad)',
|
||||
'part.manufacturer': 'Hersteller',
|
||||
'part.manufacturer_full': 'Hersteller (Ganzer Pfad)',
|
||||
'part.footprint': 'Footprint',
|
||||
'part.footprint_full': 'Footprint (Ganzer Pfad)',
|
||||
'part.mass': 'Gewicht',
|
||||
'part.tags': 'Tags',
|
||||
'part.mpn': 'Herstellernummer (MPN)',
|
||||
'part.status': 'Herstellungsstatus',
|
||||
'part.description': 'Beschreibung',
|
||||
'part.description_t': 'Beschreibung (Text)',
|
||||
'part.comment': 'Kommentar',
|
||||
'part.comment_t': 'Kommentar (Text)',
|
||||
'part.last_modified': 'Änderungsdatum',
|
||||
'part.creation_date': 'Erstellungsdatum',
|
||||
'global.username': 'Benutzername',
|
||||
'global.username_full': 'Benutzername (inklusive Name)',
|
||||
'global.datetime': 'Datum & Uhrzeit',
|
||||
'global.date': 'Datum',
|
||||
'global.time': 'Uhrzeit',
|
||||
'global.install_name': 'Installationsname',
|
||||
'global.type': 'Zieltyp',
|
||||
} );
|
50
public/ckeditor/plugins/partdb_label/lang/en.js
Normal file
50
public/ckeditor/plugins/partdb_label/lang/en.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.setLang( 'partdb_label', 'en', {
|
||||
title: 'Insert Placeholders',
|
||||
label: 'Placeholders',
|
||||
'section.global': 'Globals',
|
||||
'section.part': 'Part',
|
||||
'part.id': 'Database ID',
|
||||
'part.name': 'Part name',
|
||||
'part.category': 'Category',
|
||||
'part.category_full': 'Category (Full path)',
|
||||
'part.manufacturer': 'Manufacturer',
|
||||
'part.manufacturer_full': 'Manufacturer (Full path)',
|
||||
'part.footprint': 'Footprint',
|
||||
'part.footprint_full': 'Footprint (Full path)',
|
||||
'part.mass': 'Mass',
|
||||
'part.tags': 'Tags',
|
||||
'part.mpn': 'Manufacturer Product Number (MPN)',
|
||||
'part.status': 'Manufacturing status',
|
||||
'part.description': 'Description',
|
||||
'part.description_t': 'Description (Text)',
|
||||
'part.comment': 'Comment',
|
||||
'part.comment_t': 'Comment (Text)',
|
||||
'part.last_modified': 'Last modified datetime',
|
||||
'part.creation_date': 'Creation datetime',
|
||||
'global.username': 'Username',
|
||||
'global.username_full': 'Username (including name)',
|
||||
'global.datetime': 'Current datetime',
|
||||
'global.date': 'Current date',
|
||||
'global.time': 'Current time',
|
||||
'global.install_name': 'Instance name',
|
||||
'global.type': 'Target type',
|
||||
} );
|
115
public/ckeditor/plugins/partdb_label/plugin.js
Normal file
115
public/ckeditor/plugins/partdb_label/plugin.js
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const PLACEHOLDERS = {
|
||||
part: {
|
||||
label: 'section.part',
|
||||
entries: [
|
||||
['%%ID%%', 'part.id'],
|
||||
['%%NAME%%', 'part.name'],
|
||||
['%%CATEGORY%%', 'part.category'],
|
||||
['%%CATEGORY_FULL', 'part.category_full'],
|
||||
['%%MANUFACTURER', 'part.manufacturer'],
|
||||
['%%MANUFACTURER_FULL', 'part.manufacturer_full'],
|
||||
['%%FOOTPRINT%%', 'part.footprint'],
|
||||
['%%FOOTPRINT_FULL%%', 'part.footprint'],
|
||||
['%%MASS%%', 'part.mass'],
|
||||
['%%MPN%%', 'part.mpn'],
|
||||
['%%TAGS%%', 'part.tags'],
|
||||
['%%M_STATUS%%', 'part.status'],
|
||||
['%%DESCRIPTION%%', 'part.description'],
|
||||
['%%DESCRIPTION_T%%', 'part.description_t'],
|
||||
['%%COMMENT%%', 'part.comment'],
|
||||
['%%COMMENT_T%%', 'part.comment_t'],
|
||||
['%%LAST_MODIFIED%%', 'part.last_modified'],
|
||||
['%%CREATION_DATE%%', 'part.creation_date'],
|
||||
]
|
||||
},
|
||||
global: {
|
||||
label: 'section.global',
|
||||
entries: [
|
||||
['%%USERNAME%%', 'global.username'],
|
||||
['%%USERNAME_FULL%%', 'global.username_full'],
|
||||
['%%DATETIME%%', 'global.datetime'],
|
||||
['%%DATE%%', 'global.date'],
|
||||
['%%TIME%%', 'global.time'],
|
||||
['%%INSTALL_NAME%%', 'global.install_name'],
|
||||
['%%TYPE%%', 'global.type']
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
function findLabelForPlaceholder(search)
|
||||
{
|
||||
for (var group in PLACEHOLDERS) {
|
||||
var entries = PLACEHOLDERS[group].entries;
|
||||
for (var placeholder in entries) {
|
||||
if (entries[placeholder][0] == search) {
|
||||
return entries[placeholder][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CKEDITOR.plugins.add('partdb_label', {
|
||||
hidpi: true,
|
||||
icons: 'placeholder',
|
||||
lang: ['en', 'de'],
|
||||
init: function (editor) {
|
||||
var config = editor.config,
|
||||
lang = editor.lang.partdb_label;
|
||||
|
||||
editor.ui.addRichCombo('Placeholders', {
|
||||
label: lang.label,
|
||||
title: lang.title,
|
||||
allowedContent: 'abbr[title]',
|
||||
panel: {
|
||||
css: [ CKEDITOR.skin.getPath( 'editor' ) ].concat( config.contentsCss ),
|
||||
multiSelect: false,
|
||||
attributes: { 'aria-label': lang.title }
|
||||
},
|
||||
init: function () {
|
||||
for (var group in PLACEHOLDERS) {
|
||||
var localized_group = PLACEHOLDERS[group].label;
|
||||
if (lang[localized_group]) {
|
||||
localized_group = lang[localized_group];
|
||||
}
|
||||
this.startGroup(localized_group);
|
||||
var entries = PLACEHOLDERS[group].entries;
|
||||
for (var placeholder in entries) {
|
||||
var localized_placeholder = entries[placeholder][1];
|
||||
if (lang[localized_placeholder]) {
|
||||
localized_placeholder = lang[localized_placeholder];
|
||||
}
|
||||
this.add(entries[placeholder][0], localized_placeholder, entries[placeholder][0])
|
||||
}
|
||||
}
|
||||
},
|
||||
onClick: function(value) {
|
||||
editor.focus();
|
||||
editor.fire('saveSnapshot');
|
||||
var title = findLabelForPlaceholder(value);
|
||||
if (lang[title]) {
|
||||
title = lang[title];
|
||||
}
|
||||
editor.insertHtml('<abbr title="' + title + '">' + value + '</abbr>' + ' ', 'text');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
|
@ -64,6 +64,7 @@ class LabelOptionsType extends AbstractType
|
|||
|
||||
$builder->add('lines', CKEditorType::class, [
|
||||
'label' => 'label_profile.lines.label',
|
||||
'empty_data' => '',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue