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

feat: Introducing BBCode Data-Processor #158

Merged
merged 404 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
404 commits
Select commit Hold shift + click to select a range
b663cee
feat: Enrich Typings for BBob plugin-helper
mmichaelis Oct 19, 2023
c992629
chore: Ignore `null` Handling
mmichaelis Oct 19, 2023
f136299
feat: Intermediate "Paragraph Support" Preset
mmichaelis Oct 19, 2023
9753d6f
feat: Example Data for Paragraph Support
mmichaelis Oct 19, 2023
c1659c1
feat: Add Support For Paragraphs on Root
mmichaelis Oct 20, 2023
e286658
feat: Add Example for Paragraph Support
mmichaelis Oct 20, 2023
15a4192
refactor: Move ckeditor5Preset
mmichaelis Oct 20, 2023
15d864b
refactor: Clean Up Paragraphs Tooling
mmichaelis Oct 20, 2023
560ab01
Intermediate State
mmichaelis Oct 23, 2023
292f402
fix: Skip Empty Paragraphs
mmichaelis Oct 23, 2023
eb2b762
refactor: [code] tests as data-driven test.
mmichaelis Oct 23, 2023
1896f17
test: Security Checks
mmichaelis Oct 23, 2023
cc119b2
fix: Security Checks
mmichaelis Oct 23, 2023
2385724
fix: Paragraphs
mmichaelis Oct 23, 2023
03bbdcd
refactor: Remove Broad Escaping
mmichaelis Oct 23, 2023
b27bf41
chore: Remove Debug Output
mmichaelis Oct 24, 2023
ce80d0a
test: Just some documentation
mmichaelis Oct 24, 2023
d178aaa
test: Adjust Expectation for [quote]
mmichaelis Oct 24, 2023
a21cc49
chore: Cleanup
mmichaelis Oct 24, 2023
914f4c5
test: bbcode2html
mmichaelis Oct 24, 2023
176a9ba
test: Paragraph Support in ckeditor5Preset
mmichaelis Oct 24, 2023
4d99b9f
test: Some Attribute Challenge Tests
mmichaelis Oct 24, 2023
2fc70a7
feat: Escape HTML
mmichaelis Oct 24, 2023
bcfca6f
feat: Test And Adjust Attribute Sanitation
mmichaelis Oct 24, 2023
d0cca0d
fix(blocklist): Do not remove special characters but join the words w…
JensDallmann Oct 24, 2023
87b278e
test: Integration Test for Unique Attribute Behavior
mmichaelis Oct 25, 2023
944426e
fix: Typing for getUniqueAttr
mmichaelis Oct 25, 2023
6542c41
refactor: Unique Attribute Handling in HtmlSanitzer
mmichaelis Oct 25, 2023
83f2a6c
test: Broken Tests Due To Sanitizer
mmichaelis Oct 25, 2023
f6c20b8
test: More Possibly Broken Rendering Results
mmichaelis Oct 25, 2023
a15141a
feat: Mature Renderer-Typing Information (BBob)
mmichaelis Oct 25, 2023
81af7ca
refactor: Prefer Using Artificial Tag to Prevent Recursion
mmichaelis Oct 25, 2023
b192ae4
refactor: Adjust CoreRenderNode
mmichaelis Oct 25, 2023
67bbbac
refactor: Adjust pluginHelper Typings
mmichaelis Oct 25, 2023
a01c3fb
refactor: Adjust to TagNode.content === null
mmichaelis Oct 25, 2023
455d962
refactor: Adjust to TagNode.content === null
mmichaelis Oct 25, 2023
d7676fc
refactor: Adjust to TagNode.content === null
mmichaelis Oct 25, 2023
462bbcf
refactor: Replace Renderer
mmichaelis Oct 25, 2023
a5cd4ad
fix: Workaround for Jest@Windows Issue
mmichaelis Oct 26, 2023
a730eba
refactor: Use HTML DOM for Rendering HTML
mmichaelis Oct 26, 2023
ef7c3ac
chore: Update pnpm-lock.yaml
mmichaelis Oct 26, 2023
595ddd3
fixup! refactor: Use HTML DOM for Rendering HTML
mmichaelis Oct 26, 2023
2818cc0
test: An Additional XSS Test
mmichaelis Oct 27, 2023
e0f7c0a
refactor: Extract "AttributeGuard"
mmichaelis Oct 27, 2023
db25c90
fix: Relative URL toData Processing
mmichaelis Oct 27, 2023
5de4720
fix(blocklist): Show all selected blocked words for expanded selections.
JensDallmann Nov 1, 2023
634fbeb
fix(blocklist): Open balloon only for collapsed selections when click…
JensDallmann Nov 1, 2023
c722906
refactor: Simplify BBCode Processing
mmichaelis Nov 1, 2023
6dbd809
docs: Security Considerations
mmichaelis Nov 1, 2023
1c50f96
test: Remove "on*" Handler Tests
mmichaelis Nov 1, 2023
95eca0e
test: Adjust Expectations
mmichaelis Nov 1, 2023
09c46d7
chore: Remove Debugging Outputs
mmichaelis Nov 1, 2023
8233fbc
test: Testing Attributes Utilities
mmichaelis Nov 2, 2023
3b84b3c
test: Adapt CKEditor 5 Preset Test to Flawed Unique Attr. Behavior
mmichaelis Nov 2, 2023
763f686
refactor: Fix Broken Example Data
mmichaelis Nov 2, 2023
65c53d6
test: bbcode2html
mmichaelis Nov 2, 2023
337118e
test: bbcode2html
mmichaelis Nov 2, 2023
958ab0e
feat: More Code-Block Examples
mmichaelis Nov 2, 2023
df839b2
fix: Code-Blocks Must Not be Wrapped by Paragraphs
mmichaelis Nov 2, 2023
30477ad
fix: EOL Trimming
mmichaelis Nov 2, 2023
7633535
fix: Adjust Test Expectations
mmichaelis Nov 2, 2023
6947e35
refactor: Add Guard for Debug Logging
mmichaelis Nov 2, 2023
c8dea23
refactor: Add Debug Logging to Rendering
mmichaelis Nov 2, 2023
c312669
refactor: Add Debug Logging to BBCode Processing
mmichaelis Nov 2, 2023
6b4309c
refactor: Remove "Code Formatting" Example
mmichaelis Nov 2, 2023
5b87e6c
docs: Enhance README.md for BBCode
mmichaelis Nov 2, 2023
e4f70e8
fix: Fix Babel Configuration
mmichaelis Nov 2, 2023
e7e7ee3
chore: Update pnpm-lock.yaml
mmichaelis Nov 2, 2023
dae75b9
fix: CodeQL:js/polynomial-redos
mmichaelis Nov 3, 2023
285b8ff
refactor: Remove Obsolete File
mmichaelis Nov 3, 2023
5c5f974
chore: Activate ESLint consistent-return
mmichaelis Nov 3, 2023
9431ec8
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
9493f75
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
c242679
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
fe4fa88
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
59b5ca7
fix: Address Linter Issues
mmichaelis Nov 3, 2023
e15493a
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
c756323
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
915cf61
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
130f789
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
5f5c7b5
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
e1ec829
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
1cfedda
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
420c08f
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
10f1101
fix: Typo
mmichaelis Nov 3, 2023
5ba47e9
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
da49eb6
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
70525e9
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
5cc8141
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
0a1a93d
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
4015d0a
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
898a695
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
dd3c357
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
ab9fdcf
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
76a3cc0
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
566fc82
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
8afa4c4
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
272a501
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
54165d5
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
83e74c1
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
5f70388
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
b92a5eb
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
300910d
fix: ESLint/consistent-return
mmichaelis Nov 3, 2023
0cac455
fix: CodeQL:js/polynomial-redos
mmichaelis Nov 3, 2023
0890745
test(blocklist): Add class to allocate the button in playwright test
JensDallmann Nov 1, 2023
18a8e73
test(blocklist): Add tests for balloon behavior with collapsed/expand…
JensDallmann Nov 1, 2023
bb5da09
fix(blocklist): Show selected block words if balloon is opened with k…
JensDallmann Nov 1, 2023
788bc80
fix(blocklist): Remove superfluous line.
JensDallmann Nov 2, 2023
8549bf0
chore(blocklist): Extract method
JensDallmann Nov 3, 2023
cb51ac0
test: Fix Typo in Test Name
mmichaelis Nov 3, 2023
fabd883
test: [quote]
mmichaelis Nov 3, 2023
1630084
fix(blocklist): Reduce risk of running into trouble with marker name …
JensDallmann Nov 3, 2023
a07bc50
refactor: [s]
mmichaelis Nov 6, 2023
1680cc7
refactor: [u]
mmichaelis Nov 6, 2023
c39cfb7
fix(blocklist): Set max-width and show ellipsis for words which are t…
JensDallmann Nov 6, 2023
59daae7
test: Additional Tests for XSS Attack Vectors
mmichaelis Nov 7, 2023
20a7d6a
feat: Add URL Example Data
mmichaelis Nov 7, 2023
b94ed65
refactor: Extract URL Escaping
mmichaelis Nov 7, 2023
955d1f3
refactor: Extract parseAsFragment
mmichaelis Nov 7, 2023
f32703a
test: Test for "Known Issues"
mmichaelis Nov 7, 2023
5733e60
test: Test toData Mapping of `[url]`
mmichaelis Nov 7, 2023
e25c5b4
test: toData Integration Test for html2bbcode
mmichaelis Nov 7, 2023
7d865aa
docs: Reference BBob Issue Regarding `htmlCode` Workaround
mmichaelis Nov 7, 2023
60513a2
Merge pull request #170 from CoreMedia/fix/blocklist-special-characte…
JensDallmann Nov 7, 2023
68abc17
fix(blocklist): Fix import
JensDallmann Nov 7, 2023
09bd55c
fix(blocklist): Fix linter
JensDallmann Nov 7, 2023
dca122a
fix(blocklist): Fix import
JensDallmann Nov 7, 2023
a62874b
test(bbcode): Add a smoketest for bbcode
JensDallmann Nov 7, 2023
11cd9df
refactor: Harden URL toData Transformation
mmichaelis Nov 7, 2023
646f3a8
feat: Pave `[img]` support
mmichaelis Nov 7, 2023
cc65c85
feat: Add BBCode Image Support to App
mmichaelis Nov 7, 2023
cbf761e
chore: Update pnpm-lock.yaml
mmichaelis Nov 7, 2023
8b528ad
feat: Example Data for [img] Tag
mmichaelis Nov 8, 2023
8cd5897
test: [img] for bbcode2html
mmichaelis Nov 8, 2023
97f04bb
test: [img] for html2bbcode
mmichaelis Nov 8, 2023
3582bc3
docs: [img] Tag README.md Update
mmichaelis Nov 8, 2023
8743a1d
refactor: Switch to Inline Image for [img]
mmichaelis Nov 8, 2023
40b46f0
refactor: Switch to Inline Image for [img]
mmichaelis Nov 8, 2023
10876e6
docs: Document CKEditor 5 Plugin Requirements
mmichaelis Nov 8, 2023
d87286b
test: [img] via BBCodeImg
mmichaelis Nov 8, 2023
261c1fd
feat: Enable Font Size Selection
mmichaelis Nov 8, 2023
7ab560c
feat: Extend Font Size Selection By "default"
mmichaelis Nov 8, 2023
b29bbac
feat: Add `[size]` in toData Mapping
mmichaelis Nov 8, 2023
dbe3af3
refactor: Extract first TagNodes Utility
mmichaelis Nov 9, 2023
b4fcf62
refactor: Extract [code] mapping to function
mmichaelis Nov 9, 2023
f7f8666
refactor: Extract [quote] mapping to function
mmichaelis Nov 9, 2023
15e62fb
refactor: Extract artificial htmlCode mapping to function
mmichaelis Nov 9, 2023
c9aaa9b
refactor: Extract [url] mapping to function
mmichaelis Nov 9, 2023
efc6455
refactor: Extract [img] mapping to function
mmichaelis Nov 9, 2023
8c109b4
refactor: Extract mapping of paragraphAwareTags to function
mmichaelis Nov 9, 2023
c19bfae
feat: Rework and Finish Font Size Mapping
mmichaelis Nov 9, 2023
29994af
docs: Summarized BBCode Overview
mmichaelis Nov 10, 2023
5d7f7dd
fix: Misplaced BBCode Overview
mmichaelis Nov 10, 2023
09b1a7b
docs: Add Sections for Paragraphs and Escaping
mmichaelis Nov 10, 2023
f9cf4a3
test: ckeditor5Preset Tests for [size]
mmichaelis Nov 15, 2023
f32bc1f
test: BBCodeSize Tests for [size]
mmichaelis Nov 16, 2023
5569fa5
test: Fix Bug in DDT Description
mmichaelis Nov 16, 2023
d40c1f0
test: bbcode2html test for [size]
mmichaelis Nov 16, 2023
205a87c
test: html2bbcode test for [size]
mmichaelis Nov 16, 2023
75262fd
test: BBobIntegration: Add Description
mmichaelis Nov 16, 2023
186c320
test: BBobIntegration test for [size]
mmichaelis Nov 16, 2023
dd58330
test: Document Test Layers
mmichaelis Nov 16, 2023
49f1c9a
feat: Demo Data for [size]
mmichaelis Nov 16, 2023
48c5485
docs: [size] Integration
mmichaelis Nov 16, 2023
304f8ef
refactor: [color] DevDoc
mmichaelis Nov 16, 2023
cf7e7b5
refactor: [color] Examples
mmichaelis Nov 16, 2023
65e7ad2
refactor: [h1] et al.: Get Rid of BBCode Generator
mmichaelis Nov 16, 2023
1c6e1c8
refactor: [url] Example Adaptations
mmichaelis Nov 16, 2023
af1e2ac
refactor: BBCode Example Welcome Text
mmichaelis Nov 16, 2023
5e389c0
feat: Enable Error Handling
mmichaelis Nov 16, 2023
540478b
feat: Update Security Challenge Data
mmichaelis Nov 16, 2023
fef9854
refactor: Delete Obsolete BBCode Factory
mmichaelis Nov 16, 2023
44552ae
refactor: Remove [table] Support
mmichaelis Nov 16, 2023
67174ea
chore: Fix Typo
mmichaelis Nov 17, 2023
366e7f3
docs: Tune TSDoc
mmichaelis Nov 17, 2023
2e7b46d
docs: Fix Unresolvable References to CKEditor 5 API
mmichaelis Nov 17, 2023
13326f9
docs: Fix Unresolvable Reference to CKEditor 5 API
mmichaelis Nov 17, 2023
823824d
docs: Merge BBCode Specification
mmichaelis Nov 17, 2023
8f46d56
docs: TypeDoc ckeditor5-common
mmichaelis Nov 17, 2023
8304756
docs: Tune Documentation for Data Facade
mmichaelis Nov 17, 2023
6f9dfe2
docs: Rework Blocklist Documentation
mmichaelis Nov 17, 2023
7e17abd
fix: Make BlocklistCommand Work in R/O Editor
mmichaelis Nov 20, 2023
d7f0580
feat: Extend Main README.md
mmichaelis Nov 20, 2023
251b45f
chore: Apply Linter Fixes
mmichaelis Nov 20, 2023
553b5ae
chore: Apply Linter Fixes
mmichaelis Nov 20, 2023
46d9bdc
chore: Apply Linter Fixes
mmichaelis Nov 20, 2023
6c56423
chore: Add author information
mmichaelis Nov 21, 2023
af68c83
chore: Extend author information by "email"
mmichaelis Nov 21, 2023
eb7321e
test: Explicitly Test Escaping Behavior
mmichaelis Nov 23, 2023
6e788b4
docs: Add Reference to data-facade
mmichaelis Nov 28, 2023
d3de358
docs: Prefer index.ts
mmichaelis Nov 28, 2023
4293cae
refactor: Move BlocklistService
mmichaelis Nov 28, 2023
87dec4a
ci: New "List Packages"
mmichaelis Nov 29, 2023
1eee18e
chore: Update .gitignore
mmichaelis Nov 29, 2023
db1106e
chore: Reduce Package Size
mmichaelis Nov 29, 2023
ff4bc26
chore: Reduce Package Size
mmichaelis Nov 29, 2023
54b5b2e
chore: Reduce Package Size
mmichaelis Nov 29, 2023
85cc088
chore: Reduce Package Size
mmichaelis Nov 29, 2023
196dccd
chore: Reduce Package Size
mmichaelis Nov 29, 2023
1583962
chore: Reduce Package Size
mmichaelis Nov 29, 2023
807cdb3
chore: Reduce Package Size
mmichaelis Nov 29, 2023
b44ccd2
chore: Reduce Package Size
mmichaelis Nov 29, 2023
dcaaf91
chore: Reduce Package Size
mmichaelis Nov 29, 2023
be87aa1
chore: Reduce Package Size
mmichaelis Nov 29, 2023
6dc0163
chore: Reduce Package Size
mmichaelis Nov 29, 2023
eed66ad
chore: Reduce Package Size
mmichaelis Nov 29, 2023
f2eb440
chore: Reduce Package Size
mmichaelis Nov 29, 2023
aa6fb50
chore: Reduce Package Size
mmichaelis Nov 29, 2023
2cb4c78
chore: Reduce Package Size
mmichaelis Nov 29, 2023
115c01d
chore: Reduce Package Size
mmichaelis Nov 29, 2023
9ecd014
chore: Reduce Package Size
mmichaelis Nov 29, 2023
8c149bd
chore: Reduce Package Size
mmichaelis Nov 29, 2023
6f194ca
chore: Reduce Package Size
mmichaelis Nov 29, 2023
9f42c87
chore: Reduce Package Size
mmichaelis Nov 29, 2023
e0c6c4b
chore: Reduce Package Size
mmichaelis Nov 29, 2023
f978f3b
chore: Reduce Package Size
mmichaelis Nov 29, 2023
1298ba6
docs: Document relation fromClass/isUnset
mmichaelis Nov 29, 2023
1fb2d0e
ci: Proof-of-Concept Package Listing
mmichaelis Nov 29, 2023
48e1559
ci: Fix Secrets Inheritance
mmichaelis Nov 29, 2023
38ce39f
ci: Fix env.yml
mmichaelis Nov 29, 2023
fd5a3d6
ci: Fix env.yml
mmichaelis Nov 29, 2023
0c1c50d
ci: Experiment to Propagate Secret
mmichaelis Nov 29, 2023
2742b26
ci: Experiment to Propagate Secret
mmichaelis Nov 29, 2023
7303ac8
ci: Experiment to Propagate Secret
mmichaelis Nov 29, 2023
84069ec
ci: Experiment to Propagate Secret
mmichaelis Nov 29, 2023
21a69e8
ci: Giving Up Regarding Authorization
mmichaelis Nov 29, 2023
88a9911
ci: Read Permission Should Be Enough
mmichaelis Nov 29, 2023
acf804b
ci: Next Refactoring For Authorization
mmichaelis Nov 29, 2023
16a30c4
ci: Fix --registry Reference
mmichaelis Nov 29, 2023
413b70d
ci: No Types Anymore
mmichaelis Nov 29, 2023
7d7b3cd
ci: Add Latest Version
mmichaelis Nov 29, 2023
6dcb8f6
ci: Show Recent Versions
mmichaelis Nov 29, 2023
9b54225
ci: Missed Adding Registry Reference
mmichaelis Nov 29, 2023
ab6b59c
ci: Limit Package Search to ckeditor5
mmichaelis Nov 29, 2023
4b1d752
ci: Add Search Limit
mmichaelis Nov 29, 2023
af59dda
ci: Add Warning if Search Limit Reached
mmichaelis Nov 29, 2023
2b64258
ci: Warning Did Not Trigger - Adapt
mmichaelis Nov 29, 2023
8c593c7
ci: Missed Warning Output to Summary
mmichaelis Nov 29, 2023
d251ace
ci: Add Search Limit To Inputs
mmichaelis Nov 29, 2023
e93449c
ci: Try Fixing SearchLimit
mmichaelis Nov 29, 2023
2b8b35b
ci: Use New "List Packages"
mmichaelis Nov 29, 2023
574e7ad
ci: Fix Semantic Versioning For Pre-Release
mmichaelis Nov 29, 2023
941ed6e
build: Optimize PNPM Check
mmichaelis Nov 30, 2023
9a2e970
ci: Add version handling as script
mmichaelis Nov 30, 2023
bf187dd
chore: Update pnpm-lock.yaml
mmichaelis Nov 30, 2023
ad8e9ad
ci: Use "version" script
mmichaelis Nov 30, 2023
c370215
fix: Add /theme to "files" for blocklist plugin
mmichaelis Dec 1, 2023
e898658
test: (Failing) Test for CRLF, CR and Paragraph Support
mmichaelis Dec 5, 2023
9bb8b12
fix: Normalize BBCode to LF line-separators
mmichaelis Dec 5, 2023
3a197e7
fix: Remove Table Plugins #bbcode
mmichaelis Dec 6, 2023
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
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@ckeditor/ckeditor5-ui": "39.0.2",
"@ckeditor/ckeditor5-utils": "39.0.2",
"@coremedia-internal/ckeditor5-coremedia-example-data": "^1.0.0",
"@coremedia/ckeditor5-coremedia-bbcode": "16.0.1-rc.2",
"@coremedia/ckeditor5-coremedia-blocklist": "16.0.1-rc.2",
"@coremedia/ckeditor5-coremedia-content-clipboard": "16.0.1-rc.2",
"@coremedia/ckeditor5-coremedia-differencing": "16.0.1-rc.2",
Expand All @@ -45,6 +46,7 @@
"@coremedia/ckeditor5-coremedia-richtext": "16.0.1-rc.2",
"@coremedia/ckeditor5-coremedia-studio-essentials": "16.0.1-rc.2",
"@coremedia/ckeditor5-coremedia-studio-integration-mock": "16.0.1-rc.2",
"@coremedia/ckeditor5-data-facade": "16.0.1-rc.2",
"@coremedia/ckeditor5-dataprocessor-support": "16.0.1-rc.2",
"@coremedia/ckeditor5-dom-converter": "16.0.1-rc.2",
"@coremedia/ckeditor5-font-mapper": "16.0.1-rc.2",
Expand Down
86 changes: 18 additions & 68 deletions app/sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,32 @@
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="coremedia.css">
<!--
Unfortunately it was not possible to simply import the CKEditorInspector in the ts file.
The CKEditorInspector was always undefined. This way it works, and it is fine for an example application.
Unfortunately, it was impossible to simply import the CKEditorInspector in
the ts file. The CKEditorInspector was always undefined. This way it works,
and it is fine for an example application.
-->
<script src="../node_modules/@ckeditor/ckeditor5-inspector/build/inspector.js"></script>
</head>
<body data-editor="ClassicEditor" data-collaboration="false">

