trusty-cms 7.0.44 → 7.0.45

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';
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
  }
@@ -145,7 +145,6 @@ const editorConfig = {
145
145
  'code',
146
146
  'removeFormat',
147
147
  '|',
148
- 'specialCharacters',
149
148
  'horizontalLine',
150
149
  'link',
151
150
  'bookmark',
@@ -1,3 +1,3 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.44'.freeze
2
+ VERSION = '7.0.45'.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.45
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-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator