trusty-cms 7.0.43 → 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;
@@ -2,15 +2,16 @@ module Admin::UrlHelper
2
2
  require 'uri'
3
3
 
4
4
  def format_path(path)
5
- return '' if path.to_s.empty?
6
-
7
- parts = path.split('/').reject(&:empty?)
8
- parts_size = parts.size
9
- return 'Root' if parts_size == 1
10
- return '/' if parts_size == 2
11
-
12
- formatted_path = parts[1..-2].join('/')
13
- formatted_path.empty? ? '/' : "/#{formatted_path}"
5
+ parts = path.to_s.split('/').reject(&:empty?)
6
+
7
+ case parts.size
8
+ when 0 then ''
9
+ when 1 then 'Root'
10
+ when 2 then '/'
11
+ else
12
+ subpath = parts[1..-2].to_a.join('/')
13
+ subpath.empty? ? '/' : "/#{subpath}"
14
+ end
14
15
  end
15
16
 
16
17
  def generate_page_url(url, page)
@@ -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.43'.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": [],
data/yarn.lock CHANGED
@@ -2435,9 +2435,9 @@ mdast-util-phrasing@^4.0.0:
2435
2435
  unist-util-is "^6.0.0"
2436
2436
 
2437
2437
  mdast-util-to-hast@^13.0.0:
2438
- version "13.2.0"
2439
- resolved "https://registry.yarnpkg.com/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz#5ca58e5b921cc0a3ded1bc02eed79a4fe4fe41f4"
2440
- integrity sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==
2438
+ version "13.2.1"
2439
+ resolved "https://registry.yarnpkg.com/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz#d7ff84ca499a57e2c060ae67548ad950e689a053"
2440
+ integrity sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==
2441
2441
  dependencies:
2442
2442
  "@types/hast" "^3.0.0"
2443
2443
  "@types/mdast" "^4.0.0"
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.43
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-11-19 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