Skip to content

Commit

Permalink
Merge branch '4' into 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Mar 3, 2024
2 parents 8d98004 + 6144240 commit 61491f2
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lang/sl.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
sl:
DNADesign\Elemental\Controllers\ElementalAreaController:
MENUTITLE: 'Uredi stran'
DNADesign\Elemental\Extensions\ElementalPageExtension:
has_one_ElementalArea: Blok
DNADesign\Elemental\Forms\TextCheckboxGroupField:
DISPLAYED: Prikazano
NOT_DISPLAYED: Skrito
Expand All @@ -22,7 +24,14 @@ sl:
SINGULARNAME: Gradnik
STYLE: 'Stilna različica'
SettingsTabLabel: Nastavitve
db_ExtraClass: 'Dodatna opredelitev (razred)'
db_ShowTitle: 'Prikaži naslov'
db_Sort: Razvrsti
db_Style: Slog
db_Title: Naslov
db_Version: Različica
has_one_Parent: Nadrejen
has_one_TopPage: 'Vrhnja stran'
DNADesign\Elemental\Models\ElementContent:
BlockType: Besedilo
ContentLabel: Oznaka
Expand All @@ -33,6 +42,7 @@ sl:
other: '{count} besedil'
two: '{count} besedili'
SINGULARNAME: Besedilo
db_HTML: 'Koda HTML'
DNADesign\Elemental\Models\ElementalArea:
PLURALNAME: Bloki
PLURALS:
Expand All @@ -41,6 +51,10 @@ sl:
other: '{count} blokov'
two: '{count} bloka'
SINGULARNAME: Blok
db_OwnerClassName: 'Opredelitev (razred) lastnika'
db_Version: Različica
has_many_Elements: Gradniki
has_one_TopPage: 'Vrhnja stran'
DNADesign\Elemental\Reports\ElementTypeReport:
Title: 'Tipi gradnikov'
Total: Skupaj
Expand All @@ -52,3 +66,9 @@ sl:
Summary: Povzetek
Title: Naslov
Type: 'Tip gradnika'
DNADesign\Elemental\TopPage\DataExtension:
has_one_TopPage: 'Vrhnja stran'
DNADesign\Elemental\TopPage\FluentExtension:
db_TopPageLocale: 'Lokalizacija vrhnje strani '
SilverStripe\CMS\Controllers\CMSPageHistoryController:
PREVIEW: Predogled
26 changes: 26 additions & 0 deletions tests/Behat/Extension/UniqueHtmlEditorConfigExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace DNADesign\Elemental\Tests\Behat\Extension;

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Core\Extension;
use SilverStripe\Dev\TestOnly;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;

/**
* @extends Extension<BaseElement>
*/
class UniqueHtmlEditorConfigExtension extends Extension implements TestOnly
{
public function updateCMSFields(FieldList $fields)
{
$wysiwyg = $fields->dataFieldByName('HTML');
if ($wysiwyg instanceof HTMLEditorField) {
$config = clone HTMLEditorConfig::get('cms');
$config->setOption('editorIdentifier', 'cms-' . $this->getOwner()->getUniqueKey());
$wysiwyg->setEditorConfig($config);
}
}
}
42 changes: 42 additions & 0 deletions tests/Behat/features/multiple-wysiwyg-configs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Feature: multiple elemental blocks with different HTMLEditorConfig instances
As a developer
I want my elemental blocks to have different HTMLEditorConfig instances
So that the appropriate options are available for each block

Background:
Given I add an extension "DNADesign\Elemental\Tests\Behat\Extension\UniqueHtmlEditorConfigExtension" to the "DNADesign\Elemental\Models\BaseElement" class
And I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "Alice's Block" content element with "<p>Some content</p>" content
And the "page" "Blocks Page" has a "Bob's Block" content element with "<p>completely different stuff</p>" content
And the "group" "EDITOR" has permissions "Access to 'Pages' section"
And I am logged in as a member of "EDITOR" group
And I go to "/admin/pages"
And I left click on "Blocks Page" in the tree

@unsavedChanges
Scenario: The WYSIWYG should work correctly for all configs
Given I see a list of blocks
# Check the link menu in the WYSIWYG "insert link" button is correct for block 1
When I click on block 1
And I click on the "#Form_ElementForm_1 [aria-label^='Insert link'] button" element
Then I should see "Page on this site" in the ".mce-menu.mce-in" element
And I should see "Link to a file" in the ".mce-menu.mce-in" element
And I should see "Link to external URL" in the ".mce-menu.mce-in" element
And I should see "Anchor on a page" in the ".mce-menu.mce-in" element
And I should see "Link to email address" in the ".mce-menu.mce-in" element
# Check the link menu in the WYSIWYG "insert link" button is correct for block 2
When I click on block 2
# In CI, the mouse position just happens to produce a tooltip that stops us clicking on the insert link button
# so we have to move the mouse somewhere else to avoid that
And I click on the "input[type='text']" element
And I click on the "#Form_ElementForm_2 [aria-label^='Insert link'] button" element
Then I should see "Page on this site" in the ".mce-menu.mce-in" element
And I should see "Link to a file" in the ".mce-menu.mce-in" element
And I should see "Link to external URL" in the ".mce-menu.mce-in" element
And I should see "Anchor on a page" in the ".mce-menu.mce-in" element
And I should see "Link to email address" in the ".mce-menu.mce-in" element
# Check the content of both WYSIWYG fields is correct
And the "Content" field for block 1 should contain "<p>Some content</p>"
And the "Content" field for block 2 should contain "<p>completely different stuff</p>"


0 comments on commit 61491f2

Please sign in to comment.