Skip to content

Commit 8ffc3a4

Browse files
committed
Merge branch 'development' into release
2 parents 7233c1c + 16222de commit 8ffc3a4

File tree

191 files changed

+4511
-1352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+4511
-1352
lines changed

.env.example.complete

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ AVATAR_URL=
274274
# Enable diagrams.net integration
275275
# Can simply be true/false to enable/disable the integration.
276276
# Alternatively, It can be URL to the diagrams.net instance you want to use.
277-
# For URLs, The following URL parameters should be included: embed=1&proto=json&spin=1
277+
# For URLs, The following URL parameters should be included: embed=1&proto=json&spin=1&configure=1
278278
DRAWIO=true
279279

280280
# Default item listing view

.github/translators.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Francesco Franchina (ffranchina) :: Italian
165165
Aimrane Kds (aimrane.kds) :: Arabic
166166
whenwesober :: Indonesian
167167
Rem (remkovdhoef) :: Dutch
168-
syn7ax69 :: Bulgarian; Turkish
168+
syn7ax69 :: Bulgarian; Turkish; German
169169
Blaade :: French
170170
Behzad HosseinPoor (behzad.hp) :: Persian
171171
Ole Aldric (Swoy) :: Norwegian Bokmal
@@ -238,3 +238,7 @@ pedromcsousa :: Portuguese
238238
Nir Louk (looknear) :: Hebrew
239239
Alex (qianmengnet) :: Chinese Simplified
240240
stothew :: German
241+
sgenc :: Turkish
242+
Shukrullo (vodiylik) :: Uzbek
243+
William W. (Nevnt) :: Chinese Traditional
244+
eamaro :: Portuguese

app/Config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
'locale' => env('APP_LANG', 'en'),
7272

