Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #9

Merged
merged 179 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
5a4f595
Editors: Added lexical editor for testing
ssddanbrown May 27, 2024
6e852d2
Lexical: Played with commands, extracted & improved callout node
ssddanbrown May 27, 2024
49546cd
Lexical: Switched to ts for new editor build
ssddanbrown May 27, 2024
0f8bd86
Lexical: Added custom id-supporting paragraph blocks
ssddanbrown May 28, 2024
b24d60e
Lexical: Started UI fundementals with basic button
ssddanbrown May 28, 2024
483d9bf
Lexical: Added a range of format buttons
ssddanbrown May 28, 2024
dc1a40e
Lexical: Added ui container type
ssddanbrown May 29, 2024
57259ae
Lexical: Added format previews to format buttons
ssddanbrown May 30, 2024
ae98745
Lexical: Started on form UI
ssddanbrown May 30, 2024
7c504a1
Lexical: Created core modal functionality
ssddanbrown Jun 1, 2024
a74e041
Lexical: Started build of image node and decoration UI
ssddanbrown Jun 3, 2024
ba871ec
Lexical: Started image resize controls, Defined thorough decorator model
ssddanbrown Jun 5, 2024
e959c46
Lexical: Made image resize handles functional
ssddanbrown Jun 5, 2024
0722960
Lexical: Added selection to state for aligned reading
ssddanbrown Jun 5, 2024
5c34363
Added base node/button for details/summary
ssddanbrown Jun 6, 2024
e889bc6
Lexical: Added view/edit source code button/form/action
ssddanbrown Jun 12, 2024
a475cf6
Lexical: Added clear formatting button
ssddanbrown Jun 12, 2024
9e43e03
Lexical: Added color picker controls
ssddanbrown Jun 12, 2024
e2409a5
Lexical: Added basic list button/support
ssddanbrown Jun 19, 2024
13d970c
Lexical: Added button icon system
ssddanbrown Jun 19, 2024
f47f7dd
Lexical: Added base table support and started resize handling
ssddanbrown Jun 21, 2024
ac01c62
Lexical: Added table creator UI
ssddanbrown Jun 21, 2024
a07092b
Lexical: Updated lexical, added undo state tracking, format styles
ssddanbrown Jun 23, 2024
5546b8f
Lexical: Added more icons, made reflective text/bg color buttons
ssddanbrown Jun 23, 2024
3af22ce
Lexical: Created custom table node with col width handling
ssddanbrown Jun 24, 2024
5993663
Lexical: Extracted mouse drag tracking to new helper
ssddanbrown Jun 25, 2024
b1130cb
Lexical: Linked up table resize handler (unfinished)
ssddanbrown Jun 26, 2024
72a0e08
Lexical: Completed initial table cell resize handle logic
ssddanbrown Jun 26, 2024
4e2820d
Lexical: Added horizontal rule node
ssddanbrown Jun 27, 2024
f10ec32
Lexical: Added overflow container
ssddanbrown Jun 27, 2024
517c578
Lexical: Reorganised some logic into manager
ssddanbrown Jun 30, 2024
c9a03c5
Lexical: Added base context toolbar logic
ssddanbrown Jun 30, 2024
b1c4890
Lexical: Added context toolbar placement, added link toolbar
ssddanbrown Jun 30, 2024
c2ecbf0
Lexical: Added tracked container, added fullscreen action
ssddanbrown Jul 1, 2024
9ebbf7c
Lexical: Started loading real content, Improved html loading
ssddanbrown Jul 1, 2024
97f570a
Lexical: Started code block node implementation
ssddanbrown Jul 2, 2024
d0a5a5e
Lexical: Linked code block to editor, added button
ssddanbrown Jul 2, 2024
feca1f0
Lexical: Started diagram support
ssddanbrown Jul 3, 2024
a8f1160
JS: Converted come common services to typescript
ssddanbrown Jul 3, 2024
04c7e68
Lexical: Linked up saving logic of editor via interface
ssddanbrown Jul 4, 2024
2c96af9
Lexical: Worked on toolbar styling, got format submenu working
ssddanbrown Jul 4, 2024
51d8044
Lexical: Added initial form/modal styles
ssddanbrown Jul 9, 2024
ea4c50c
Lexical: Added code block selection & edit features
ssddanbrown Jul 16, 2024
b367490
Lexical: Added list support, started todo
ssddanbrown Jul 17, 2024
5002a89
Lexical: Standardised helper function format
ssddanbrown Jul 17, 2024
634b0aa
Lexical: Started converting drawio to TS
ssddanbrown Jul 18, 2024
fb87fb5
JS: Converted http service to ts
ssddanbrown Jul 18, 2024
c7c0df0
Lexical: Finished up core drawing insert/editing
ssddanbrown Jul 19, 2024
63f4b42
Lexical: Added toolbar scroll/resize handling
ssddanbrown Jul 19, 2024
b618287
Lexical: Added table toolbar, organised button code
ssddanbrown Jul 21, 2024
2cab778
Lexical: Improved table resize bars
ssddanbrown Jul 23, 2024
76b0d2d
Lexical: Added common events support
ssddanbrown Jul 23, 2024
f284d31
Lexical: Started media node support
ssddanbrown Jul 25, 2024
c8f6b7e
Lexical: Got media node core work & form done
ssddanbrown Jul 27, 2024
ce8c9dd
Lexical: Added form complex/tab ui support
ssddanbrown Jul 28, 2024
9a7edc6
Lexical: Started drop handling, handled templates
ssddanbrown Jul 29, 2024
d86837a
Lexical: Got working with attachment insert/drop
ssddanbrown Jul 29, 2024
fe05cff
Lexical: Linked up change/draft management
ssddanbrown Jul 29, 2024
13f8f39
Lexical: Updated task list to use/support old format
ssddanbrown Jul 30, 2024
6b06d49
Lexical: Started table menu options
ssddanbrown Aug 2, 2024
a27a325
Lexical: Started on table actions
ssddanbrown Aug 2, 2024
e94ad78
Lexical: Completed out table menu elements, logic pending
ssddanbrown Aug 3, 2024
efec752
Lexical: Split helpers to utils, refactored files
ssddanbrown Aug 3, 2024
8939f31
Lexical: Started linking up cell properties form
ssddanbrown Aug 5, 2024
b3d3b14
Lexical: Finished off core cell properties functionality
ssddanbrown Aug 5, 2024
fcc1c29
Lexical: Added table cell node import logic
ssddanbrown Aug 6, 2024
e8532ef
Lexical: Added merge cell logic
ssddanbrown Aug 7, 2024
da54e1d
Lexical: Added cell width fetching, Created custom row node
ssddanbrown Aug 9, 2024
db4208a
Lexical: Linked row properties form up
ssddanbrown Aug 9, 2024
abbfd42
Lexical: Kinda made row copy/paste work
ssddanbrown Aug 9, 2024
ebf95f6
Lexical: Wired table properties, and other buttons
ssddanbrown Aug 10, 2024
ec965f2
Lexical: Added id support for all main block types
ssddanbrown Aug 11, 2024
accf256
Lexical: Integrated image manager to image button/form
ssddanbrown Aug 13, 2024
1ef4044
Lexical: Connected link selector to link form
ssddanbrown Aug 16, 2024
ad6b26b
Lexical: Added basic URL field header option list
ssddanbrown Aug 16, 2024
0039f89
Lexical: Integrated diagram manager, added menu split button
ssddanbrown Aug 17, 2024
111a313
Lexical: Added custom alignment handling for blocks
ssddanbrown Aug 18, 2024
aa1fac6
Lexical: Started adding editor shortcuts
ssddanbrown Aug 20, 2024
dbb2fe3
Lexical: Finished off baseline shortcut implementation
ssddanbrown Aug 20, 2024
ddf5f25
Lexical: Added drop/paste image handling
ssddanbrown Aug 21, 2024
8a13a9d
Lexical: Improved table row copy/paste
ssddanbrown Aug 22, 2024
1ebb0f8
Lexical: Added table column cut/copy/paste support
ssddanbrown Aug 22, 2024
1c9afcb
Lexical: Added some level of img/media alignment
ssddanbrown Sep 6, 2024
e5b6d28
Lexical: Revamped image node resize method
ssddanbrown Sep 7, 2024
bed2c29
Lexical: Added media resize support via drag handles
ssddanbrown Sep 8, 2024
16518a4
Lexical: Range of bug fixes, Updated lexical version
ssddanbrown Sep 8, 2024
fd07aa0
Lexical: Further fixes
ssddanbrown Sep 9, 2024
fb49371
Lexical: Refined editor UI
ssddanbrown Sep 9, 2024
ced66f1
Lexical: Added single node backspace/delete support
ssddanbrown Sep 9, 2024
476c2be
Add XML for OpenSearch
maximilian-walter Sep 9, 2024
2036438
Lexical: Added single node enter handling
ssddanbrown Sep 10, 2024
5083188
Lexical: Added block indenting capability
ssddanbrown Sep 10, 2024
662110c
Lexical: Custom list nesting support
ssddanbrown Sep 13, 2024
6872eb8
Lexical: Altered keyboard handling to indicant handled state
ssddanbrown Sep 13, 2024
c110a97
Remove unofficial method-attribute from OpenSearch-XML
maximilian-walter Sep 14, 2024
4f890c4
Limit short-name for OpenSearch XML to 16 characters
maximilian-walter Sep 14, 2024
5f46d71
Lexical: Fixed a range of issues in RTL mode
ssddanbrown Sep 15, 2024
03490d6
Lexical: Added RTL/LTR actions
ssddanbrown Sep 16, 2024
22d078b
Lexical: Imported core lexical libs
ssddanbrown Sep 18, 2024
ccd486f
Lexical: Got a range of Editor tests working
ssddanbrown Sep 18, 2024
787e06e
Lexical: Adapted a range of further existing tests
ssddanbrown Sep 20, 2024
dba8ab9
Lexical: Finished conversion/update of test files
ssddanbrown Sep 20, 2024
654a7a5
Lexical: Removed reconciler level direction handling
ssddanbrown Sep 21, 2024
e6edd93
Lexical: Added alignment detoggle, fixed inital focus area
ssddanbrown Sep 21, 2024
2add15b
Lexical: Added direction support to extra blocks
ssddanbrown Sep 22, 2024
ef3de10
Lexical: Added UI translation support
ssddanbrown Sep 22, 2024
c8ccb2b
Lexical: Range of fixes
ssddanbrown Sep 22, 2024
8b32e6c
Page Editors: Added switching/options for new lexical editor
ssddanbrown Sep 22, 2024
a62d838
Lexical: Updated toolbar & text node exporting
ssddanbrown Sep 23, 2024
1b9310e
Meta: Added lexical licensing info and added TS/JS CI testing
ssddanbrown Sep 27, 2024
b35b62d
Merge branch 'lexical' into development
ssddanbrown Sep 27, 2024
56b9107
Dependancies: Updated php & JS deps, updated license lists
ssddanbrown Sep 27, 2024
eec639d
Maintenance: Fixed js lint and SCSS build warnings
ssddanbrown Sep 27, 2024
abda9bc
PHP Dependancies: Updated packages pending major version changes
ssddanbrown Sep 27, 2024
42264f4
CSS: Fixed floating search icon on mobile
ssddanbrown Sep 27, 2024
6103a22
Exports: Made pdf command timeout configurable
ssddanbrown Sep 27, 2024
89f84c9
Pages: Updated editor field to always be set
ssddanbrown Sep 29, 2024
d12e8ec
Users: Improved user response for failed invite sending
ssddanbrown Sep 29, 2024
f583354
Maintenance: Removed stray dd from last commit
ssddanbrown Sep 29, 2024
a5b031f
Translatable description for OpenSearch XML
maximilian-walter Sep 14, 2024
1302e3c
Add missing XML declaration to OpenSearch endpoint
maximilian-walter Sep 14, 2024
2f74cfb
Add test for OpenSearch endpoint
maximilian-walter Sep 14, 2024
8bc6e75
Code Blocks: Added SAS and R language options
ssddanbrown Sep 30, 2024
514db60
Tests: Categorised up meta tests
ssddanbrown Sep 30, 2024
e656555
Merge branch 'feature/opensearch' into development
ssddanbrown Sep 30, 2024
34ade50
Base layout: Changed main app script to be module loaded
ssddanbrown Oct 1, 2024
177cfd7
Search: Added structure for search term inputs
ssddanbrown Oct 2, 2024
93c677a
Searching: Added negation support to UI and term handling
ssddanbrown Oct 3, 2024
cd84d08
Search: Added exact/filter/tag term negation support
ssddanbrown Oct 3, 2024
966ff91
Search: Prevented negated terms filling in UI inputs
ssddanbrown Oct 3, 2024
6646dcc
Merge pull request #5239 from BookStackApp/search_negation
ssddanbrown Oct 3, 2024
b1a3ea1
Languages: Enabled Welsh option
ssddanbrown Oct 4, 2024
be6529d
New WYSIWYG: Added mac shortcut support
ssddanbrown Oct 4, 2024
2766c76
TinyMCE: Updated version from 6.8.3 to 6.8.4
ssddanbrown Oct 4, 2024
346b88a
JS: Converted a few extra services to TS
ssddanbrown Oct 4, 2024
9b2520a
WYSIWYG: Fixed list indenting selection & display bugs
ssddanbrown Oct 4, 2024
c314a60
WYSIWYG: Code & table fixes
ssddanbrown Oct 5, 2024
51287d5
Searching: Fixed some form search issues
ssddanbrown Oct 5, 2024
8b9bcc1
Search: Fixed last commented filter when using table prefixes
ssddanbrown Oct 5, 2024
d22413b
JS: Converted/updated translation code to TS, fixed some comment counts
ssddanbrown Oct 7, 2024
65453bd
Updated translations with latest Crowdin changes (#5188)
ssddanbrown Oct 9, 2024
a58102d
Attribution: Updated translator & license files before v24.10
ssddanbrown Oct 9, 2024
a5f48e3
Merge branch 'development' into release
ssddanbrown Oct 9, 2024
26aadff
Updated version and assets for release v24.10
ssddanbrown Oct 9, 2024
b9b5003
Refactor SettingController to validate categies by existing view files
Oct 10, 2024
a3d0f74
Move settings category layouts into their own view folder
Oct 10, 2024
4dc75ba
Settings: Added test to cover setting category by view
ssddanbrown Oct 11, 2024
6f1c54d
Users: Changed name validation to min:1 instead of 2
ssddanbrown Oct 15, 2024
7aaf866
fix tests namespace definition
LordSimal Oct 26, 2024
e4ca3bf
Merge pull request #5291 from LordSimal/development
ssddanbrown Oct 27, 2024
45189d9
System CLI: Updated to 126de5599c state
ssddanbrown Nov 7, 2024
73babcb
Merge pull request #5312 from BookStackApp/system_cli_update
ssddanbrown Nov 7, 2024
8120278
PHP Deps: Bumped up minor versions
ssddanbrown Nov 8, 2024
7017a1c
Update URL Command: Added revisions table support
ssddanbrown Nov 8, 2024
a6ba8dd
Testing: Improved reliability
ssddanbrown Nov 8, 2024
e42cdbe
Updated translations with latest Crowdin changes (#5250)
ssddanbrown Nov 8, 2024
e5a6ccc
Translators: Updated before patch release
ssddanbrown Nov 8, 2024
ac27e18
Languages: Added Turkmen to locale manager
ssddanbrown Nov 8, 2024
0cf313a
Merge branch 'development' into release
ssddanbrown Nov 8, 2024
f3efb64
Updated version and assets for release v24.10.1
ssddanbrown Nov 8, 2024
c40ab41
Dependencies: Updated composer packages
ssddanbrown Nov 13, 2024
306b877
Updated translations with latest Crowdin changes (#5317)
ssddanbrown Nov 13, 2024
c0b3770
Merge branch 'development' into release
ssddanbrown Nov 13, 2024
5fba4a5
Updated version and assets for release v24.10.2
ssddanbrown Nov 13, 2024
17f7afe
Updates the OIDC userinfo endpoint request to allow for a `Content-Ty…
Nov 26, 2024
68ce340
Depenencies: Updated PHP packages
ssddanbrown Nov 28, 2024
415cd6a
Includes: Workaround for PHP 8.3.14 bug
ssddanbrown Nov 28, 2024
bc1f1d9
OIDC: Added extra userinfo content-type normalisation and test
ssddanbrown Nov 28, 2024
978acec
Merge branch 'oidc-content-type-issue' into development
ssddanbrown Nov 28, 2024
4630f07
Code: Set base codemirror line height
ssddanbrown Nov 29, 2024
e9f906c
Attachments: Fixed full range request handling
ssddanbrown Nov 29, 2024
f5ecd51
Updated translations with latest Crowdin changes (#5331)
ssddanbrown Nov 29, 2024
94165cc
Updated translator & dependency attribution before release v24.10.2
ssddanbrown Nov 29, 2024
fb9c840
Merge branch 'development' into release
ssddanbrown Nov 29, 2024
14056c6
Updated version and assets for release v24.10.2
ssddanbrown Nov 29, 2024
07e45a2
Updated version and assets for release v24.10.3
ssddanbrown Nov 29, 2024
c401952
Merge branch 'release' of https://github.com/BookStackApp/BookStack i…
paulhollmann Dec 17, 2024
197918d
Merge pull request #8 from vatger/BookStackApp-release
paulhollmann Dec 17, 2024
175d24b
.
paulhollmann Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .env.example.complete
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ EXPORT_PAGE_SIZE=a4
# Example: EXPORT_PDF_COMMAND="/scripts/convert.sh {input_html_path} {output_pdf_path}"
EXPORT_PDF_COMMAND=false

# Export PDF Command Timeout
# The number of seconds that the export PDF command will run before a timeout occurs.
# Only applies for the EXPORT_PDF_COMMAND option, not for DomPDF or wkhtmltopdf.
EXPORT_PDF_COMMAND_TIMEOUT=15

# Set path to wkhtmltopdf binary for PDF generation.
# Can be 'false' or a path path like: '/home/bins/wkhtmltopdf'
# When false, BookStack will attempt to find a wkhtmltopdf in the application
Expand Down
26 changes: 25 additions & 1 deletion .github/translators.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Kauê Sena (kaue.sena.ks) :: Portuguese, Brazilian
MatthieuParis :: French
Douradinho :: Portuguese, Brazilian; Portuguese
Gaku Yaguchi (tama11) :: Japanese
johnroyer :: Chinese Traditional
Zero Huang (johnroyer) :: Chinese Traditional
jackaaa :: Chinese Traditional
Irfan Hukama Arsyad (IrfanArsyad) :: Indonesian
Jeff Huang (s8321414) :: Chinese Traditional
Expand Down Expand Up @@ -431,3 +431,27 @@ Michal Melich (michalmelich) :: Czech
David (david-prv) :: German; German Informal
Larry (lahoje) :: Swedish
Marcia dos Santos (marciab80) :: Portuguese
Ricard López Torres (richilpez.torres) :: Catalan
sarahalves7 :: Portuguese, Brazilian
petr.husak :: Czech
javadataherian :: Persian
Ludo-code :: French
hollsten :: Swedish
Ngoc Lan Phung (lanpncz) :: Vietnamese
Worive :: Catalan
Илья Скаба (skabailya) :: Russian
Irjan Olsen (Irch) :: Norwegian Bokmal
Aleksandar Jovanovic (jovanoviczaleksandar) :: Serbian (Cyrillic)
Red (RedVortex) :: Hebrew
xgrug :: Chinese Simplified
HrCalmar :: Danish
Avishay Rapp (AvishayRapp) :: Hebrew
matthias4217 :: French
Berke BOYLU2 (berkeboylu2) :: Turkish
etwas7B :: German
Mohammed srhiri (m.sghiri20) :: Arabic
YongMin Kim (kym0118) :: Korean
Rivo Zängov (Eraser) :: Estonian
Francisco Rafael Fonseca (chicoraf) :: Portuguese, Brazilian
ИEØ_ΙΙØZ (NEO_IIOZ) :: Chinese Traditional
madnjpn (madnjpn.) :: Georgian
4 changes: 2 additions & 2 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ on:
jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Install NPM deps
run: npm ci
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: test-js

on:
push:
paths:
- '**.js'
- '**.ts'
- '**.json'
pull_request:
paths:
- '**.js'
- '**.ts'
- '**.json'

jobs:
build:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install NPM deps
run: npm ci

- name: Run TypeScript type checking
run: npm run ts:lint

- name: Run JavaScript tests
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/node_modules
/.vscode
/composer
/coverage
Homestead.yaml
.env
.idea
Expand Down Expand Up @@ -32,3 +33,4 @@ phpstan.neon
composer.lock
esbuild-meta.json
.phpactor.json
composer.lock
4 changes: 3 additions & 1 deletion app/Access/Oidc/OidcUserinfoResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class OidcUserinfoResponse implements ProvidesClaims

public function __construct(ResponseInterface $response, string $issuer, array $keys)
{
$contentType = $response->getHeader('Content-Type')[0];
$contentTypeHeaderValue = $response->getHeader('Content-Type')[0] ?? '';
$contentType = strtolower(trim(explode(';', $contentTypeHeaderValue, 2)[0]));

if ($contentType === 'application/json') {
$this->claims = json_decode($response->getBody()->getContents(), true);
}
Expand Down
10 changes: 10 additions & 0 deletions app/Access/UserInviteException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace BookStack\Access;

use Exception;

class UserInviteException extends Exception
{
//
}
8 changes: 7 additions & 1 deletion app/Access/UserInviteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ class UserInviteService extends UserTokenService
/**
* Send an invitation to a user to sign into BookStack
* Removes existing invitation tokens.
* @throws UserInviteException
*/
public function sendInvitation(User $user)
{
$this->deleteByUser($user);
$token = $this->createTokenForUser($user);
$user->notify(new UserInviteNotification($token));

try {
$user->notify(new UserInviteNotification($token));
} catch (\Exception $exception) {
throw new UserInviteException($exception->getMessage(), $exception->getCode(), $exception);
}
}
}
10 changes: 10 additions & 0 deletions app/App/MetaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ public function licenses()
'jsLibData' => file_get_contents(base_path('dev/licensing/js-library-licenses.txt')),
]);
}

/**
* Show the view for /opensearch.xml.
*/
public function opensearch()
{
return response()
->view('misc.opensearch')
->header('Content-Type', 'application/opensearchdescription+xml');
}
}
4 changes: 4 additions & 0 deletions app/Config/exports.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
// Example: EXPORT_PDF_COMMAND="/scripts/convert.sh {input_html_path} {output_pdf_path}"
'pdf_command' => env('EXPORT_PDF_COMMAND', false),

// The amount of time allowed for PDF generation command to run
// before the process times out and is stopped.
'pdf_command_timeout' => env('EXPORT_PDF_COMMAND_TIMEOUT', 15),

// 2024-04: Snappy/WKHTMLtoPDF now considered deprecated in regard to BookStack support.
'snappy' => [
'pdf_binary' => env('WKHTMLTOPDF', false),
Expand Down
7 changes: 7 additions & 0 deletions app/Console/Commands/UpdateUrlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function handle(Connection $db): int
'chapters' => ['description_html'],
'books' => ['description_html'],
'bookshelves' => ['description_html'],
'page_revisions' => ['html', 'text', 'markdown'],
'images' => ['url'],
'settings' => ['value'],
'comments' => ['html', 'text'],
Expand Down Expand Up @@ -77,6 +78,12 @@ public function handle(Connection $db): int
$this->info('URL update procedure complete.');
$this->info('============================================================================');
$this->info('Be sure to run "php artisan cache:clear" to clear any old URLs in the cache.');

if (!str_starts_with($newUrl, url('/'))) {
$this->warn('You still need to update your APP_URL env value. This is currently set to:');
$this->warn(url('/'));
}

$this->info('============================================================================');

return 0;
Expand Down
1 change: 1 addition & 0 deletions app/Entities/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace BookStack\Entities\Models;

use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Tools\PageEditorType;
use BookStack\Permissions\PermissionApplicator;
use BookStack\Uploads\Attachment;
use Illuminate\Database\Eloquent\Builder;
Expand Down
17 changes: 11 additions & 6 deletions app/Entities/Repos/PageRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use BookStack\Entities\Queries\EntityQueries;
use BookStack\Entities\Tools\BookContents;
use BookStack\Entities\Tools\PageContent;
use BookStack\Entities\Tools\PageEditorData;
use BookStack\Entities\Tools\PageEditorType;
use BookStack\Entities\Tools\TrashCan;
use BookStack\Exceptions\MoveOperationException;
use BookStack\Exceptions\PermissionsException;
Expand Down Expand Up @@ -43,6 +43,7 @@ public function getNewDraftPage(Entity $parent)
'owned_by' => user()->id,
'updated_by' => user()->id,
'draft' => true,
'editor' => PageEditorType::getSystemDefault()->value,
]);

if ($parent instanceof Chapter) {
Expand Down Expand Up @@ -127,7 +128,9 @@ protected function updateTemplateStatusAndContentFromInput(Page $page, array $in
}

$pageContent = new PageContent($page);
$currentEditor = $page->editor ?: PageEditorData::getSystemDefaultEditor();
$defaultEditor = PageEditorType::getSystemDefault();
$currentEditor = PageEditorType::forPage($page) ?: $defaultEditor;
$inputEditor = PageEditorType::fromRequestValue($input['editor'] ?? '') ?? $currentEditor;
$newEditor = $currentEditor;

$haveInput = isset($input['markdown']) || isset($input['html']);
Expand All @@ -136,15 +139,17 @@ protected function updateTemplateStatusAndContentFromInput(Page $page, array $in
if ($haveInput && $inputEmpty) {
$pageContent->setNewHTML('', user());
} elseif (!empty($input['markdown']) && is_string($input['markdown'])) {
$newEditor = 'markdown';
$newEditor = PageEditorType::Markdown;
$pageContent->setNewMarkdown($input['markdown'], user());
} elseif (isset($input['html'])) {
$newEditor = 'wysiwyg';
$newEditor = ($inputEditor->isHtmlBased() ? $inputEditor : null) ?? ($defaultEditor->isHtmlBased() ? $defaultEditor : null) ?? PageEditorType::WysiwygTinymce;
$pageContent->setNewHTML($input['html'], user());
}

if ($newEditor !== $currentEditor && userCan('editor-change')) {
$page->editor = $newEditor;
if (($newEditor !== $currentEditor || empty($page->editor)) && userCan('editor-change')) {
$page->editor = $newEditor->value;
} elseif (empty($page->editor)) {
$page->editor = $defaultEditor->value;
}
}

Expand Down
22 changes: 7 additions & 15 deletions app/Entities/Tools/PageEditorData.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ protected function build(): array
];
}

protected function updateContentForEditor(Page $page, string $editorType): void
protected function updateContentForEditor(Page $page, PageEditorType $editorType): void
{
$isHtml = !empty($page->html) && empty($page->markdown);

// HTML to markdown-clean conversion
if ($editorType === 'markdown' && $isHtml && $this->requestedEditor === 'markdown-clean') {
if ($editorType === PageEditorType::Markdown && $isHtml && $this->requestedEditor === 'markdown-clean') {
$page->markdown = (new HtmlToMarkdown($page->html))->convert();
}

// Markdown to HTML conversion if we don't have HTML
if ($editorType === 'wysiwyg' && !$isHtml) {
if ($editorType->isHtmlBased() && !$isHtml) {
$page->html = (new MarkdownToHtml($page->markdown))->convert();
}
}
Expand All @@ -94,24 +94,16 @@ protected function updateContentForEditor(Page $page, string $editorType): void
* Defaults based upon the current content of the page otherwise will fall back
* to system default but will take a requested type (if provided) if permissions allow.
*/
protected function getEditorType(Page $page): string
protected function getEditorType(Page $page): PageEditorType
{
$editorType = $page->editor ?: self::getSystemDefaultEditor();
$editorType = PageEditorType::forPage($page) ?: PageEditorType::getSystemDefault();

// Use requested editor if valid and if we have permission
$requestedType = explode('-', $this->requestedEditor)[0];
if (($requestedType === 'markdown' || $requestedType === 'wysiwyg') && userCan('editor-change')) {
$requestedType = PageEditorType::fromRequestValue($this->requestedEditor);
if ($requestedType && userCan('editor-change')) {
$editorType = $requestedType;
}

return $editorType;
}

/**
* Get the configured system default editor.
*/
public static function getSystemDefaultEditor(): string
{
return setting('app-editor') === 'markdown' ? 'markdown' : 'wysiwyg';
}
}
37 changes: 37 additions & 0 deletions app/Entities/Tools/PageEditorType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace BookStack\Entities\Tools;

use BookStack\Entities\Models\Page;

enum PageEditorType: string
{
case WysiwygTinymce = 'wysiwyg';
case WysiwygLexical = 'wysiwyg2024';
case Markdown = 'markdown';

public function isHtmlBased(): bool
{
return match ($this) {
self::WysiwygTinymce, self::WysiwygLexical => true,
self::Markdown => false,
};
}

public static function fromRequestValue(string $value): static|null
{
$editor = explode('-', $value)[0];
return static::tryFrom($editor);
}

public static function forPage(Page $page): static|null
{
return static::tryFrom($page->editor);
}

public static function getSystemDefault(): static
{
$setting = setting('app-editor');
return static::tryFrom($setting) ?? static::WysiwygTinymce;
}
}
4 changes: 2 additions & 2 deletions app/Entities/Tools/PageIncludeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ protected function splitTextNodesAtTags(DOMNode $textNode): array

if ($currentOffset < $tagStartOffset) {
$previousText = substr($text, $currentOffset, $tagStartOffset - $currentOffset);
$textNode->parentNode->insertBefore(new DOMText($previousText), $textNode);
$textNode->parentNode->insertBefore($this->doc->createTextNode($previousText), $textNode);
}

$node = $textNode->parentNode->insertBefore(new DOMText($tagOuterContent), $textNode);
$node = $textNode->parentNode->insertBefore($this->doc->createTextNode($tagOuterContent), $textNode);
$includeTags[] = new PageIncludeTag($tagInnerContent, $node);
$currentOffset = $tagStartOffset + strlen($tagOuterContent);
}
Expand Down
11 changes: 9 additions & 2 deletions app/Entities/Tools/PdfGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use BookStack\Exceptions\PdfExportException;
use Knp\Snappy\Pdf as SnappyPdf;
use Dompdf\Dompdf;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;

class PdfGenerator
Expand Down Expand Up @@ -85,9 +86,15 @@ protected function renderUsingCommand(string $html): string

file_put_contents($inputHtml, $html);

$timeout = intval(config('exports.pdf_command_timeout'));
$process = Process::fromShellCommandline($command);
$process->setTimeout(15);
$process->run();
$process->setTimeout($timeout);

try {
$process->run();
} catch (ProcessTimedOutException $e) {
throw new PdfExportException("PDF Export via command failed due to timeout at {$timeout} second(s)");
}

if (!$process->isSuccessful()) {
throw new PdfExportException("PDF Export via command failed with exit code {$process->getExitCode()}, stdout: {$process->getOutput()}, stderr: {$process->getErrorOutput()}");
Expand Down
2 changes: 1 addition & 1 deletion app/Http/RangeSupportedStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function parseRequest(Request $request): void
if ($start < 0 || $start > $end) {
$this->responseStatus = 416;
$this->responseHeaders['Content-Range'] = sprintf('bytes */%s', $this->fileSize);
} elseif ($end - $start < $this->fileSize - 1) {
} else {
$this->responseLength = $end < $this->fileSize ? $end - $start + 1 : -1;
$this->responseOffset = $start;
$this->responseStatus = 206;
Expand Down
Loading
Loading