-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmichaelis
force-pushed
the
feature/bbcode-dataprocessor
branch
from
September 12, 2023 13:02
ffb5c77
to
3abd876
Compare
mmichaelis
force-pushed
the
feature/bbcode-dataprocessor
branch
from
October 2, 2023 06:11
3786b04
to
b776872
Compare
Similar to DOM-Support, we require to deal with `null` again and again as it is part of the BBob API. Thus, decided to skip these linter checks.
This is an intermediate commit to show the working paragraph support at least for nested block-elements. Still missing is support on root- level and of course a lot of clean-up.
To be able to process paragraphs on root-level we need to create an artificial root-node to be processed within configured default-tags. There may be other options, like adding a paragraph-support plugin, that runs after the HTML5 preset. But the current solution also fixes an issue with the default `quote` processing of BBob HTML5 Preset: By default, it just wraps any content into a single paragraph not respecting, that in a valid HTML5 structure, a paragraph must not contain other block-level elements. As alternative, we can now use the new "intelligent paragraph processing" also on this level already, instead of having to devour the results of the HTML5 preset (which even may change with more recent BBob versions).
Bundling all hard-wired BBob-dependent artifacts into an extra folder.
Some documentation and removing debugging output.
One of the original tests for BBob HTML5 Preset (we copied them, to ensure, we are consistent with the original mapping), added spaces in front of a list. These extra spaces triggered creation of a paragraph node containing only these _indent spaces_. Decided to introduce a `skipEmpty` option, that is enabled by default. This will prevent the creation of paragraphs, that are empty - also trimming any blanks prior to this check.
First sketch for some security related checks on high integration layer (thus, testing `bbcode2html` as facade to BBob).
Small sanitizer, that removes any `on` attributes.
Respect `requireParagraph` even if to skip empty.
A broad escaping may do harm to the BBCode. Instead, if handling HTML characters is required it should be done in corresponding environment (thus, different for element content compared to attribute content).
For new rendering we skip final newlines in paragraph (BBCode to data view). Adapting expectations accordingly.
Next trying to set an actions secret.
Set required GitHub Token.
Next try to get it going. For `gh` we need our repository. Thus, checkout first.
Failed for now to pass authorization token from a called workflow.
Must be URL, not host.
Removing list of types. Not relevant.
searchLimit defaults to 20 if unset, thus, we may miss some packages if unset. see-also: <https://docs.npmjs.com/cli/v6/using-npm/config#searchlimit> see-also: <https://stackoverflow.com/questions/47308559/why-does-npm-search-provide-incomplete-results>
And as probe, reduce again to the default search limit 20.
Trying with defensive comparison, if the used bash version does not support arithmetic contexts.
For some reason, the default did not work. See-also: <https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callinputs>
Using "delegate"
There is a strict specification for pre-release versions. Previous template `<mj>.<mn>.<p>-pr<pr>-<run>.0` violated this pattern and may irritate parsing and ordering semantic versions. The new template aligns with the standards, so that, for example, a previous pre-release version: 16.0.1-pr158-717.0 is now generated as: 16.0.1-pr.158.717.0 See-also: <https://semver.org/>
Prefer check via local script over npx --yes only-allow pnpm For a no-op install this boosts runtime from 7.2s to 1.5s (as one example).
To reduce GitHub actions load (and as part of some debugging), providing a Node.js script to deal with versions.
Instead of dealing with version increments at several GitHub actions, we now prefer using a dedicated script. This also spares installing `semver` and it provides the option to validate the process in local runs.
Missed adding the theme folder.
As it seems, our implementation cannot handle CRLF inputs (Windows) as well as CR (some older systems, like classic MacOS). This test demonstrate it and should be fixed.
BBob only supports parsing of BBCode having Unix (LF) line-separators. Thus, added pre-processing for this behavior. An additional integration test will tell us, if BBob changes the behavior here, which may trigger removing this normalization.
As decided, we will not support tables for BBCode up to now (due to several challenges regarding the CKEditor 5 table-handling). Because of that, also removing the Table Plugins from example application.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature:bbcode
BBCode Data-Processor
release:minor
Suggests a minor release (x.X.x)
type:feature
New Feature or Request
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Features 🎉
BBCode Data Processor
The new module
@coremedia/ckeditor5-bbcode
provides a plugin for editing data available as BBCode.As each BBCode is vendor specific (with some standards most agree upon), this plugin will also come with its own BBCode specification. The specification is mostly based on commonly agreed standards (for example, see Wikipedia (en)).
Find the full specification, including specifications for paragraph support and escaping in the module description.
RgbColor
andCSSStyleDeclarations
Module
@coremedia/ckeditor5-dom-support
ships with two new utilities. They are dedicated (for now) to handling (text) colors. While introduced for BBCode parsing, they may be of more general use.Main Usage Example
The following example for
getColor
fromCSSStyleDeclarations
forwards toRgbColor
internally, when there is somergb()
orrgba()
code to parse.getColor
fuchsia
fuchsia
transparent
orcurrentcolor
are returned as is.rgb(1, 2, 3)
RgbColor
rgba(1, 2, 3, 0.5)
RgbColor
Note that there is no need for parsing other color format styles, as
CSSStyleDeclaration
transforms all color codes (thus, no color names) to eitherrgb()
orrgba()
internally.RgbColor
is then able to provide different representations of the parsed color either asrgb()
,rgba()
, as hex value or as hex-with-alpha (hexa) value.The following table demonstrates different representations for a parsed
rgba(128, 128, 128, 0.5)
value:rgb
rgb(128, 128, 128)
rgba
rgba(128, 128, 128, 0.5)
toRgb()
rgba(128, 128, 128, 0.5)
rgba
andrgb
depending on if alpha channel is set or not.hex
#808080
hexa
#8080807f
toHex()
#8080807f
hexa
andhex
depending on if alpha channel is set or not.BBCode Usage
For BBCode, we use it for supporting
[color=#808080]
in data-processing.BBob (third-party library we use for
toView
processing from BBCode to HTML) automatically transforms this to<span style="color: #808080;">
In
toData
processing, driven by a proprietary mapping as defined in some rule-sets, we can process any color state generated by the FontColor plugin that ships with CKEditor 5. They all will be transformed to thehex
orhexa
representation suitable for the[color]
tag (despite color names, which are transformed as is).Suggested CoreMedia Rich Text 1.0 Usage
CoreMedia Rich Text 1.0 lacks a
style
property. Typical mappings from HTML (CKEditor 5 data view) to CoreMedia Rich Text 1.0 (data layer) will try transforming styles to some dedicated token in class-attribute.Given the new API, you could apply such transformations based on
getColor
inCSSStyleDeclarations
utility collection. Suggested mapping:<span style="color: fuchsia;">
<span class="style--color-fuchsia">
<span style="color: rgb(128, 128, 128);">
<span class="style--color-x808080">
The additional
x
may help in parsing, when it comes to resolve this mapping later in delivery (CAE, Headless Server).Bug Fixes 🩹
Blocklist Feature
This pull-request also includes a set of fixes for the blocklist plugin:
Adjusting the following behaviors:
Internal Changes 🔐
Some changes are not relevant for the external deliverable, but may be important to know for developers within this workspace.
ESLint
Enabling consistent-return.
Required, for example, explicit
return undefined;
instead of just a void return value as inreturn;
. Added, as it adds more consistency to the API we develop.BBCode Example App
BBCode has been introduced as an additional flavor of the Example App. The CoreMedia Rich Text Example App, which is still our main example application, has been refactored, so that we can now load different flavors of example apps.
This comes with a new
SwitchButton
, that automatically stores the current state in the URL, so that upon reload, corresponding states are kept as is. For example, if you turned on read-only before, the editor will also be read-only after reload.Babel Configuration Simplification
As most plugins we referenced explicitly are already part of the corresponding presets, removed the obsolete explicit references.
As a needed side effect, we returned to the standard configurations of the corresponding plugins, which is especially about skipping the
loose
option forplugin-transform-*
.TypeDoc: Prefer
index.ts
overindex-doc.ts
Since we mature our public API within
index.ts
(adapting the CKEditor 5 code-style), theindex-doc.ts
becomes more and more obsolete. What is more: Usingindex.ts
also for documentation will inform us automatically also on possibly missing (yet) private API to expose, that is reachable via public API.Only more or less directly affected modules have been adapted accordingly.