Skip to content

Commit a5e25ab

Browse files
committed
Merge branch 'v24-02' into release
2 parents b310e87 + 3e23f45 commit a5e25ab

File tree

8 files changed

+38
-9
lines changed

8 files changed

+38
-9
lines changed

app/References/ReferenceFetcher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ protected function queryReferencesToEntity(Entity $entity): Builder
4141
{
4242
$baseQuery = Reference::query()
4343
->where('to_type', '=', $entity->getMorphClass())
44-
->where('to_id', '=', $entity->id);
44+
->where('to_id', '=', $entity->id)
45+
->whereHas('from');
4546

4647
return $this->permissions->restrictEntityRelationQuery(
4748
$baseQuery,

app/Util/HtmlDescriptionFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HtmlDescriptionFilter
2020
*/
2121
protected static array $allowedAttrsByElements = [
2222
'p' => [],
23-
'a' => ['href', 'title'],
23+
'a' => ['href', 'title', 'target'],
2424
'ol' => [],
2525
'ul' => [],
2626
'li' => [],

resources/js/code/index.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ function highlightElem(elem) {
4848
const content = elem.textContent.trimEnd();
4949

5050
let langName = '';
51+
let innerCodeDirection = '';
5152
if (innerCodeElem !== null) {
5253
langName = innerCodeElem.className.replace('language-', '');
54+
innerCodeDirection = innerCodeElem.getAttribute('dir');
5355
}
5456

5557
const wrapper = document.createElement('div');
5658
elem.parentNode.insertBefore(wrapper, elem);
5759

58-
const direction = innerCodeElem.getAttribute('dir') || elem.getAttribute('dir') || '';
60+
const direction = innerCodeDirection || elem.getAttribute('dir') || '';
5961
if (direction) {
6062
wrapper.setAttribute('dir', direction);
6163
}

resources/js/wysiwyg/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export function buildForInput(options) {
348348
toolbar: 'bold italic link bullist numlist',
349349
content_style: getContentStyle(options),
350350
file_picker_types: 'file',
351-
valid_elements: 'p,a[href|title],ol,ul,li,strong,em,br',
351+
valid_elements: 'p,a[href|title|target],ol,ul,li,strong,em,br',
352352
file_picker_callback: filePickerCallback,
353353
init_instance_callback(editor) {
354354
addCustomHeadContent(editor.getDoc());

resources/sass/_forms.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@
128128
body {
129129
display: block;
130130
background-color: #fff;
131-
padding-inline-start: 16px;
132-
padding-inline-end: 16px;
131+
padding-inline-start: 12px;
132+
padding-inline-end: 12px;
133+
max-width: 864px;
133134
}
134135
[drawio-diagram]:hover {
135136
outline: 2px solid var(--color-primary);

resources/sass/_tinymce.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
padding-block-end: 1rem;
2222
outline: 0;
2323
display: block;
24+
max-width: 870px;
2425
}
2526

2627
.wysiwyg-input.mce-content-body {

tests/Entity/BookTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ public function test_description_limited_to_specific_html()
266266
{
267267
$book = $this->entities->book();
268268

269-
$input = '<h1>Test</h1><p id="abc" href="beans">Content<a href="#cat" data-a="b">a</a><section>Hello</section></p>';
270-
$expected = '<p>Content<a href="#cat">a</a></p>';
269+
$input = '<h1>Test</h1><p id="abc" href="beans">Content<a href="#cat" target="_blank" data-a="b">a</a><section>Hello</section></p>';
270+
$expected = '<p>Content<a href="#cat" target="_blank">a</a></p>';
271271

272272
$this->asEditor()->put($book->getUrl(), [
273273
'name' => $book->name,

tests/References/ReferencesTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,31 @@ public function test_description_links_from_book_chapter_shelf_updated_on_url_ch
271271
}
272272
}
273273

274-
protected function createReference(Model $from, Model $to)
274+
public function test_reference_from_deleted_item_does_not_count_or_show_in_references_page()
275+
{
276+
$page = $this->entities->page();
277+
$referencingPageA = $this->entities->page();
278+
$referencingPageB = $this->entities->page();
279+
280+
$this->asEditor();
281+
$this->createReference($referencingPageA, $page);
282+
$this->createReference($referencingPageB, $page);
283+
284+
$resp = $this->get($page->getUrl());
285+
$resp->assertSee('Referenced by 2 items');
286+
287+
$this->delete($referencingPageA->getUrl());
288+
289+
$resp = $this->get($page->getUrl());
290+
$resp->assertSee('Referenced by 1 item');
291+
292+
$resp = $this->get($page->getUrl('/references'));
293+
$resp->assertOk();
294+
$resp->assertSee($referencingPageB->getUrl());
295+
$resp->assertDontSee($referencingPageA->getUrl());
296+
}
297+
298+
protected function createReference(Model $from, Model $to): void
275299
{
276300
(new Reference())->forceFill([
277301
'from_type' => $from->getMorphClass(),

0 commit comments

Comments
 (0)