<div id="notifications"></div>

<header>
<div id="notifications">
<!-- Place to render notifications like "open in tab" -->
</div>
<div class="centered">
<h1><a href="https://ckeditor.com/ckeditor-5/" target="_blank" rel="noopener noreferrer"><img
src="https://c.cksource.com/a/1/logos/ckeditor5.svg" alt="CKEditor 5 logo">CKEditor 5</a></h1>
src="https://c.cksource.com/a/1/logos/ckeditor5.svg" alt="CKEditor 5 logo">CKEditor 5</a></h1>
<nav>
<ul>
<li><a href="https://ckeditor.com/docs/ckeditor5/" target="_blank" rel="noopener noreferrer">Documentation</a>
</li>
<li><a href="https://ckeditor.com/" target="_blank" rel="noopener noreferrer">Website</a></li>
<li><a href=".?#ckdebug=verbose" rel="noopener noreferrer" id="debug">Debug Logging</a></li>
<li>Language: <a href="." rel="noopener noreferrer" id="lang" title="Switch language of editor UI."
style="font-weight: initial;"></a></li>
</ul>
</nav>
</div>
<div id="examples">
<label for="xmp-input">
Example Data:
</label>
<input id="xmp-input"
list="xmp-data"
placeholder="Start typing..."
autocomplete="on"
>
<datalist id="xmp-data">
<!-- Will be filled from example-data.ts -->
</datalist>
<button id="xmp-reload" title="Reload">🔄</button>
<button id="xmp-clear" title="Clear">🚮</button>
<!-- Place to render example selection combobox to. -->
</div>
</header>

