Skip to content

Commit 89f4e7e

Browse files
feat: Add dynamic links to Text plugins and HTMLFields with CKEditor 5 (#6)
* Add dynamic link fields * Complete some left-over changes * Update private/js/ckeditor5_plugins/cms-link/src/cmsLink.js * Update private/js/ckeditor5_plugins/cms-link/src/cmsLink.js * Fix multiple editor issue * Fix toolbar logic * Fix: UI update calls when changing text * Refactor * Update private/js/ckeditor5_plugins/cms-link/src/cmsLink.js Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * Fix sourcery recommendations * fix: Update dropdown after using the action view of the link plugin * Update readme * Prepare next release --------- Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
1 parent 2d74829 commit 89f4e7e

File tree

12 files changed

+596
-724
lines changed

12 files changed

+596
-724
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Changelog
33
=========
44

5+
0.2.0 (2024-12-12)
6+
==================
7+
8+
* feat: Add dynamic links to Text plugins and HTMLFields with CKEditor 5
9+
510
0.1.0 (2024-12-16)
611
==================
712

README.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ Features
1111

1212
- **CKEditor5**: Look and feel of CKEditor5.
1313
- **Inline exiting**: CKEditor5 supports inline editing.
14-
- **Dynamic HTML attributes**: (not yet supported - help needed)
14+
- **Dynamic HTML attributes**: Supported for the Link plugin
1515
- **Text-enabled plugins**: (not yet supported - help needed)
1616

1717

1818
Installation
1919
------------
2020

2121
Install ``djangocms-text-ckeditor5`` using pip:
22-
``pip install git+https://github.com/django-cms/djangocms-text-ckeditor5``.
22+
23+
.. code-block:: bash
24+
25+
pip install djangocms-text-ckeditor5
2326
2427
Build latest development branch using git:
2528

@@ -34,12 +37,17 @@ Build latest development branch using git:
3437
You then can install the cloned repo using ``pip install -e
3538
/path/to/the/repo/djangocms-text-ckeditor5``.
3639

37-
Finally, add ``djangocms_text_ckeditor5`` to your ``INSTALLED_APPS`` in your Django project
38-
settings:
40+
Finally, add ``djangocms_text_ckeditor5`` in addition to ``djangocms_text`` to
41+
your ``INSTALLED_APPS`` in your Django project settings:
3942

4043
.. code-block:: python
4144
42-
INSTALLED_APPS = [..., "djangocms_text_ckeditor5", ...]
45+
INSTALLED_APPS = [
46+
...,
47+
"djangocms_text",
48+
"djangocms_text_ckeditor5",
49+
...
50+
]
4351
4452
and set the editor you want to use:
4553

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from djangocms_text.editors import RTEConfig
22

33

4-
__version__ = "0.1.0"
4+
__version__ = "0.2.0"
55

66

77
ckeditor5 = RTEConfig(
88
name="ckeditor5",
99
config="CKEDITOR5",
10-
js=("djangocms_text/bundles/bundle.ckeditor5.min.js",),
11-
css={"all": ("djangocms_text/css/cms.ckeditor5.css",)},
10+
js=("djangocms_text_ckeditor5/bundles/bundle.ckeditor5.min.js",),
11+
css={
12+
"all": (
13+
"djangocms_text_ckeditor5/css/cms.ckeditor5.css",
14+
"djangocms_text_ckeditor5/css/cms.linkfield.css",
15+
)
16+
},
1217
inline_editing=True,
1318
)

djangocms_text_ckeditor5/static/djangocms_text/css/cms.ckeditor5.css renamed to djangocms_text_ckeditor5/static/djangocms_text_ckeditor5/css/cms.ckeditor5.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
}
88
}
99

10+
.cms-editor-inline-wrapper.ck a {
11+
pointer-events: none;
12+
}
13+
1014
.cms-admin.app-djangocms_text.model-text .ck-editor {
1115
border: none;
1216
background: var(--dca-white);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.ck.ck-balloon-panel {
2+
.cms-linkfield-wrapper {
3+
font-size: 0.8rem;
4+
position: relative;
5+
input[type="text"] {
6+
padding-inline-end: 2em;
7+
background: var(--dca-white, white) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="16" fill="%23808080" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>') no-repeat right center;
8+
&[dir=rtl] {
9+
background-position: left center;
10+
}
11+
background-size: auto 1em;
12+
}
13+
.cms-linkfield-selected {
14+
font-weight: bold;
15+
}
16+
.cms-linkfield-dropdown:not(:empty), .cms-linkfield-dropdown:active {
17+
/* Hide dropdown when empty */
18+
visibility: visible;
19+
}
20+
.cms-linkfield-dropdown {
21+
z-index: 1;
22+
visibility: hidden;
23+
position: absolute;
24+
max-block-size: 200px;
25+
overflow: auto;
26+
inset-inline-start: 0;
27+
inset-block-start: 100%;
28+
border: 1px solid var(--dca-gray-lighter);
29+
background: var(--dca-white);
30+
inline-size: 120%;
31+
resize: both;
32+
border-end-start-radius: 4px;
33+
border-end-end-radius: 4px;
34+
box-shadow: 0 1.5px 1.5px rgba(var(--dca-shadow),.4);
35+
.cms-linkfield-error {
36+
color: red;
37+
font-size: 0.8rem;
38+
}
39+
div {
40+
padding: 0.3rem 6px;
41+
white-space: nowrap;
42+
font-weight: normal;
43+
border-block-end: 1px solid var(--dca-gray-lighter);
44+
&:last-child {
45+
border-bottom: none;
46+
}
47+
&.cms-linkfield-parent {
48+
font-weight: bold;
49+
background: var(--dca-gray-lightest);
50+
}
51+
&.cms-linkfield-message {
52+
font-style: italic;
53+
color: var(--dca-gray);
54+
}
55+
&.cms-linkfield-option {
56+
cursor: pointer;
57+
}
58+
&.cms-linkfield-option:hover {
59+
background: var(--dca-primary);
60+
color: var(--dca-white);
61+
}
62+
}
63+
}
64+
}
65+
}

private/js/ckeditor5_plugins/cms-link/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
/* jshint esversion: 6 */
33

44
// index.js
5-
import CMSLinkPlugin from './src/cmsLinkPlugin';
5+
import CmsLink from './src/cmsLink';
66

7-
export default CMSLinkPlugin;
7+
export default CmsLink;

private/js/ckeditor5_plugins/cms-link/src/autocomplete.js

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)