@richscripts/richtexteditor 2.14.0 → 2.14.1

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.
@@ -4,17 +4,28 @@
4
4
  <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.1)" />
5
5
 
6
6
  <script type="text/javascript">
7
+ // Call the editor directly when this frame may. Opened from disk (file://) every frame
8
+ // is its own origin and the direct call throws a SecurityError - which used to abort this
9
+ // page's load before it drew Recent, and made OK do nothing. Post a message instead; the
10
+ // editor's Color Picker listens for this frame's messages.
11
+ function callPicker(method, value) {
12
+ try { parent.rtecolorpicker[method](value); return; }
13
+ catch (e) { }
14
+ try { parent.postMessage({ rtecolorpicker: method, value: value }, "*"); }
15
+ catch (e) { }
16
+ }
7
17
  function updateColor(c) {
8
- parent.rtecolorpicker.update(c);
18
+ callPicker("update", c);
9
19
  }
10
20
  function selectColor(c) {
11
- parent.rtecolorpicker.select(c);
21
+ callPicker("select", c);
12
22
  }
13
23
  function selectCancel() {
14
- parent.rtecolorpicker.cancel();
24
+ callPicker("cancel");
15
25
  }
16
26
  function setCallback(cb) {
17
- parent.rtecolorpicker.setCallback(cb);
27
+ try { parent.rtecolorpicker.setCallback(cb); }
28
+ catch (e) { }
18
29
  }
19
30
  </script>
20
31
 
@@ -121,12 +132,14 @@
121
132
 
122
133
  }
123
134
 
124
- if (top.dialogArguments) {
125
- if (typeof (top.dialogArguments) == 'object') {
126
- if (top.dialogArguments.onchange) {
127
- firecolorchange = top.dialogArguments.onchange;
128
- _origincolor = top.dialogArguments.color;
129
- _editor = top.dialogArguments.editor;
135
+ var _dialogArguments = null;
136
+ try { _dialogArguments = top.dialogArguments; } catch (e) { } // cross-origin from disk
137
+ if (_dialogArguments) {
138
+ if (typeof (_dialogArguments) == 'object') {
139
+ if (_dialogArguments.onchange) {
140
+ firecolorchange = _dialogArguments.onchange;
141
+ _origincolor = _dialogArguments.color;
142
+ _editor = _dialogArguments.editor;
130
143
  }
131
144
  }
132
145
  }
@@ -313,7 +326,8 @@
313
326
  msg.SelectAColor = "Select a color:";
314
327
  msg.OKButton = "OK";
315
328
  msg.CancelButton = "Cancel";
316
- msg.Recent = "Recent";
329
+ msg.Recent = "Recent colors";
330
+ msg.RecentEmpty = "Colors you apply will appear here.";
317
331
  msg.WebSafeWarning = "Warning: not a web safe color";
318
332
  msg.WebSafeClick = "Click to select web safe color";
319
333
  msg.HsbHue = "H:";
@@ -392,11 +406,17 @@
392
406
  frm.ColorType[new Number(GetCookie("ColorMode") || 0)].checked = true;
393
407
  ColorMode_Changed(e);
394
408
 
395
- var recent = GetCookie("RecentColors") || "";
409
+ // The editor passes its list (every colour it applied, from anywhere); fall back to
410
+ // the shared storage for a page opened some other way.
411
+ var recent = GetQuery("Recent") || GetCookie("RecentColors") || "";
412
+ recent = String(recent).toUpperCase().replace(/[^0-9A-F]/g, "");
413
+ recent = recent.substring(0, recent.length - recent.length % 6);
396
414
 
397
415
  var RecentTooltip = msg.RecentTooltip;
416
+ var recentShown = 0;
398
417
  for (var i = 1; i < 33; i++)
399
- if (recent.length / 6 >= i) {
418
+ if (recent.length / 6 >= i && i <= 24) {
419
+ recentShown++;
400
420
  hex = recent.substr((i - 1) * 6, 6);
401
421
  var rgb = HexToRgb(hex);
402
422
  var title = formatString(msg.RecentTooltip, hex, rgb[0], rgb[1], rgb[2]);
@@ -410,8 +430,13 @@
410
430
  recentColor.onkeydown = pnlRecent_KeyDown;
411
431
  }
412
432
  else
413
- document.getElementById("pnlRecent" + i).style.border = "0px";
414
- //Hide(document.all["pnlRecent" + i]);
433
+ document.getElementById("pnlRecent" + i).className = "recent-empty";
434
+ if (!recentShown) {
435
+ var none = document.createElement("span");
436
+ none.id = "pnlRecentNone";
437
+ none.innerText = msg.RecentEmpty;
438
+ document.getElementById("pnlRecent").appendChild(none);
439
+ }
415
440
  }
416
441
 
417
442
  function pnlRecent_Click(e) {
@@ -2421,6 +2446,56 @@ Elements
2421
2446
  margin: 0;
2422
2447
  text-align: center;
2423
2448
  }
2449
+
2450
+ /* Recent colors: only the swatches there are, rounded, in a grid - not 32 sunken empty
2451
+ boxes. Up to 24 (three rows) fit the space. */
2452
+ #colorpickerpanel #pnlRecentBorder {
2453
+ display: none;
2454
+ }
2455
+
2456
+ #colorpickerpanel #lblRecent {
2457
+ width: 160px;
2458
+ }
2459
+
2460
+ #colorpickerpanel #pnlRecent {
2461
+ display: grid;
2462
+ grid-template-columns: repeat(8, 16px);
2463
+ grid-auto-rows: 16px;
2464
+ gap: 4px;
2465
+ align-content: start;
2466
+ height: 72px;
2467
+ }
2468
+
2469
+ #colorpickerpanel #pnlRecent DIV {
2470
+ position: static;
2471
+ width: 16px;
2472
+ height: 16px;
2473
+ box-sizing: border-box;
2474
+ border: 1px solid rgba(0, 0, 0, .22);
2475
+ border-radius: 3px;
2476
+ cursor: pointer;
2477
+ transition: transform .1s, box-shadow .1s;
2478
+ }
2479
+
2480
+ #colorpickerpanel #pnlRecent DIV:hover {
2481
+ transform: scale(1.2);
2482
+ box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
2483
+ }
2484
+
2485
+ #colorpickerpanel #pnlRecent DIV:focus-visible {
2486
+ outline: 2px solid #1a73e8;
2487
+ outline-offset: 1px;
2488
+ }
2489
+
2490
+ #colorpickerpanel #pnlRecent DIV.recent-empty {
2491
+ display: none;
2492
+ }
2493
+
2494
+ #pnlRecentNone {
2495
+ grid-column: 1 / -1;
2496
+ font: 11px/1.35 Arial, sans-serif;
2497
+ color: #6b7280;
2498
+ }
2424
2499
  </style>
2425
2500
  <title>CustomColor</title>
2426
2501
  </head>
@@ -2683,7 +2758,9 @@ Elements
2683
2758
  <script>
2684
2759
 
2685
2760
  new function () {
2686
- var editor = parent.rtecolorpickereditor;
2761
+ var editor = null;
2762
+ try { editor = parent.rtecolorpickereditor; } catch (e) { } // cross-origin from disk: keep English
2763
+ if (!editor || !editor.getLangText) return;
2687
2764
  var ns = document.getElementsByTagName("*");
2688
2765
  for (var i = 0; i < ns.length; i++) {
2689
2766
  var n = ns[i];