Expand All @@ -56,70 +44,32 @@ <h2>CKEditor 5: CoreMedia Plugin Showcase</h2>
</div>
</div>
<div class="centered">
<div>
<button id="readOnlyMode" title="Delay Modifiers: Ctrl/Cmd: 10s, Shift: 60s, Ctrl/Cmd+Shift: 120s">Enable Read-Only-Mode</button>
<button id="previewButton">Show XML Preview</button>
<div id="applicationToolbar">
<button id="inputExampleContentButton">Show Input Example Content</button>
</div>

<div id="inputExampleContentDiv" hidden="hidden">
<!-- The Drag Examples will be generated here. -->
</div>
<div class="row">

<div id="defaultEditorRow" class="row editor-row">
<div class="row-editor">
<!-- RichText Editor Starts Here. Content is initial content to display on load. -->
<!-- The data inside are given in data-format of CKEditor, which is CoreMedia RichText 1.0. -->
<div id="editor"></div>
<div id="preview" class="preview hidden" hidden></div>
<div id="preview">
<!-- The preview displaying the "stored data" will be rendered here. -->
</div>
</div>
</div>
</div>
</main>

<footer>
<p>Copyright © 2020-2022,
<p>Copyright © 2020-2023,
<a href="https://www.coremedia.com/" target="_blank" rel="noopener">CoreMedia</a>
</p>
</footer>
<script>
const loadTranslations = (locale) => {
if (locale === "en") {
console.log("Default locale. No need to load further resources.");
} else {
const scriptEl = document.createElement("script");
scriptEl.src = "../dist/translations/" + locale + ".js";
document.body.appendChild(scriptEl);
}
};

