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

Feature/bbcode dataprocessor data facade wo tests #169

Closed

Conversation

JensDallmann
Copy link
Contributor

No description provided.

pkliesch and others added 30 commits September 29, 2023 12:10
Plugin to convert BBCode to HTML for CKEditor data view (and vice versa).
This is just the initial commit and still work in progress.
…ML2BBCodeRule

Instead of returning bbcode with the node's textContent, we should return the child contents instead.
This is mandatory since a strong/italic etc. node might have children that need to be rendered inside the
resulting bbcode tag. Since we are computing the bbcode string recursively, starting with the inner nodes,
we can just use the already computed child string.
Also: Inline comments and dom-converter package used to simplify types
The EditorConfig type extensions in some of our augmentation files were marked as mandatory.
This is false. TypeScript would complain about insufficient configs if these plugins were not configured.
(Which is totally fine) Therefore, these config extensions are now marked as optional.

Also, the configuration of the CoreMedia RichText plugin was now moved into a separate function.
TypeScript was not happy with compatibility and rules being set independently because these values
have to match in order to represent a certain config type (v10 or latest). Compatibility is now
also set explicitly to make sure the value matches the given type. (type expects "v10" or "latest" and
the value was of type "string | true")
main is now at 15.0.2-rc.2. Updated new BBCode module accordingly.
To share selection support for a given set of examples, moved the
corresponding code to `ckeditor5-coremedia-example-data`.

This API could not be reused for all our example applications.
Refactoring the Rich Text Editor to the new examples UI.
To be able to re-use the read-only toggle button for different
example editors, refactored the code, so that it now also adds the
required UI-Elements on the fly.
* Move Notifications into Header
* Add some comments about "boxes to fill".
* Fixing some typos.
In preparation, to possibly also provide a preview for BBCode (MVP:
as plain text), extracted formatting to extra facade.
Now you may configure the formatter to use when
updating the preview.
To prepare using the preview also for BBCode editor, refactored the
preview initialization to be similar to the read-only mode button
behavior (like dynamically adding a toggle button to the
application toolbar).

Moved application toolbar handling to extra file, so that it can be
reused.
Introduced a general concept for toggling states with focus on being
able to switch the editor depending on the data-type.

State is stored in hash-parameters, so that it can be restored on
reload or even triggered directly.
Now also using the SwitchButton. We decided to extend the SwitchButton,
so that it ships with the option to delay switching on demand, to cover
a relevant use-case for switching read-only mode (we require the delay,
so that we may, for example, open some dialogs and see, that they
respond for a switch of the read-only mode).
The current read-only mode is now also stored in hash-parameters and
helps to start the application in a given mode right away.
We now also store the preview state as hash parameter.
In preparation to also have example data for BBCode, moving content
link data to example-data module for better separation of concerns.
In preparation to also have example data for BBCode, moving invalid
rich text data to example-data module for better separation of concerns.
In preparation to also have example data for BBCode, moving some simple
rich text data to example-data module for better separation of concerns.
Using `innerHtml` for defining option may break the layout, if the
example title contains HTML elements or entities.
mmichaelis and others added 27 commits October 9, 2023 15:21
Replace "recursive mapping detection" by explicitly invoking
`render` internally. And, while at it, added a behavior, that trims
surrounding newlines, that may be a left-over from pretty-printing in
HTML 2 BBCode processing.
As before, we re-use the existing tests from BBob. This helps us to see,
if we broke any of the existing behavior.

Only skipped that test (but kept for documentation), where we changed
the behavior and added new ones in an extra section instead.
We now support the language-attribute for code-blocks. Thus,
adapted the tests accordingly.
Add a demo for custom language tokens and add custom `bbcode`
language to the configuration copied from the default config.
Move code block examples into extra file with some additional
description.
Instead of trying to escape some weird matched language pattern using
a defensive regular expression now. This feels much less error-prone,
especially, as there are known issues with escaping not to work
within attributes regarding BBCode parsing.
…le name)

While in previous commit we focused on renaming the folder only, now
also renaming the module. According to our naming rules, the module
must not contain `coremedia` in its name (despite the scope), as it
does not include CoreMedia specific adaptations.
Updating README along with adapting the example application accordingly.
When `href` and `textContent` are equal, HTML transformed to BBCode can
be optimized to the URL only being rendered as content of the BBCode
`[url]` tag.

Applied this optimization.
* Adding note on table rendering.
* Moving _Links_ section closer to the inline formats, as it seems
  more suitable.
* Adding a hint for data facade.
Aligned implementations a little bit.
Using style options is not limited to `<span>`. It works for any
`HTMLElement`.
Simplifying by only relying on applying a regular expression once.
Parsing will now also signal, if it actually understood the color
code pattern.

Added a bunch of documentation, especially to the somewhat complex
regular expression used for matching.
@@ -0,0 +1 @@
export const removeLeadingAndTrailingNewlines = (s: string): string => s.replace(/(^[\n\r]*|[\n\r]*$)/g, "");

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings with many repetitions of '\n'.
@JensDallmann JensDallmann deleted the feature/bbcode-dataprocessor-data-facade-wo-tests branch October 18, 2023 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants