Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/References/ReferenceFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ protected function queryReferencesToEntity(Entity $entity): Builder
{
$baseQuery = Reference::query()
->where('to_type', '=', $entity->getMorphClass())
->where('to_id', '=', $entity->id);
->where('to_id', '=', $entity->id)
->whereHas('from');

return $this->permissions->restrictEntityRelationQuery(
$baseQuery,
Expand Down
2 changes: 1 addition & 1 deletion app/Util/HtmlDescriptionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HtmlDescriptionFilter
*/
protected static array $allowedAttrsByElements = [
'p' => [],
'a' => ['href', 'title'],
'a' => ['href', 'title', 'target'],
'ol' => [],
'ul' => [],
'li' => [],
Expand Down
4 changes: 3 additions & 1 deletion resources/js/code/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ function highlightElem(elem) {
const content = elem.textContent.trimEnd();

let langName = '';
let innerCodeDirection = '';
if (innerCodeElem !== null) {
langName = innerCodeElem.className.replace('language-', '');
innerCodeDirection = innerCodeElem.getAttribute('dir');
}

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

const direction = innerCodeElem.getAttribute('dir') || elem.getAttribute('dir') || '';
const direction = innerCodeDirection || elem.getAttribute('dir') || '';
if (direction) {
wrapper.setAttribute('dir', direction);
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/wysiwyg/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export function buildForInput(options) {
toolbar: 'bold italic link bullist numlist',
content_style: getContentStyle(options),
file_picker_types: 'file',
valid_elements: 'p,a[href|title],ol,ul,li,strong,em,br',
valid_elements: 'p,a[href|title|target],ol,ul,li,strong,em,br',
file_picker_callback: filePickerCallback,
init_instance_callback(editor) {
addCustomHeadContent(editor.getDoc());
Expand Down
5 changes: 3 additions & 2 deletions resources/sass/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@
body {
display: block;
background-color: #fff;
padding-inline-start: 16px;
padding-inline-end: 16px;
padding-inline-start: 12px;
padding-inline-end: 12px;
max-width: 864px;
}
[drawio-diagram]:hover {
outline: 2px solid var(--color-primary);
Expand Down
1 change: 1 addition & 0 deletions resources/sass/_tinymce.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
padding-block-end: 1rem;
outline: 0;
display: block;
max-width: 870px;
}

.wysiwyg-input.mce-content-body {
Expand Down
4 changes: 2 additions & 2 deletions tests/Entity/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ public function test_description_limited_to_specific_html()
{
$book = $this->entities->book();

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

$this->asEditor()->put($book->getUrl(), [
'name' => $book->name,
Expand Down
26 changes: 25 additions & 1 deletion tests/References/ReferencesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,31 @@ public function test_description_links_from_book_chapter_shelf_updated_on_url_ch
}
}

protected function createReference(Model $from, Model $to)
public function test_reference_from_deleted_item_does_not_count_or_show_in_references_page()
{
$page = $this->entities->page();
$referencingPageA = $this->entities->page();
$referencingPageB = $this->entities->page();

$this->asEditor();
$this->createReference($referencingPageA, $page);
$this->createReference($referencingPageB, $page);

$resp = $this->get($page->getUrl());
$resp->assertSee('Referenced by 2 items');

$this->delete($referencingPageA->getUrl());

$resp = $this->get($page->getUrl());
$resp->assertSee('Referenced by 1 item');

$resp = $this->get($page->getUrl('/references'));
$resp->assertOk();
$resp->assertSee($referencingPageB->getUrl());
$resp->assertDontSee($referencingPageA->getUrl());
}

protected function createReference(Model $from, Model $to): void
{
(new Reference())->forceFill([
'from_type' => $from->getMorphClass(),
Expand Down