trusty-cms 7.0.44 → 7.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,19 @@
1
+ .ck-content .asset-image-tag {
2
+ background-color: #dcdcdc;
3
+ display: inline-flex;
4
+ align-items: center;
5
+ padding: 1em;
6
+ border: 1px dashed #c3c3c3;
7
+ opacity: 0.85;
8
+ user-select: none;
9
+ }
10
+
11
+ .ck-content .asset-image-tag__label {
12
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
13
+ font-size: 0.85em;
14
+ white-space: nowrap;
15
+ }
16
+
1
17
  .search {
2
18
  display: grid;
3
19
  grid-template-columns: 1fr 1fr;
@@ -1,11 +1,16 @@
1
- import { Plugin } from 'ckeditor5';
1
+ import { Plugin, Widget, toWidget } from 'ckeditor5/src/index.js';
2
2
 
3
3
  export default class AssetTagBuilder extends Plugin {
4
+ static get requires() {
5
+ return [ Widget ];
6
+ }
7
+
4
8
  init() {
5
9
  console.log( 'AssetTagBuilder plugin initialized' );
6
10
  // Plugin logic goes here
7
11
  this._defineSchema();
8
12
  this._defineConverters();
13
+ this._defineDataNormalization();
9
14
  }
10
15
 
11
16
  _defineSchema() {
@@ -48,6 +53,7 @@ export default class AssetTagBuilder extends Plugin {
48
53
  }
49
54
  } );
50
55
 
56
+
51
57
  // Data downcast: ensure no inner whitespace like   gets serialized.
52
58
  dataDowncast.elementToElement( {
53
59
  model: 'assetImage',
@@ -65,7 +71,7 @@ export default class AssetTagBuilder extends Plugin {
65
71
  if ( height ) attrs.height = height;
66
72
  if ( width ) attrs.width = width;
67
73
 
68
- return writer.createEmptyElement( 'r:asset:image', attrs );
74
+ return writer.createContainerElement( 'r:asset:image', attrs );
69
75
  }
70
76
  } );
71
77
 
@@ -86,8 +92,78 @@ export default class AssetTagBuilder extends Plugin {
86
92
  if ( height ) attrs.height = height;
87
93
  if ( width ) attrs.width = width;
88
94
 
89
- return writer.createContainerElement( 'r:asset:image', attrs );
90
- }
91
- } );
95
+ const container = writer.createContainerElement('span', {
96
+ class: 'asset-image-tag',
97
+ 'data-asset-id': id,
98
+ 'data-asset-size': size
99
+ });
100
+
101
+ const label = writer.createUIElement(
102
+ 'span',
103
+ { class: 'asset-image-tag__label' },
104
+ function (domDocument) {
105
+ const domEl = this.toDomElement(domDocument);
106
+ const parts = [
107
+ 'Asset image',
108
+ id ? `#${id}` : '',
109
+ size ? `(${size})` : '',
110
+ alt ? `— ${alt}` : '',
111
+ height ? `height: ${height}` : '',
112
+ width ? `width: ${width}` : ''
113
+ ].filter(Boolean);
114
+
115
+ domEl.textContent = parts.join(' ');
116
+ return domEl;
117
+ }
118
+ );
119
+
120
+ writer.insert(writer.createPositionAt(container, 0), label);
121
+ return toWidget(container, writer, { label: `Asset image ${id ? `#${id}` : ''}` });
122
+ }
123
+ } );
124
+
125
+ }
126
+
127
+ _defineDataNormalization() {
128
+ const editor = this.editor;
129
+ const processor = editor.data.processor;
130
+
131
+ const originalToView = processor.toView.bind( processor );
132
+ const originalToData = processor.toData.bind( processor );
133
+
134
+ // 1) Incoming: <r:asset:image ... /> -> <r:asset:image ...></r:asset:image>
135
+ processor.toView = (data) => {
136
+ let normalized = data;
137
+
138
+ // 1) Self-closing -> paired
139
+ normalized = normalized.replace(
140
+ /<r:asset:image\b([^>]*?)\/>/gi,
141
+ '<r:asset:image$1></r:asset:image>'
142
+ );
143
+
144
+ // 2) Bare open tag (rare, but happens) -> paired
145
+ normalized = normalized.replace(
146
+ /<r:asset:image\b([^>]*?)>(?!\s*<\/r:asset:image>)/gi,
147
+ '<r:asset:image$1></r:asset:image>'
148
+ );
149
+
150
+ return originalToView(normalized);
151
+ };
152
+
153
+
154
+ processor.toData = (viewFragment) => {
155
+ const html = originalToData(viewFragment);
156
+
157
+ return html.replace(
158
+ /<r:asset:image\b([^>]*?)>([\s\S]*?)<\/r:asset:image>/gi,
159
+ (match, attrs, inner) => {
160
+ const cleanedInner = inner.replace(
161
+ /^(?:\s|&nbsp;|&#160;)+|(?:\s|&nbsp;|&#160;)+$/g,
162
+ ''
163
+ );
164
+ return `<r:asset:image${attrs} />${cleanedInner}`;
165
+ }
166
+ );
167
+ };
92
168
  }
93
169
  }
@@ -46,7 +46,7 @@ const defaultStyleDefinitions = [
46
46
  }
47
47
  ]
48
48
 
49
- import AssetTagBuilder from '../plugins/asset_tags/asset_tags';
49
+ import AssetTagBuilder from '../plugins/asset_tags/asset_tag_builder';
50
50
 
51
51
  import {
52
52
  ClassicEditor,
@@ -112,9 +112,7 @@ import {
112
112
  TextTransformation,
113
113
  TodoList,
114
114
  Underline
115
- } from 'ckeditor5';
116
-
117
- import "ckeditor5/ckeditor5.css";
115
+ } from 'ckeditor5/src/index.js';
118
116
 
119
117
 
120
118
  const editorConfig = {
@@ -145,7 +143,6 @@ const editorConfig = {
145
143
  'code',
146
144
  'removeFormat',
147
145
  '|',
148
- 'specialCharacters',
149
146
  'horizontalLine',
150
147
  'link',
151
148
  'bookmark',
@@ -370,6 +367,8 @@ editorElements.forEach((editorElement) => {
370
367
  if (!hiddenInput) {
371
368
  return;
372
369
  }
370
+
371
+ editor.setData(hiddenInput.value || '');
373
372
  editor.ui.focusTracker.on( 'change:isFocused', ( evt, name, isFocused ) => {
374
373
  if ( !isFocused ) {
375
374
  editor.plugins.get( 'SourceEditing' ).updateEditorData()
@@ -14,5 +14,4 @@
14
14
  .editor-container.editor-container_classic-editor.editor-container_include-style.editor-container_include-fullscreen#editor-container
15
15
  .editor-container__editor
16
16
  %div{ id: "editor_#{ page_part.name.to_slug }", data: { part: page_part.name.to_slug } }
17
- = page_part.content.to_s.html_safe # rubocop:disable Rails/OutputSafety
18
17
  = hidden_field_tag :page_part, page_part.content || '', name: "page[parts_attributes][#{ page_part_counter }][content]", id: "part_#{ page_part.name.to_slug }_content"
@@ -37,11 +37,10 @@
37
37
 
38
38
  - stylesheet_overrides.each do |stylesheet|
39
39
  = stylesheet_link_tag stylesheet
40
-
41
40
  - javascript_overrides.each do |javascript|
42
41
  = javascript_include_tag javascript
43
42
 
44
- = stylesheet_link_tag href="trusty_cms/ckeditor5"
43
+ = stylesheet_link_tag 'ckeditor5/dist/ckeditor5.css'
45
44
  = csrf_meta_tags
46
45
 
47
46
  :javascript
@@ -1,3 +1,3 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.44'.freeze
2
+ VERSION = '7.0.46'.freeze
3
3
  end
data/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "scripts": {
35
35
  "test": "echo \"Error: no test specified\" && exit 1",
36
- "build": "esbuild app/javascript/trusty_cms/ckeditor5.js --bundle --sourcemap --outdir=app/assets/builds/trusty_cms --public-path=/assets",
36
+ "build": "esbuild app/javascript/trusty_cms/ckeditor5.js --bundle --sourcemap --outdir=app/assets/builds/trusty_cms --public-path=/assets --loader:.svg=text",
37
37
  "build:watch": "npm run build -- --watch"
38
38
  },
39
39
  "keywords": [],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.44
4
+ version: 7.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-08 00:00:00.000000000 Z
11
+ date: 2026-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator
@@ -819,7 +819,6 @@ files:
819
819
  - app/helpers/site_helper.rb
820
820
  - app/helpers/sites_helper.rb
821
821
  - app/javascript/plugins/asset_tags/asset_tag_builder.js
822
- - app/javascript/plugins/asset_tags/asset_tags.js
823
822
  - app/javascript/trusty_cms/ckeditor5.js
824
823
  - app/mailers/application_mailer.rb
825
824
  - app/mailers/devise_mailer.rb
@@ -1,8 +0,0 @@
1
- import AssetTagBuilder from './asset_tag_builder';
2
- import { Plugin } from 'ckeditor5';
3
-
4
- export default class AssetTags extends Plugin {
5
- static get requires() {
6
- return [ AssetTagBuilder ];
7
- }
8
- }