const loadCKEditor = (locale) => {
const scriptEl = document.createElement("script");
scriptEl.src = "../dist/ckeditor.js";
scriptEl.dataset["lang"] = locale;
document.body.appendChild(scriptEl);
};

const initLanguage = () => {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const languageFlag = 'lang';
const language = urlParams.get(languageFlag)?.toLowerCase() || 'en';
const languageToggle = document.getElementById(languageFlag);
let label, hrefLang;
if (language === "de") {
label = "EN | <strong>DE</strong>";
hrefLang = "en";
} else {
label = "<strong>EN</strong> | DE";
hrefLang = "de";
}
languageToggle.setAttribute("href", `.?lang=${hrefLang}`);
languageToggle.innerHTML = label;
return language;
};

const lang = initLanguage();
loadCKEditor(lang);
loadTranslations(lang);
</script>
<script src="../dist/translations/de.js"></script>
<script src="../dist/ckeditor.js"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions app/sample/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ input.error {

/* --------- PREVIEW STYLES ---------------------------------------------------------------------------------------- */
.preview {
display: inline-block;
display: none;
vertical-align: top;
background-color: white;
padding: 2px 2em;
Expand All @@ -114,8 +114,8 @@ input.error {
min-height: calc(var(--ck-sample-editor-min-height) + 38.67px);
}

.preview.hidden {
display: none;
.with-preview .preview {
display: inline-block;
}

#input-examples.hidden {
Expand Down Expand Up @@ -159,7 +159,7 @@ main .ck-editor[role='application'] .ck.ck-content,
padding: 1.5em 2em;
}

.ck.ck-editor.with-preview {
.with-preview .ck.ck-editor {
display: inline-block;
vertical-align: top;
width: calc(50% - 8px) !important;
Expand Down
106 changes: 106 additions & 0 deletions app/src/ApplicationState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { setHashParam } from "./HashParams";

// Keeping the following values in line with corresponding switch-buttons helps
// to ease the integration. We may also refactor this to some more explicit
// reusable set of types to choose from.

export type InspectorState = "expanded" | "collapsed";
export type CompatibilityMode = "v10" | "latest";
export type DataType = "richtext" | "bbcode";
export type UiLanguage = "en" | "de";
export type ReadOnlyMode = "rw" | "ro";
export type PreviewState = "hidden" | "visible";

export class ApplicationState {
/**
* Language for CKEditor 5 UI.
*/
readonly #uiLanguage: UiLanguage;
/**
* Signals, if to open the inspector expanded or collapsed by default.
*/
readonly #inspector: InspectorState;
/**
* Plugin version compatibility mode to apply.
*
* * `v10`: Up to version 10 we provided different data-processing for
* CoreMedia Rich Text.
* * `latest`: Just assume the latest plugin version.
*/
readonly #compatibility: CompatibilityMode;
/**
* The data type to support.
*/
readonly #dataType: DataType;
#readOnlyMode: ReadOnlyMode;
#previewState: PreviewState;

constructor(config?: Map<string, string | boolean>) {
const uiLanguage = config?.get("uiLanguage") ?? "en";
const inspector = config?.get("inspector") ?? "collapsed";
const compatibility = config?.get("compatibility") ?? "latest";
const dataType = config?.get("dataType") ?? "richtext";
const readOnly = config?.get("readOnly") ?? false;
const showPreview = config?.get("showPreview") ?? false;

this.#uiLanguage = typeof uiLanguage === "string" && uiLanguage.toLowerCase() === "de" ? "de" : "en";
this.#inspector =
typeof inspector === "string" && inspector.toLowerCase() === "expanded" ? "expanded" : "collapsed";
this.#compatibility = typeof compatibility === "string" && compatibility.toLowerCase() === "v10" ? "v10" : "latest";
this.#dataType = typeof dataType === "string" && dataType.toLowerCase() === "bbcode" ? "bbcode" : "richtext";
this.#readOnlyMode = typeof readOnly === "boolean" && readOnly ? "ro" : "rw";
this.#previewState = typeof showPreview === "boolean" && showPreview ? "visible" : "hidden";
}

get uiLanguage(): UiLanguage {
return this.#uiLanguage;
}

set uiLanguage(language: UiLanguage) {
if (language !== this.#uiLanguage) {
setHashParam("uiLanguage", language, true);
}
}

get inspector(): InspectorState {
return this.#inspector;
}

get compatibility(): CompatibilityMode {
return this.#compatibility;
}

set compatibility(mode) {
if (this.#compatibility !== mode) {
setHashParam("compatibility", mode, true);
}
}

get dataType(): DataType {
return this.#dataType;
}

set dataType(dataType) {
if (this.#dataType !== dataType) {
setHashParam("dataType", dataType, true);
}
}

get readOnlyMode(): ReadOnlyMode {
return this.#readOnlyMode;
}

set readOnlyMode(mode) {
this.#readOnlyMode = mode;
setHashParam("readOnly", mode === "ro");
}

get previewState(): PreviewState {
return this.#previewState;
}

set previewState(state) {
this.#previewState = state;
setHashParam("showPreview", state === "visible");
}
}
20 changes: 20 additions & 0 deletions app/src/ApplicationToolbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const defaultApplicationToolbarId = "applicationToolbar";

export interface ApplicationToolbarConfig {
/**
* ID of toolbar button to add the preview button to.
* Defaults to: `applicationToolbar`.
*/
toolbarId?: string;
}

export const requireApplicationToolbar = (config?: ApplicationToolbarConfig): HTMLElement => {
const { toolbarId = defaultApplicationToolbarId } = config ?? {};
const toolbar = document.getElementById(toolbarId);

if (!toolbar) {
throw new Error(`Cannot find toolbar element having ID "${toolbarId}".`);
}

return toolbar;
};
4 changes: 4 additions & 0 deletions app/src/CKEditorInstanceFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ApplicationState } from "./ApplicationState";
import { ClassicEditor } from "@ckeditor/ckeditor5-editor-classic";

export type CKEditorInstanceFactory = (sourceElement: HTMLElement, state: ApplicationState) => Promise<ClassicEditor>;
18 changes: 18 additions & 0 deletions app/src/DataFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { default as formatXml } from "xml-formatter";

export type DataFormatter = (data: string, empty?: string) => string;

export const dataFormatter: {
xml: DataFormatter;
text: DataFormatter;
} = {
xml: (data, empty) =>
data
? formatXml(data, {
indentation: " ",
collapseContent: false,
whiteSpaceAtEndOfSelfclosingTag: true,
})
: empty ?? "",
text: (data, empty) => (data ? data : empty ?? ""),
};
16 changes: 16 additions & 0 deletions app/src/DataTypeSwitch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SwitchButton, SwitchButtonConfig } from "./SwitchButton";

export const dataTypes = {
["richtext" as const]: "Rich Text",
["bbcode" as const]: "BBCode",
};

export const initDataTypeSwitch = (config: SwitchButtonConfig<keyof typeof dataTypes>): void => {
new SwitchButton({
id: "dataTypeSwitch",
default: "richtext",
states: dataTypes,
label: "Data Type",
...config,
}).init();
};
Loading