7373
// Locales available
74-
'locales' => ['en', 'ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'de_informal', 'es', 'es_AR', 'et', 'eu', 'fa', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'lv', 'nl', 'nb', 'pt', 'pt_BR', 'sk', 'sl', 'sv', 'pl', 'ru', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW'],
74+
'locales' => ['en', 'ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'de_informal', 'es', 'es_AR', 'et', 'eu', 'fa', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'lv', 'nl', 'nb', 'pt', 'pt_BR', 'sk', 'sl', 'sv', 'pl', 'ru', 'th', 'tr', 'uk', 'uz', 'vi', 'zh_CN', 'zh_TW'],
7575

7676
// Application Fallback Locale
7777
'fallback_locale' => 'en',

app/Entities/Models/Deletion.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
use Illuminate\Database\Eloquent\Relations\MorphTo;
1111

1212
/**
13+
* @property int $id
14+
* @property int $deleted_by
15+
* @property string $deletable_type
16+
* @property int $deletable_id
1317
* @property Deletable $deletable
1418
*/
1519
class Deletion extends Model implements Loggable
1620
{
21+
protected $hidden = [];
22+
1723
/**
1824
* Get the related deletable record.
1925
*/

app/Entities/Models/Page.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @property bool $template
2323
* @property bool $draft
2424
* @property int $revision_count
25+
* @property string $editor
2526
* @property Chapter $chapter
2627
* @property Collection $attachments
2728
* @property Collection $revisions

app/Entities/Models/PageRevision.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* @property mixed $id
1414
* @property int $page_id
15+
* @property string $name
1516
* @property string $slug
1617
* @property string $book_slug
1718
* @property int $created_by
@@ -21,13 +22,14 @@
2122
* @property string $summary
2223
* @property string $markdown
2324
* @property string $html
25+
* @property string $text
2426
* @property int $revision_number
2527
* @property Page $page
2628
* @property-read ?User $createdBy
2729
*/
2830
class PageRevision extends Model
2931
{
30-
protected $fillable = ['name', 'html', 'text', 'markdown', 'summary'];
32+
protected $fillable = ['name', 'text', 'summary'];
3133
protected $hidden = ['html', 'markdown', 'restricted', 'text'];
3234

3335
/**

app/Entities/Repos/BaseRepo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
class BaseRepo
1313
{
14-
protected $tagRepo;
15-
protected $imageRepo;
14+
protected TagRepo $tagRepo;
15+
protected ImageRepo $imageRepo;
1616

1717
public function __construct(TagRepo $tagRepo, ImageRepo $imageRepo)
1818
{
@@ -58,6 +58,7 @@ public function update(Entity $entity, array $input)
5858

5959
if (isset($input['tags'])) {
6060
$this->tagRepo->saveTagsToEntity($entity, $input['tags']);
61+
$entity->touch();
6162
}
6263

6364
$entity->rebuildPermissions();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace BookStack\Entities\Repos;
4+
5+
use BookStack\Actions\ActivityType;
6+
use BookStack\Entities\Models\Deletion;
7+
use BookStack\Entities\Tools\TrashCan;
8+
use BookStack\Facades\Activity;
9+
10+
class DeletionRepo
11+
{
12+
private TrashCan $trashCan;
13+
14+
public function __construct(TrashCan $trashCan)
15+
{
16+
$this->trashCan = $trashCan;
17+
}
18+
19+
public function restore(int $id): int
20+
{
21+
/** @var Deletion $deletion */
22+
$deletion = Deletion::query()->findOrFail($id);
23+
Activity::add(ActivityType::RECYCLE_BIN_RESTORE, $deletion);
24+
25+
return $this->trashCan->restoreFromDeletion($deletion);
26+
}
27+
28+
public function destroy(int $id): int
29+
{
30+
/** @var Deletion $deletion */
31+
$deletion = Deletion::query()->findOrFail($id);
32+
Activity::add(ActivityType::RECYCLE_BIN_DESTROY, $deletion);
33+
34+
return $this->trashCan->destroyFromDeletion($deletion);
35+
}
36+
}

app/Entities/Repos/PageRepo.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use BookStack\Entities\Models\PageRevision;
1111
use BookStack\Entities\Tools\BookContents;
1212
use BookStack\Entities\Tools\PageContent;
13+
use BookStack\Entities\Tools\PageEditorData;
1314
use BookStack\Entities\Tools\TrashCan;
1415
use BookStack\Exceptions\MoveOperationException;
1516
use BookStack\Exceptions\NotFoundException;
@@ -217,20 +218,38 @@ protected function updateTemplateStatusAndContentFromInput(Page $page, array $in
217218
}
218219

219220
$pageContent = new PageContent($page);
220-
if (!empty($input['markdown'] ?? '')) {
221+
$currentEditor = $page->editor ?: PageEditorData::getSystemDefaultEditor();
222+
$newEditor = $currentEditor;
223+
224+
$haveInput = isset($input['markdown']) || isset($input['html']);
225+
$inputEmpty = empty($input['markdown']) && empty($input['html']);
226+
227+
if ($haveInput && $inputEmpty) {
228+
$pageContent->setNewHTML('');
229+
} elseif (!empty($input['markdown']) && is_string($input['markdown'])) {
230+
$newEditor = 'markdown';
221231
$pageContent->setNewMarkdown($input['markdown']);
222232
} elseif (isset($input['html'])) {
233+
$newEditor = 'wysiwyg';
223234
$pageContent->setNewHTML($input['html']);
224235
}
236+
237+
if ($newEditor !== $currentEditor && userCan('editor-change')) {
238+
$page->editor = $newEditor;
239+
}
225240
}
226241

227242
/**
228243
* Saves a page revision into the system.
229244
*/
230245
protected function savePageRevision(Page $page, string $summary = null): PageRevision
231246
{
232-
$revision = new PageRevision($page->getAttributes());
247+
$revision = new PageRevision();
233248

249+
$revision->name = $page->name;
250+
$revision->html = $page->html;
251+
$revision->markdown = $page->markdown;
252+
$revision->text = $page->text;
234253
$revision->page_id = $page->id;
235254
$revision->slug = $page->slug;
236255
$revision->book_slug = $page->book->slug;
@@ -260,10 +279,15 @@ public function updatePageDraft(Page $page, array $input)
260279
return $page;
261280
}
262281

263-
// Otherwise save the data to a revision
282+
// Otherwise, save the data to a revision
264283
$draft = $this->getPageRevisionToUpdate($page);
265284
$draft->fill($input);
266-
if (setting('app-editor') !== 'markdown') {
285+
286+
if (!empty($input['markdown'])) {
287+
$draft->markdown = $input['markdown'];
288+
$draft->html = '';
289+
} else {
290+
$draft->html = $input['html'];
267291
$draft->markdown = '';
268292
}
269293

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace BookStack\Entities\Tools\Markdown;
4+
5+
use League\HTMLToMarkdown\Converter\DivConverter;
6+
use League\HTMLToMarkdown\ElementInterface;
7+
8+
class CustomDivConverter extends DivConverter
9+
{
10+
public function convert(ElementInterface $element): string
11+
{
12+
// Clean up draw.io diagrams
13+
$drawIoDiagram = $element->getAttribute('drawio-diagram');
14+
if ($drawIoDiagram) {
15+
return "<div drawio-diagram=\"{$drawIoDiagram}\">{$element->getValue()}</div>\n\n";
16+
}
17+
18+
return parent::convert($element);
19+
}
20+
}

0 commit comments

Comments
 (0)