labellife-design-tool 2.5.7 → 2.7.0

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.
package/dist/esm/index.js CHANGED
@@ -102,6 +102,20 @@ function _asyncToGenerator(n) {
102
102
  });
103
103
  };
104
104
  }
105
+ function _classCallCheck(a, n) {
106
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
107
+ }
108
+ function _defineProperties(e, r) {
109
+ for (var t = 0; t < r.length; t++) {
110
+ var o = r[t];
111
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
112
+ }
113
+ }
114
+ function _createClass(e, r, t) {
115
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
116
+ writable: false
117
+ }), e;
118
+ }
105
119
  function _createForOfIteratorHelper(r, e) {
106
120
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
107
121
  if (!t) {
@@ -1001,6 +1015,22 @@ var TextElement = Shape.named('TextElement').props({
1001
1015
  return {
1002
1016
  toggleEditMode: function toggleEditMode(editing) {
1003
1017
  self._editModeEnabled = editing !== undefined ? editing : !self._editModeEnabled;
1018
+ },
1019
+ // Ends an inline text edit. The canvas editor writes the text on every keystroke
1020
+ // without recording a history state, so the finished edit is committed here (once,
1021
+ // and only when the text really changed). That makes it undoable and lets the
1022
+ // activity log see it.
1023
+ finishEdit: function finishEdit(_ref) {
1024
+ var text = _ref.text,
1025
+ originalText = _ref.originalText;
1026
+ self.text = text;
1027
+ self._editModeEnabled = false;
1028
+ if (text === originalText) return;
1029
+ try {
1030
+ getRoot(self).history.addUndoState();
1031
+ } catch (e) {
1032
+ console.warn('Text edit: failed to record history state', e);
1033
+ }
1004
1034
  }
1005
1035
  };
1006
1036
  });
@@ -1566,10 +1596,20 @@ var History = types.model('History', {
1566
1596
  self.history.splice(0, self.history.length - 100);
1567
1597
  self.undoIdx = self.history.length - 1;
1568
1598
  }
1599
+ self._notifyActivity('onCommit', stateToSave);
1569
1600
  } catch (e) {
1570
1601
  console.warn('History: failed to save state', e);
1571
1602
  }
1572
1603
  },
1604
+ // Feeds the plain-English activity log; it must never break editing.
1605
+ _notifyActivity: function _notifyActivity(method, snapshot) {
1606
+ try {
1607
+ var tracker = getRoot(self)._activity;
1608
+ if (tracker) tracker[method](snapshot);
1609
+ } catch (e) {
1610
+ console.warn('Activity log: failed to update', e);
1611
+ }
1612
+ },
1573
1613
  _restoreState: function _restoreState(state) {
1574
1614
  if (!state) return;
1575
1615
  self._ignoring = true;
@@ -1628,11 +1668,13 @@ var History = types.model('History', {
1628
1668
  if (!self.canUndo) return;
1629
1669
  self.undoIdx -= 1;
1630
1670
  self._restoreState(self.history[self.undoIdx]);
1671
+ self._notifyActivity('undone', self.history[self.undoIdx]);
1631
1672
  },
1632
1673
  redo: function redo() {
1633
1674
  if (!self.canRedo) return;
1634
1675
  self.undoIdx += 1;
1635
1676
  self._restoreState(self.history[self.undoIdx]);
1677
+ self._notifyActivity('redone', self.history[self.undoIdx]);
1636
1678
  },
1637
1679
  clear: function clear() {
1638
1680
  self.history.clear();
@@ -1830,6 +1872,746 @@ function buildFontFaceCss(customFont) {
1830
1872
  // Comprehensive list of Google Fonts matching Polotno's font library
1831
1873
  var DEFAULT_FONTS = ['ABeeZee', 'Abel', 'Abhaya Libre', 'Abril Fatface', 'Aclonica', 'Acme', 'Actor', 'Adamina', 'Advent Pro', 'Aguafina Script', 'Akronim', 'Aladin', 'Alata', 'Alatsi', 'Albert Sans', 'Aldrich', 'Alef', 'Alegreya', 'Alegreya Sans', 'Alegreya Sans SC', 'Alegreya SC', 'Aleo', 'Alex Brush', 'Alfa Slab One', 'Alice', 'Alike', 'Alike Angular', 'Allan', 'Allerta', 'Allerta Stencil', 'Allison', 'Allura', 'Almarai', 'Almendra', 'Almendra Display', 'Almendra SC', 'Alumni Sans', 'Alumni Sans Inline One', 'Amarante', 'Amaranth', 'Amatic SC', 'Amethysta', 'Amiko', 'Amiri', 'Amita', 'Anaheim', 'Andada Pro', 'Andika', 'Anek Bangla', 'Anek Devanagari', 'Anek Gujarati', 'Anek Gurmukhi', 'Anek Kannada', 'Anek Latin', 'Anek Malayalam', 'Anek Odia', 'Anek Tamil', 'Anek Telugu', 'Angkor', 'Annie Use Your Telescope', 'Anonymous Pro', 'Antic', 'Antic Didone', 'Antic Slab', 'Anton', 'Antonio', 'Anybody', 'Arapey', 'Arbutus', 'Arbutus Slab', 'Architects Daughter', 'Archivo', 'Archivo Black', 'Archivo Narrow', 'Are You Serious', 'Aref Ruqaa', 'Arima', 'Arimo', 'Arizonia', 'Armata', 'Arsenal', 'Artifika', 'Arvo', 'Arya', 'Asap', 'Asap Condensed', 'Asar', 'Asset', 'Assistant', 'Astloch', 'Asul', 'Athiti', 'Atkinson Hyperlegible', 'Atma', 'Atomic Age', 'Aubrey', 'Audiowide', 'Autour One', 'Average', 'Average Sans', 'Averia Gruesa Libre', 'Averia Libre', 'Averia Sans Libre', 'Averia Serif Libre', 'Azeret Mono', 'B612', 'B612 Mono', 'Bad Script', 'Bahiana', 'Bahianita', 'Bai Jamjuree', 'Bakbak One', 'Ballet', 'Baloo 2', 'Baloo Bhai 2', 'Baloo Bhaijaan 2', 'Baloo Bhaina 2', 'Baloo Chettan 2', 'Baloo Da 2', 'Baloo Paaji 2', 'Baloo Tamma 2', 'Baloo Tammudu 2', 'Baloo Thambi 2', 'Balsamiq Sans', 'Balthazar', 'Bangers', 'Barlow', 'Barlow Condensed', 'Barlow Semi Condensed', 'Barriecito', 'Barrio', 'Basic', 'Baskervville', 'Battambang', 'Baumans', 'Bayon', 'Be Vietnam Pro', 'Beau Rivage', 'Bebas Neue', 'Belgrano', 'Bellefair', 'Belleza', 'Bellota', 'Bellota Text', 'BenchNine', 'Benne', 'Bentham', 'Berkshire Swash', 'Besley', 'Beth Ellen', 'Bevan', 'BIZ UDGothic', 'BIZ UDMincho', 'BIZ UDPGothic', 'BIZ UDPMincho', 'Big Shoulders Display', 'Big Shoulders Inline Display', 'Big Shoulders Inline Text', 'Big Shoulders Stencil Display', 'Big Shoulders Stencil Text', 'Big Shoulders Text', 'Bigelow Rules', 'Bigshot One', 'Bilbo', 'Bilbo Swash Caps', 'BioRhyme', 'BioRhyme Expanded', 'Birthstone', 'Birthstone Bounce', 'Bitter', 'Black And White Picture', 'Black Han Sans', 'Black Ops One', 'Blaka', 'Blaka Hollow', 'Blaka Ink', 'Blinker', 'Bodoni Moda', 'Bokor', 'Bona Nova', 'Bonbon', 'Bonheur Royale', 'Boogaloo', 'Bowlby One', 'Bowlby One SC', 'Brawler', 'Bree Serif', 'Brygada 1918', 'Bubblegum Sans', 'Bubbler One', 'Buda', 'Buenard', 'Bungee', 'Bungee Hairline', 'Bungee Inline', 'Bungee Outline', 'Bungee Shade', 'Bungee Spice', 'Butcherman', 'Butterfly Kids', 'Cabin', 'Cabin Condensed', 'Cabin Sketch', 'Caesar Dressing', 'Cagliostro', 'Cairo', 'Cairo Play', 'Caladea', 'Calistoga', 'Calligraffitti', 'Cambay', 'Cambo', 'Candal', 'Cantarell', 'Cantata One', 'Cantora One', 'Caprasimo', 'Capriola', 'Caramel', 'Carattere', 'Cardo', 'Carlito', 'Carme', 'Carrois Gothic', 'Carrois Gothic SC', 'Carter One', 'Castoro', 'Catamaran', 'Caudex', 'Caveat', 'Caveat Brush', 'Cedarville Cursive', 'Ceviche One', 'Chakra Petch', 'Changa', 'Changa One', 'Chango', 'Charis SIL', 'Charm', 'Charmonman', 'Chathura', 'Chau Philomene One', 'Chela One', 'Chelsea Market', 'Chenla', 'Cherry Bomb One', 'Cherry Cream Soda', 'Cherry Swash', 'Chewy', 'Chicle', 'Chilanka', 'Chivo', 'Chivo Mono', 'Chonburi', 'Cinzel', 'Cinzel Decorative', 'Clicker Script', 'Coda', 'Coda Caption', 'Codystar', 'Coiny', 'Combo', 'Comfortaa', 'Comforter', 'Comforter Brush', 'Comic Neue', 'Coming Soon', 'Commissioner', 'Concert One', 'Condiment', 'Content', 'Contrail One', 'Convergence', 'Cookie', 'Copse', 'Corben', 'Corinthia', 'Cormorant', 'Cormorant Garamond', 'Cormorant Infant', 'Cormorant SC', 'Cormorant Unicase', 'Cormorant Upright', 'Courgette', 'Courier Prime', 'Cousine', 'Coustard', 'Covered By Your Grace', 'Crafty Girls', 'Creepster', 'Crete Round', 'Crimson Pro', 'Crimson Text', 'Croissant One', 'Crushed', 'Cuprum', 'Cute Font', 'Cutive', 'Cutive Mono', 'DM Mono', 'DM Sans', 'DM Serif Display', 'DM Serif Text', 'Damion', 'Dancing Script', 'Dangrek', 'Darker Grotesque', 'David Libre', 'Dawning of a New Day', 'Days One', 'Dekko', 'Dela Gothic One', 'Delius', 'Delius Swash Caps', 'Delius Unicase', 'Della Respira', 'Denk One', 'Devonshire', 'Dhurjati', 'Didact Gothic', 'Diplomata', 'Diplomata SC', 'Do Hyeon', 'Dokdo', 'Domine', 'Donegal One', 'Dongle', 'Doppio One', 'Dorsa', 'Dosis', 'DotGothic16', 'Dr Sugiyama', 'Duru Sans', 'DynaPuff', 'Dynalight', 'EB Garamond', 'Eagle Lake', 'East Sea Dokdo', 'Eater', 'Economica', 'Eczar', 'El Messiri', 'Electrolize', 'Elsie', 'Elsie Swash Caps', 'Emblema One', 'Emilys Candy', 'Encode Sans', 'Encode Sans Condensed', 'Encode Sans Expanded', 'Encode Sans SC', 'Encode Sans Semi Condensed', 'Encode Sans Semi Expanded', 'Engagement', 'Englebert', 'Enriqueta', 'Ephesis', 'Epilogue', 'Erica One', 'Esteban', 'Estonia', 'Euphoria Script', 'Ewert', 'Exo', 'Exo 2', 'Expletus Sans', 'Explora', 'Fahkwang', 'Familjen Grotesk', 'Fanwood Text', 'Farro', 'Farsan', 'Fascinate', 'Fascinate Inline', 'Faster One', 'Fasthand', 'Fauna One', 'Faustina', 'Federant', 'Federo', 'Felipa', 'Fenix', 'Festive', 'Finger Paint', 'Finlandica', 'Fira Code', 'Fira Mono', 'Fira Sans', 'Fira Sans Condensed', 'Fira Sans Extra Condensed', 'Fjalla One', 'Fjord One', 'Flamenco', 'Flavors', 'Fleur De Leah', 'Flow Block', 'Flow Circular', 'Flow Rounded', 'Fondamento', 'Fontdiner Swanky', 'Forum', 'Fragment Mono', 'Francois One', 'Frank Ruhl Libre', 'Fraunces', 'Freckle Face', 'Fredericka the Great', 'Fredoka', 'Freehand', 'Fresca', 'Frijole', 'Fruktur', 'Fugaz One', 'Fuggles', 'Fuzzy Bubbles', 'GFS Didot', 'GFS Neohellenic', 'Gabriela', 'Gaegu', 'Gafata', 'Galada', 'Galdeano', 'Galindo', 'Gamja Flower', 'Gantari', 'Gas', 'Gayathri', 'Gelasio', 'Gemunu Libre', 'Genos', 'Gentium Book Plus', 'Gentium Plus', 'Geo', 'Georama', 'Geostar', 'Geostar Fill', 'Germania One', 'Gideon Roman', 'Gidugu', 'Gilda Display', 'Girassol', 'Give You Glory', 'Glass Antiqua', 'Glegoo', 'Gloria Hallelujah', 'Glory', 'Gluten', 'Goblin One', 'Gochi Hand', 'Goldman', 'Goldplay', 'Golos Text', 'Gorditas', 'Gothic A1', 'Gotu', 'Goudy Bookletter 1911', 'Gowun Batang', 'Gowun Dodum', 'Graduate', 'Grand Hotel', 'Grandstander', 'Grape Nuts', 'Gravitas One', 'Great Vibes', 'Grechen Fuemen', 'Grenze', 'Grenze Gotisch', 'Grey Qo', 'Griffy', 'Gruppo', 'Gudea', 'Gugi', 'Gulzar', 'Gupter', 'Gurajada', 'Gwendolyn', 'Habibi', 'Hachi Maru Pop', 'Hahmlet', 'Halant', 'Hammersmith One', 'Hanalei', 'Hanalei Fill', 'Handlee', 'Hanken Grotesk', 'Hanuman', 'Happy Monkey', 'Harmattan', 'Headland One', 'Heebo', 'Henny Penny', 'Hepta Slab', 'Herr Von Muellerhoff', 'Hi Melody', 'Hina Mincho', 'Hind', 'Hind Guntur', 'Hind Madurai', 'Hind Siliguri', 'Hind Vadodara', 'Holtwood One SC', 'Homemade Apple', 'Homenaje', 'Hubballi', 'Hurricane', 'IBM Plex Mono', 'IBM Plex Sans', 'IBM Plex Sans Arabic', 'IBM Plex Sans Condensed', 'IBM Plex Sans Devanagari', 'IBM Plex Sans Hebrew', 'IBM Plex Sans JP', 'IBM Plex Sans KR', 'IBM Plex Sans Thai', 'IBM Plex Sans Thai Looped', 'IBM Plex Serif', 'Iceberg', 'Iceland', 'Imbue', 'Imperial Script', 'Imprima', 'Inconsolata', 'Inder', 'Indie Flower', 'Ingrid Darling', 'Inika', 'Inknut Antiqua', 'Inria Sans', 'Inria Serif', 'Inspiration', 'Inter', 'Inter Tight', 'Irish Grover', 'Island Moments', 'Istok Web', 'Italiana', 'Italianno', 'Itim', 'Jacques Francois', 'Jacques Francois Shadow', 'Jaldi', 'JetBrains Mono', 'Jim Nightshade', 'Joan', 'Jockey One', 'Jolly Lodger', 'Jomhuria', 'Jomolhari', 'Josefin Sans', 'Josefin Slab', 'Jost', 'Joti One', 'Jua', 'Judson', 'Julee', 'Julius Sans One', 'Junge', 'Jura', 'K2D', 'Kadwa', 'Kaisei Decol', 'Kaisei HarunoUmi', 'Kaisei Opti', 'Kaisei Tokumin', 'Kalam', 'Kameron', 'Kanit', 'Kantumruy Pro', 'Karantina', 'Karla', 'Karma', 'Katibeh', 'Kaushan Script', 'Kavivanar', 'Kavoon', 'Kdam Thmor Pro', 'Keania One', 'Kelly Slab', 'Kenia', 'Khand', 'Khmer', 'Khula', 'Kings', 'Kirang Haerang', 'Kite One', 'Kiwi Maru', 'Klee One', 'Knewave', 'KoHo', 'Kodchasan', 'Koh Santepheap', 'Kolker Brush', 'Konkhmer Sleokchher', 'Kosugi', 'Kosugi Maru', 'Kotta One', 'Koulen', 'Kranky', 'Kreon', 'Kristi', 'Krona One', 'Krub', 'Kufam', 'Kulim Park', 'Kumar One', 'Kumar One Outline', 'Kumbh Sans', 'Kurale', 'La Belle Aurore', 'Lacquer', 'Laila', 'Lakki Reddy', 'Lalezar', 'Lancelot', 'Langar', 'Lango', 'Lateef', 'Lato', 'Lavishly Yours', 'League Gothic', 'League Script', 'League Spartan', 'Leckerli One', 'Ledger', 'Lekton', 'Lemon', 'Lemonada', 'Lexend', 'Lexend Deca', 'Lexend Exa', 'Lexend Giga', 'Lexend Mega', 'Lexend Peta', 'Lexend Tera', 'Lexend Zetta', 'Libre Barcode 128', 'Libre Barcode 128 Text', 'Libre Barcode 39', 'Libre Barcode 39 Extended', 'Libre Barcode 39 Extended Text', 'Libre Barcode 39 Text', 'Libre Barcode EAN13 Text', 'Libre Baskerville', 'Libre Bodoni', 'Libre Caslon Display', 'Libre Caslon Text', 'Libre Franklin', 'Licorice', 'Life Savers', 'Lilita One', 'Lily Script One', 'Limelight', 'Linden Hill', 'Lingua Franca', 'Literata', 'Liu Jian Mao Cao', 'Livvic', 'Lobster', 'Lobster Two', 'Londrina Outline', 'Londrina Shadow', 'Londrina Sketch', 'Londrina Solid', 'Long Cang', 'Lora', 'Love Light', 'Love Ya Like A Sister', 'Loved by the King', 'Lovers Quarrel', 'Luckiest Guy', 'Lusitana', 'Lustria', 'Luxurious Roman', 'Luxurious Script', 'M PLUS 1', 'M PLUS 1 Code', 'M PLUS 1p', 'M PLUS 2', 'M PLUS Code Latin', 'M PLUS Rounded 1c', 'Ma Shan Zheng', 'Macondo', 'Macondo Swash Caps', 'Mada', 'Magra', 'Maiden Orange', 'Maitree', 'Major Mono Display', 'Mako', 'Mali', 'Mallanna', 'Mandali', 'Manjari', 'Manrope', 'Mansalva', 'Manuale', 'Marcellus', 'Marcellus SC', 'Marck Script', 'Margarine', 'Marhey', 'Markazi Text', 'Marko One', 'Marmelad', 'Martel', 'Martel Sans', 'Marvel', 'Mate', 'Mate SC', 'Maven Pro', 'McLaren', 'Mea Culpa', 'Meddon', 'MedievalSharp', 'Medula One', 'Meera Inimai', 'Megrim', 'Meie Script', 'Meow Script', 'Merienda', 'Merriweather', 'Merriweather Sans', 'Metal', 'Metal Mania', 'Metamorphous', 'Metrophobic', 'Michroma', 'Milonga', 'Miltonian', 'Miltonian Tattoo', 'Mina', 'Miniver', 'Miriam Libre', 'Mirza', 'Miss Fajardose', 'Mitr', 'Mochiy Pop One', 'Mochiy Pop P One', 'Modak', 'Modern Antiqua', 'Mogra', 'Mohave', 'Moirai One', 'Molengo', 'Molle', 'Monda', 'Monofett', 'Monoton', 'Monsieur La Doulaise', 'Montaga', 'Montagu Slab', 'MonteCarlo', 'Montez', 'Montserrat', 'Montserrat Alternates', 'Montserrat Subrayada', 'Moon Dance', 'Moul', 'Moulpali', 'Mountains of Christmas', 'Mouse Memoirs', 'Mr Bedfort', 'Mr Dafoe', 'Mr De Haviland', 'Mrs Saint Delafield', 'Mrs Sheppards', 'Mukta', 'Mukta Mahee', 'Mukta Malar', 'Mukta Vaani', 'Mulish', 'Murecho', 'MuseoModerno', 'My Soul', 'Mynerve', 'Mystery Quest', 'NTR', 'Nabla', 'Nanum Brush Script', 'Nanum Gothic', 'Nanum Gothic Coding', 'Nanum Myeongjo', 'Nanum Pen Script', 'Neonderthaw', 'Nerko One', 'Neucha', 'Neuton', 'New Rocker', 'New Tegomin', 'News Cycle', 'Newsreader', 'Niconne', 'Niramit', 'Nixie One', 'Nobile', 'Nokora', 'Norican', 'Nosifer', 'Notable', 'Nothing You Could Do', 'Noticia Text', 'Noto Color Emoji', 'Noto Emoji', 'Noto Kufi Arabic', 'Noto Music', 'Noto Naskh Arabic', 'Noto Nastaliq Urdu', 'Noto Sans', 'Noto Sans Arabic', 'Noto Sans Display', 'Noto Sans Mono', 'Noto Serif', 'Noto Serif Display', 'Nova Cut', 'Nova Flat', 'Nova Mono', 'Nova Oval', 'Nova Round', 'Nova Script', 'Nova Slim', 'Nova Square', 'Numans', 'Nunito', 'Nunito Sans', 'Odibee Sans', 'Odor Mean Chey', 'Offside', 'Oi', 'Old Standard TT', 'Oldenburg', 'Ole', 'Oleo Script', 'Oleo Script Swash Caps', 'Oooh Baby', 'Open Sans', 'Oranienbaum', 'Orbit', 'Orbitron', 'Oregano', 'Orelega One', 'Orienta', 'Original Surfer', 'Oswald', 'Outfit', 'Over the Rainbow', 'Overlock', 'Overlock SC', 'Overpass', 'Overpass Mono', 'Ovo', 'Oxanium', 'Oxygen', 'Oxygen Mono', 'PT Mono', 'PT Sans', 'PT Sans Caption', 'PT Sans Narrow', 'PT Serif', 'PT Serif Caption', 'Pacifico', 'Padauk', 'Padyakke Expanded One', 'Palanquin', 'Palanquin Dark', 'Palette Mosaic', 'Pangolin', 'Paprika', 'Parisienne', 'Passero One', 'Passion One', 'Passions Conflict', 'Pathway Extreme', 'Pathway Gothic One', 'Patrick Hand', 'Patrick Hand SC', 'Pattaya', 'Patua One', 'Pavanam', 'Paytone One', 'Peddana', 'Peralta', 'Permanent Marker', 'Petit Formal Script', 'Petrona', 'Philosopher', 'Phudu', 'Piazzolla', 'Piedra', 'Pinyon Script', 'Pirata One', 'Plaster', 'Play', 'Playball', 'Playfair Display', 'Playfair Display SC', 'Playpen Sans', 'Plus Jakarta Sans', 'Podkova', 'Poiret One', 'Poller One', 'Poltawski Nowy', 'Poly', 'Pompiere', 'Pontano Sans', 'Poor Story', 'Poppins', 'Port Lligat Sans', 'Port Lligat Slab', 'Potta One', 'Pragati Narrow', 'Praise', 'Prata', 'Preahvihear', 'Press Start 2P', 'Pridi', 'Princess Sofia', 'Prociono', 'Prompt', 'Prosto One', 'Proza Libre', 'Public Sans', 'Puppies Play', 'Puritan', 'Purple Purse', 'Pushster', 'Quando', 'Quantico', 'Quattrocento', 'Quattrocento Sans', 'Questrial', 'Quicksand', 'Quintessential', 'Qwigley', 'Qwitcher Grypen', 'REM', 'Racing Sans One', 'Radio Canada', 'Radley', 'Rajdhani', 'Rakkas', 'Raleway', 'Raleway Dots', 'Ramabhadra', 'Ramaraja', 'Rambla', 'Rammetto One', 'Rampart One', 'Ranchers', 'Rancho', 'Ranga', 'Rasa', 'Rationale', 'Ravi Prakash', 'Readex Pro', 'Recursive', 'Red Hat Display', 'Red Hat Mono', 'Red Hat Text', 'Red Rose', 'Redacted', 'Redacted Script', 'Redressed', 'Reem Kufi', 'Reem Kufi Fun', 'Reem Kufi Ink', 'Reenie Beanie', 'Reggae One', 'Revalia', 'Rhodium Libre', 'Ribeye', 'Ribeye Marrow', 'Righteous', 'Risque', 'Road Rage', 'RocknRoll One', 'Rokkitt', 'Romanesco', 'Ropa Sans', 'Rosario', 'Rosarivo', 'Rouge Script', 'Rowdies', 'Rozha One', 'Rubik', 'Rubik Beastly', 'Rubik Bubbles', 'Rubik Burned', 'Rubik Dirt', 'Rubik Distressed', 'Rubik Gemstones', 'Rubik Glitch', 'Rubik Iso', 'Rubik Marker Hatch', 'Rubik Maze', 'Rubik Microbe', 'Rubik Mono One', 'Rubik Moonrocks', 'Rubik Pixels', 'Rubik Puddles', 'Rubik Spray Paint', 'Rubik Storm', 'Rubik Vinyl', 'Rubik Wet Paint', 'Ruda', 'Rufina', 'Ruge Boogie', 'Ruluko', 'Rum Raisin', 'Ruslan Display', 'Russo One', 'Ruthie', 'Rye', 'STIX Two Text', 'Sacramento', 'Sahitya', 'Sail', 'Saira', 'Saira Condensed', 'Saira Extra Condensed', 'Saira Semi Condensed', 'Saira Stencil One', 'Salsa', 'Sanchez', 'Sancreek', 'Sansita', 'Sansita Swashed', 'Sarabun', 'Sarala', 'Sarina', 'Sarpanch', 'Sassybold', 'Satisfy', 'Sawarabi Gothic', 'Sawarabi Mincho', 'Scada', 'Scheherazade New', 'Schoolbell', 'Scope One', 'Seaweed Script', 'Secular One', 'Sedgwick Ave', 'Sedgwick Ave Display', 'Sen', 'Send Flowers', 'Sevillana', 'Seymour One', 'Shadows Into Light', 'Shadows Into Light Two', 'Shalimar', 'Shanti', 'Share', 'Share Tech', 'Share Tech Mono', 'Shippori Antique', 'Shippori Antique B1', 'Shippori Mincho', 'Shippori Mincho B1', 'Shizuru', 'Shojumaru', 'Short Stack', 'Shrikhand', 'Siemreap', 'Sigmar One', 'Signika', 'Signika Negative', 'Silkscreen', 'Simonetta', 'Single Day', 'Sintony', 'Sirin Stencil', 'Six Caps', 'Skranji', 'Slabo 13px', 'Slabo 27px', 'Slackey', 'Smokum', 'Smooch', 'Smooch Sans', 'Smythe', 'Sniglet', 'Snippet', 'Snowburst One', 'Sofadi One', 'Sofia', 'Sofia Sans', 'Sofia Sans Condensed', 'Sofia Sans Extra Condensed', 'Sofia Sans Semi Condensed', 'Solitreo', 'Solway', 'Song Myung', 'Sono', 'Sonsie One', 'Sora', 'Sorts Mill Goudy', 'Source Code Pro', 'Source Sans 3', 'Source Sans Pro', 'Source Serif 4', 'Source Serif Pro', 'Space Grotesk', 'Space Mono', 'Special Elite', 'Spectral', 'Spectral SC', 'Spicy Rice', 'Spinnaker', 'Spirax', 'Splash', 'Spline Sans', 'Spline Sans Mono', 'Squada One', 'Square Peg', 'Sree Krushnadevaraya', 'Sriracha', 'Srisakdi', 'Staatliches', 'Stalemate', 'Stalinist One', 'Stardos Stencil', 'Stick', 'Stick No Bills', 'Stint Ultra Condensed', 'Stint Ultra Expanded', 'Stoke', 'Strait', 'Style Script', 'Stylish', 'Sue Ellen Francisco', 'Suez One', 'Sulphur Point', 'Sumana', 'Sunflower', 'Sunshiney', 'Supermercado One', 'Sura', 'Suranna', 'Suravaram', 'Suwannaphum', 'Swanky and Moo Moo', 'Syncopate', 'Syne', 'Syne Mono', 'Syne Tactile', 'Tac One', 'Tai Heritage Pro', 'Tajawal', 'Tangerine', 'Tapestry', 'Taprom', 'Tauri', 'Taviraj', 'Teko', 'Telex', 'Tenali Ramakrishna', 'Tenor Sans', 'Text Me One', 'Texturina', 'Thasadith', 'The Girl Next Door', 'The Nautigal', 'Tienne', 'Tillana', 'Tilt Neon', 'Tilt Prism', 'Tilt Warp', 'Timmana', 'Tinos', 'Tiro Bangla', 'Tiro Devanagari Marathi', 'Tiro Devanagari Sanskrit', 'Tiro Gurmukhi', 'Tiro Kannada', 'Tiro Tamil', 'Tiro Telugu', 'Titan One', 'Titillium Web', 'Tomorrow', 'Tourney', 'Trade Winds', 'Train One', 'Trirong', 'Trispace', 'Trocchi', 'Trochut', 'Truculenta', 'Trykker', 'Tsukimi Rounded', 'Tulpen One', 'Turret Road', 'Twinkle Star', 'Ubuntu', 'Ubuntu Condensed', 'Ubuntu Mono', 'Uchen', 'Ultra', 'Unbounded', 'Uncial Antiqua', 'Underdog', 'Unica One', 'UnifrakturCook', 'UnifrakturMaguntia', 'Unkempt', 'Unlock', 'Unna', 'Updock', 'Urbanist', 'Vast Shadow', 'Vazirmatn', 'Vesper Libre', 'Viaoda Libre', 'Vibes', 'Vibur', 'Vidaloka', 'Viga', 'Voces', 'Volkhov', 'Vollkorn', 'Vollkorn SC', 'Voltaire', 'Vujahday Script', 'Waiting for the Sunrise', 'Wallpoet', 'Walter Turncoat', 'Warnes', 'Waterfall', 'Wavefont', 'Wellfleet', 'Wendy One', 'Whisper', 'WindSong', 'Wire One', 'Work Sans', 'Wix Madefor Display', 'Wix Madefor Text', 'Xanh Mono', 'Yaldevi', 'Yanone Kaffeesatz', 'Yantramanav', 'Yatra One', 'Yellowtail', 'Yeon Sung', 'Yeseva One', 'Yesteryear', 'Yomogi', 'Yrsa', 'Ysabeau', 'Ysabeau Infant', 'Ysabeau Office', 'Ysabeau SC', 'Yuji Boku', 'Yuji Hentaigana Akari', 'Yuji Hentaigana Akebono', 'Yuji Mai', 'Yuji Syuku', 'Yusei Magic', 'ZCOOL KuaiLe', 'ZCOOL QingKe HuangYou', 'ZCOOL XiaoWei', 'Zen Antique', 'Zen Antique Soft', 'Zen Dots', 'Zen Kaku Gothic Antique', 'Zen Kaku Gothic New', 'Zen Kurenaido', 'Zen Loop', 'Zen Maru Gothic', 'Zen Old Mincho', 'Zen Tokyo Zoo', 'Zeyada', 'Zhi Mang Xing', 'Zilla Slab', 'Zilla Slab Highlight'];
1832
1874
 
1875
+ // src/model/activity-log.js
1876
+ //
1877
+ // Turns what the user does into plain English sentences. Pure functions on
1878
+ // plain snapshot objects: no MST, no React, so it runs under plain node tests.
1879
+ // Never writes image data or URLs into a sentence.
1880
+
1881
+ var DEFAULT_OPTIONS = {
1882
+ includeTextContent: true,
1883
+ maxTextLength: 40,
1884
+ maxEntries: 300,
1885
+ maxSentenceLength: 200,
1886
+ mergeWindowMs: 1500
1887
+ };
1888
+ function clip(text, max) {
1889
+ var s = String(text == null ? '' : text);
1890
+ return s.length > max ? "".concat(s.slice(0, max), "\u2026") : s;
1891
+ }
1892
+ function imageSource(src) {
1893
+ var s = String(src || '');
1894
+ if (s.startsWith('data:') || s.startsWith('blob:')) return 'uploaded';
1895
+ if (s.toLowerCase().includes('unsplash')) return 'stock photo';
1896
+ return '';
1897
+ }
1898
+ function describeElement(el) {
1899
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
1900
+ var type = el && el.type;
1901
+ switch (type) {
1902
+ case 'text':
1903
+ {
1904
+ var text = el.text == null ? '' : String(el.text);
1905
+ if (!opts.includeTextContent || !text) return 'the text';
1906
+ return "the text \"".concat(clip(text, opts.maxTextLength), "\"");
1907
+ }
1908
+ case 'image':
1909
+ return 'the image';
1910
+ case 'figure':
1911
+ return el.subType ? "the shape (".concat(el.subType, ")") : 'the shape';
1912
+ case 'line':
1913
+ return 'the line';
1914
+ case 'group':
1915
+ return 'the group';
1916
+ case 'svg':
1917
+ return 'the graphic';
1918
+ default:
1919
+ return 'the element';
1920
+ }
1921
+ }
1922
+
1923
+ // ── Start, final and popup sentences ────────────────────────────────
1924
+
1925
+ var MAX_LISTED_TEXTS = 5;
1926
+ var HIDDEN_VALUE = '(value hidden)';
1927
+ function walk(children, fn) {
1928
+ (children || []).forEach(function (child) {
1929
+ if (!child) return;
1930
+ fn(child);
1931
+ if (child.children) walk(child.children, fn);
1932
+ });
1933
+ }
1934
+ function allElements(snapshot) {
1935
+ var out = [];
1936
+ (snapshot && snapshot.pages || []).forEach(function (page) {
1937
+ return walk(page && page.children, function (el) {
1938
+ return out.push(el);
1939
+ });
1940
+ });
1941
+ return out;
1942
+ }
1943
+ var num = function num(n) {
1944
+ return String(Number.isFinite(+n) ? +(+n).toFixed(2) : n);
1945
+ };
1946
+ function describeSize(snapshot) {
1947
+ var s = snapshot || {};
1948
+ return "".concat(num(s.width), " x ").concat(num(s.height), " ").concat(s.unit || 'px');
1949
+ }
1950
+ var plural = function plural(n, word) {
1951
+ return "".concat(n, " ").concat(word).concat(n === 1 ? '' : 's');
1952
+ };
1953
+ var COUNTED = [['text', 'text'], ['image', 'image'], ['figure', 'shape'], ['line', 'line'], ['svg', 'graphic']];
1954
+ function countParts(elements) {
1955
+ return COUNTED.map(function (_ref) {
1956
+ var _ref2 = _slicedToArray(_ref, 2),
1957
+ type = _ref2[0],
1958
+ word = _ref2[1];
1959
+ return [elements.filter(function (e) {
1960
+ return e.type === type;
1961
+ }).length, word];
1962
+ }).filter(function (_ref3) {
1963
+ var _ref4 = _slicedToArray(_ref3, 1),
1964
+ n = _ref4[0];
1965
+ return n > 0;
1966
+ }).map(function (_ref5) {
1967
+ var _ref6 = _slicedToArray(_ref5, 2),
1968
+ n = _ref6[0],
1969
+ word = _ref6[1];
1970
+ return plural(n, word);
1971
+ });
1972
+ }
1973
+ function joinWithAnd(parts) {
1974
+ if (parts.length <= 1) return parts.join('');
1975
+ return "".concat(parts.slice(0, -1).join(', '), " and ").concat(parts[parts.length - 1]);
1976
+ }
1977
+ function variableName(el) {
1978
+ var custom = el && el.custom || {};
1979
+ return custom.variableName || custom.promptText || 'the field';
1980
+ }
1981
+ function describeStart(snapshot) {
1982
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
1983
+ var elements = allElements(snapshot);
1984
+ var size = describeSize(snapshot);
1985
+ if (elements.length === 0) return ["Started from a blank label, ".concat(size, ".")];
1986
+ var parts = countParts(elements);
1987
+ var texts = elements.filter(function (e) {
1988
+ return e.type === 'text' && e.text;
1989
+ });
1990
+ if (opts.includeTextContent && texts.length && parts[0].endsWith(texts.length === 1 ? ' text' : ' texts')) {
1991
+ var listed = texts.slice(0, MAX_LISTED_TEXTS).map(function (e) {
1992
+ return "\"".concat(clip(e.text, opts.maxTextLength), "\"");
1993
+ }).join(', ');
1994
+ parts[0] = "".concat(parts[0], " (").concat(listed, ")");
1995
+ }
1996
+ var pages = (snapshot && snapshot.pages || []).length || 1;
1997
+ var sentences = ["Started from a template, ".concat(size, ", ").concat(plural(pages, 'page'), ", with ").concat(joinWithAnd(parts), ".")];
1998
+ var vars = elements.filter(function (e) {
1999
+ return e.custom && e.custom.inputField;
2000
+ });
2001
+ if (vars.length) {
2002
+ var named = vars.map(function (e) {
2003
+ return "\"".concat(variableName(e), "\" (").concat(e.custom.inputType || 'text', ")");
2004
+ }).join(', ');
2005
+ sentences.push("The template asked for ".concat(plural(vars.length, 'variable'), ": ").concat(named, "."));
2006
+ }
2007
+ return sentences;
2008
+ }
2009
+ function describeFinal(snapshot) {
2010
+ var parts = countParts(allElements(snapshot));
2011
+ return "Final label: ".concat([].concat(_toConsumableArray(parts.length ? parts : ['empty']), [describeSize(snapshot)]).join(', '), ".");
2012
+ }
2013
+ function describePopup() {
2014
+ var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2015
+ action = _ref7.action,
2016
+ field = _ref7.field,
2017
+ value = _ref7.value;
2018
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
2019
+ if (action === 'finish') return 'User finished the variable questions.';
2020
+ var custom = field && field.custom || {};
2021
+ var name = variableName(field);
2022
+ var shown = function shown(v) {
2023
+ return opts.includeTextContent ? clip(v, opts.maxTextLength) : HIDDEN_VALUE;
2024
+ };
2025
+ switch (action) {
2026
+ case 'skip':
2027
+ return custom.removeIfSkipped ? "User skipped variable \"".concat(name, "\"; the element was removed from the label.") : "User skipped variable \"".concat(name, "\".");
2028
+ case 'back':
2029
+ return "User went back to change variable \"".concat(name, "\".");
2030
+ case 'submit':
2031
+ break;
2032
+ default:
2033
+ return "User answered variable \"".concat(name, "\".");
2034
+ }
2035
+ switch (custom.inputType) {
2036
+ case 'radio':
2037
+ {
2038
+ var isOption = Array.isArray(custom.options) && custom.options.includes(value);
2039
+ return isOption ? "User chose \"".concat(shown(value), "\" for variable \"").concat(name, "\".") : "User typed their own answer \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2040
+ }
2041
+ case 'list':
2042
+ {
2043
+ var picked = String(value == null ? '' : value).split(', ').filter(Boolean).map(function (v) {
2044
+ return "\"".concat(shown(v), "\"");
2045
+ }).join(', ');
2046
+ return "User selected ".concat(picked, " for variable \"").concat(name, "\".");
2047
+ }
2048
+ case 'date':
2049
+ return "User picked the date \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2050
+ case 'integer':
2051
+ return "User entered the number ".concat(shown(value), " for variable \"").concat(name, "\".");
2052
+ case 'image':
2053
+ return "User uploaded an image for variable \"".concat(name, "\".");
2054
+ default:
2055
+ return "User entered \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2056
+ }
2057
+ }
2058
+
2059
+ // ── Diff: snapshot → sentences ──────────────────────────────────────
2060
+
2061
+ var words = function words(prop) {
2062
+ return String(prop).replace(/([A-Z])/g, ' $1').toLowerCase().trim();
2063
+ };
2064
+ var _short = function _short(v) {
2065
+ var s = String(v == null ? '' : v);
2066
+ return "".concat(s.length, ":").concat(s.slice(0, 40));
2067
+ };
2068
+ var isLocked = function isLocked(el) {
2069
+ return el.draggable === false && el.resizable === false && el.contentEditable === false && el.styleEditable === false;
2070
+ };
2071
+ var quotedText = function quotedText(el, n, opts) {
2072
+ return opts.includeTextContent && el.text ? "\"".concat(clip(el.text, opts.maxTextLength), "\"") : n;
2073
+ };
2074
+
2075
+ // One row per property group: how to read its value, and how to word the change.
2076
+ // A new property is one new row. `render(ctx)` returns (from, to) => sentence so a
2077
+ // merged entry can be re-worded with its first `from` and last `to`.
2078
+ var ROWS = [{
2079
+ key: 'text',
2080
+ props: ['text'],
2081
+ render: function render(_ref8) {
2082
+ var opts = _ref8.opts;
2083
+ return function (f, t) {
2084
+ return opts.includeTextContent ? "Changed the text \"".concat(clip(f, opts.maxTextLength), "\" to \"").concat(clip(t, opts.maxTextLength), "\".") : 'Changed the text.';
2085
+ };
2086
+ }
2087
+ }, {
2088
+ key: 'fontFamily',
2089
+ props: ['fontFamily'],
2090
+ render: function render(_ref9) {
2091
+ var n = _ref9.n;
2092
+ return function (f, t) {
2093
+ return "Changed the font of ".concat(n, " to ").concat(t, ".");
2094
+ };
2095
+ }
2096
+ }, {
2097
+ key: 'fontSize',
2098
+ props: ['fontSize'],
2099
+ render: function render(_ref0) {
2100
+ var n = _ref0.n;
2101
+ return function (f, t) {
2102
+ return "Changed the font size of ".concat(n, " from ").concat(f, " to ").concat(t, ".");
2103
+ };
2104
+ }
2105
+ }, {
2106
+ key: 'fill',
2107
+ props: ['fill'],
2108
+ render: function render(_ref1) {
2109
+ var n = _ref1.n;
2110
+ return function (f, t) {
2111
+ return "Changed the colour of ".concat(n, " to ").concat(t, ".");
2112
+ };
2113
+ }
2114
+ }, {
2115
+ key: 'position',
2116
+ props: ['x', 'y'],
2117
+ render: function render(_ref10) {
2118
+ var n = _ref10.n;
2119
+ return function () {
2120
+ return "Moved ".concat(n, ".");
2121
+ };
2122
+ }
2123
+ }, {
2124
+ key: 'size',
2125
+ props: ['width', 'height'],
2126
+ render: function render(_ref11) {
2127
+ var n = _ref11.n;
2128
+ return function () {
2129
+ return "Resized ".concat(n, ".");
2130
+ };
2131
+ }
2132
+ }, {
2133
+ key: 'rotation',
2134
+ props: ['rotation'],
2135
+ render: function render(_ref12) {
2136
+ var n = _ref12.n;
2137
+ return function (f, t) {
2138
+ return "Rotated ".concat(n, " to ").concat(t, " degrees.");
2139
+ };
2140
+ }
2141
+ }, {
2142
+ key: 'visible',
2143
+ props: ['visible'],
2144
+ render: function render(_ref13) {
2145
+ var n = _ref13.n;
2146
+ return function (f, t) {
2147
+ return t ? "Showed ".concat(n, ".") : "Hid ".concat(n, ".");
2148
+ };
2149
+ }
2150
+ }, {
2151
+ key: 'lock',
2152
+ props: ['draggable', 'resizable', 'contentEditable', 'styleEditable'],
2153
+ value: isLocked,
2154
+ render: function render(_ref14) {
2155
+ var n = _ref14.n;
2156
+ return function (f, t) {
2157
+ return t ? "Locked ".concat(n, ".") : "Unlocked ".concat(n, ".");
2158
+ };
2159
+ }
2160
+ }, {
2161
+ key: 'crop',
2162
+ props: ['cropX', 'cropY', 'cropWidth', 'cropHeight'],
2163
+ render: function render(_ref15) {
2164
+ var n = _ref15.n;
2165
+ return function () {
2166
+ return "Cropped ".concat(n, ".");
2167
+ };
2168
+ }
2169
+ }, {
2170
+ key: 'clipSrc',
2171
+ props: ['clipSrc'],
2172
+ render: function render(_ref16) {
2173
+ var n = _ref16.n;
2174
+ return function (f, t) {
2175
+ return t ? "Applied a mask to ".concat(n, ".") : "Removed the mask from ".concat(n, ".");
2176
+ };
2177
+ }
2178
+ }, {
2179
+ key: 'curveEnabled',
2180
+ props: ['curveEnabled'],
2181
+ render: function render(_ref17) {
2182
+ var n = _ref17.n,
2183
+ next = _ref17.next,
2184
+ opts = _ref17.opts;
2185
+ return function (f, t) {
2186
+ return t ? "Applied curved text to ".concat(quotedText(next, n, opts), ".") : "Removed the curve from ".concat(n, ".");
2187
+ };
2188
+ }
2189
+ }, {
2190
+ key: 'shadowEnabled',
2191
+ props: ['shadowEnabled'],
2192
+ render: function render(_ref18) {
2193
+ var n = _ref18.n;
2194
+ return function (f, t) {
2195
+ return t ? "Added a shadow to ".concat(n, ".") : "Removed the shadow from ".concat(n, ".");
2196
+ };
2197
+ }
2198
+ }, {
2199
+ key: 'grayscaleEnabled',
2200
+ props: ['grayscaleEnabled'],
2201
+ render: function render(_ref19) {
2202
+ var n = _ref19.n;
2203
+ return function (f, t) {
2204
+ return t ? "Made ".concat(n, " grayscale.") : "Removed the grayscale from ".concat(n, ".");
2205
+ };
2206
+ }
2207
+ }, {
2208
+ key: 'src',
2209
+ props: ['src'],
2210
+ value: function value(el) {
2211
+ return _short(el.src);
2212
+ },
2213
+ render: function render(_ref20) {
2214
+ var n = _ref20.n,
2215
+ next = _ref20.next;
2216
+ return function () {
2217
+ var source = imageSource(next.src);
2218
+ var note = source === 'uploaded' ? ' (uploaded by the user)' : source ? " (".concat(source, ")") : '';
2219
+ return "Replaced ".concat(n).concat(note, ".");
2220
+ };
2221
+ }
2222
+ }];
2223
+ var HANDLED = new Set(['id', 'type', 'custom', 'children'].concat(_toConsumableArray(ROWS.flatMap(function (r) {
2224
+ return r.props;
2225
+ }))));
2226
+ function rowValue(row, el) {
2227
+ if (row.value) return row.value(el);
2228
+ return row.props.length === 1 ? el[row.props[0]] : row.props.map(function (p) {
2229
+ return el[p];
2230
+ }).join(',');
2231
+ }
2232
+ function indexSnapshot(snapshot) {
2233
+ var pages = new Map();
2234
+ var elements = new Map();
2235
+ var orders = new Map();
2236
+ (snapshot && snapshot.pages || []).forEach(function (page) {
2237
+ if (!page) return;
2238
+ pages.set(page.id, page);
2239
+ var _visit = function visit(children, parentId) {
2240
+ orders.set(parentId, (children || []).filter(Boolean).map(function (c) {
2241
+ return c.id;
2242
+ }));
2243
+ (children || []).forEach(function (child) {
2244
+ if (!child) return;
2245
+ elements.set(child.id, {
2246
+ el: child,
2247
+ parentId: parentId
2248
+ });
2249
+ if (child.children) _visit(child.children, child.id);
2250
+ });
2251
+ };
2252
+ _visit(page.children, page.id);
2253
+ });
2254
+ return {
2255
+ pages: pages,
2256
+ elements: elements,
2257
+ orders: orders
2258
+ };
2259
+ }
2260
+ function indefinite(el, opts) {
2261
+ switch (el.type) {
2262
+ case 'text':
2263
+ return opts.includeTextContent && el.text ? "a text \"".concat(clip(el.text, opts.maxTextLength), "\"") : 'a text';
2264
+ case 'image':
2265
+ {
2266
+ var source = imageSource(el.src);
2267
+ var note = source === 'uploaded' ? ' (uploaded by the user)' : source ? " (".concat(source, ")") : '';
2268
+ return "an image".concat(note);
2269
+ }
2270
+ case 'figure':
2271
+ return el.subType ? "a shape (".concat(el.subType, ")") : 'a shape';
2272
+ case 'line':
2273
+ return 'a line';
2274
+ case 'group':
2275
+ return 'a group';
2276
+ case 'svg':
2277
+ return 'a graphic';
2278
+ default:
2279
+ return 'an element';
2280
+ }
2281
+ }
2282
+ var BACKGROUND_IMAGE = /^(https?:|data:|blob:|url\()/;
2283
+ function diffToEntries(prev, next) {
2284
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;
2285
+ if (!prev || !next) return [];
2286
+ var a = indexSnapshot(prev);
2287
+ var b = indexSnapshot(next);
2288
+ var out = [];
2289
+
2290
+ // Label size
2291
+ var sizeFrom = describeSize(prev);
2292
+ var sizeTo = describeSize(next);
2293
+ if (sizeFrom !== sizeTo) {
2294
+ out.push({
2295
+ key: 'label:size',
2296
+ from: sizeFrom,
2297
+ to: sizeTo,
2298
+ render: function render(f, t) {
2299
+ return "Changed the label size from ".concat(f, " to ").concat(t, ".");
2300
+ },
2301
+ sentence: "Changed the label size from ".concat(sizeFrom, " to ").concat(sizeTo, ".")
2302
+ });
2303
+ }
2304
+
2305
+ // Pages
2306
+ var addedPages = new Set(_toConsumableArray(b.pages.keys()).filter(function (id) {
2307
+ return !a.pages.has(id);
2308
+ }));
2309
+ var removedPages = new Set(_toConsumableArray(a.pages.keys()).filter(function (id) {
2310
+ return !b.pages.has(id);
2311
+ }));
2312
+ addedPages.forEach(function (id) {
2313
+ return out.push({
2314
+ key: "".concat(id, ":added"),
2315
+ sentence: 'Added a page.'
2316
+ });
2317
+ });
2318
+ removedPages.forEach(function (id) {
2319
+ return out.push({
2320
+ key: "".concat(id, ":removed"),
2321
+ sentence: 'Removed a page.'
2322
+ });
2323
+ });
2324
+
2325
+ // Added and removed elements (only the top of an added/removed subtree)
2326
+ var added = new Set(_toConsumableArray(b.elements.keys()).filter(function (id) {
2327
+ return !a.elements.has(id);
2328
+ }));
2329
+ var removed = new Set(_toConsumableArray(a.elements.keys()).filter(function (id) {
2330
+ return !b.elements.has(id);
2331
+ }));
2332
+ added.forEach(function (id) {
2333
+ var _b$elements$get = b.elements.get(id),
2334
+ el = _b$elements$get.el,
2335
+ parentId = _b$elements$get.parentId;
2336
+ if (added.has(parentId) || addedPages.has(parentId)) return;
2337
+ out.push({
2338
+ key: "".concat(id, ":added"),
2339
+ sentence: "Added ".concat(indefinite(el, opts), ".")
2340
+ });
2341
+ });
2342
+ removed.forEach(function (id) {
2343
+ var _a$elements$get = a.elements.get(id),
2344
+ el = _a$elements$get.el,
2345
+ parentId = _a$elements$get.parentId;
2346
+ if (removed.has(parentId) || removedPages.has(parentId)) return;
2347
+ out.push({
2348
+ key: "".concat(id, ":removed"),
2349
+ sentence: "Removed ".concat(describeElement(el, opts), ".")
2350
+ });
2351
+ });
2352
+
2353
+ // Changed elements
2354
+ b.elements.forEach(function (_ref21, id) {
2355
+ var nextEl = _ref21.el;
2356
+ var before = a.elements.get(id);
2357
+ if (!before) return;
2358
+ var prevEl = before.el;
2359
+ var ctx = {
2360
+ n: describeElement(nextEl, opts),
2361
+ prev: prevEl,
2362
+ next: nextEl,
2363
+ opts: opts
2364
+ };
2365
+ ROWS.forEach(function (row) {
2366
+ var from = rowValue(row, prevEl);
2367
+ var to = rowValue(row, nextEl);
2368
+ if (from === to || from === undefined && to === undefined) return;
2369
+ var render = row.render(ctx);
2370
+ out.push({
2371
+ key: "".concat(id, ":").concat(row.key),
2372
+ from: from,
2373
+ to: to,
2374
+ render: render,
2375
+ sentence: render(from, to)
2376
+ });
2377
+ });
2378
+ var props = new Set([].concat(_toConsumableArray(Object.keys(prevEl)), _toConsumableArray(Object.keys(nextEl))));
2379
+ props.forEach(function (prop) {
2380
+ if (HANDLED.has(prop)) return;
2381
+ var from = JSON.stringify(prevEl[prop]);
2382
+ var to = JSON.stringify(nextEl[prop]);
2383
+ if (from === to) return;
2384
+ out.push({
2385
+ key: "".concat(id, ":").concat(prop),
2386
+ from: from,
2387
+ to: to,
2388
+ sentence: "Changed the ".concat(words(prop), " of ").concat(ctx.n, ".")
2389
+ });
2390
+ });
2391
+ });
2392
+
2393
+ // Layer order within each parent, for elements present before and after
2394
+ b.orders.forEach(function (nextIds, parentId) {
2395
+ var prevIds = a.orders.get(parentId);
2396
+ if (!prevIds) return;
2397
+ var common = new Set(nextIds.filter(function (id) {
2398
+ return prevIds.includes(id);
2399
+ }));
2400
+ var pOrder = prevIds.filter(function (id) {
2401
+ return common.has(id);
2402
+ });
2403
+ var nOrder = nextIds.filter(function (id) {
2404
+ return common.has(id);
2405
+ });
2406
+ if (pOrder.join('|') === nOrder.join('|')) return;
2407
+ var mover = nOrder.find(function (c) {
2408
+ var p = pOrder.filter(function (id) {
2409
+ return id !== c;
2410
+ }).join('|');
2411
+ var n = nOrder.filter(function (id) {
2412
+ return id !== c;
2413
+ }).join('|');
2414
+ return p === n;
2415
+ });
2416
+ if (!mover) {
2417
+ out.push({
2418
+ key: "".concat(parentId, ":order"),
2419
+ sentence: 'Changed the layer order.'
2420
+ });
2421
+ return;
2422
+ }
2423
+ var name = describeElement(b.elements.get(mover).el, opts);
2424
+ var pos = nOrder.indexOf(mover);
2425
+ var sentence = pos === nOrder.length - 1 ? "Brought ".concat(name, " to the front.") : pos === 0 ? "Sent ".concat(name, " to the back.") : "Changed the layer order of ".concat(name, ".");
2426
+ out.push({
2427
+ key: "".concat(mover, ":order"),
2428
+ sentence: sentence
2429
+ });
2430
+ });
2431
+
2432
+ // Page background
2433
+ b.pages.forEach(function (page, id) {
2434
+ var before = a.pages.get(id);
2435
+ if (!before) return;
2436
+ var from = before.background || '';
2437
+ var to = page.background || '';
2438
+ if (from === to) return;
2439
+ var sentence = !to ? 'Removed the background.' : BACKGROUND_IMAGE.test(to) ? 'Set an image as the background.' : "Changed the background colour to ".concat(to, ".");
2440
+ out.push({
2441
+ key: "".concat(id, ":background"),
2442
+ sentence: sentence
2443
+ });
2444
+ });
2445
+ return out;
2446
+ }
2447
+
2448
+ // ── Tracker: keeps the log, merges quick repeats, caps the size ─────
2449
+
2450
+ var ActivityTracker = /*#__PURE__*/function () {
2451
+ function ActivityTracker() {
2452
+ var getOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
2453
+ return DEFAULT_OPTIONS;
2454
+ };
2455
+ var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now;
2456
+ _classCallCheck(this, ActivityTracker);
2457
+ this._getOptions = getOptions;
2458
+ this._now = now;
2459
+ this.clear();
2460
+ }
2461
+ return _createClass(ActivityTracker, [{
2462
+ key: "_opts",
2463
+ get: function get() {
2464
+ return _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), this._getOptions() || {});
2465
+ }
2466
+ }, {
2467
+ key: "clear",
2468
+ value: function clear() {
2469
+ this._start = [];
2470
+ this._actions = [];
2471
+ this._dropped = false;
2472
+ this._baseline = null;
2473
+ }
2474
+ }, {
2475
+ key: "reset",
2476
+ value: function reset(snapshot) {
2477
+ var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2478
+ this.clear();
2479
+ if (!snapshot) return;
2480
+ this._baseline = snapshot;
2481
+ this._start = [].concat(_toConsumableArray(describeStart(snapshot, this._opts)), _toConsumableArray(extra));
2482
+ }
2483
+ }, {
2484
+ key: "rebaseline",
2485
+ value: function rebaseline(snapshot) {
2486
+ if (snapshot) this._baseline = snapshot;
2487
+ }
2488
+
2489
+ // The canvas sometimes rewrites an element by itself (e.g. re-measuring a text's height once a
2490
+ // font has loaded). That is not something the user did, so fold it into the baseline for just
2491
+ // that element: the next commit then won't report it, and the user's own pending changes stay.
2492
+ }, {
2493
+ key: "patchBaseline",
2494
+ value: function patchBaseline(id, attrs) {
2495
+ if (!id || !this._baseline) return;
2496
+ var _patch = function patch(children) {
2497
+ return (children || []).map(function (child) {
2498
+ if (!child) return child;
2499
+ if (child.id === id) return _objectSpread2(_objectSpread2({}, child), attrs);
2500
+ return child.children ? _objectSpread2(_objectSpread2({}, child), {}, {
2501
+ children: _patch(child.children)
2502
+ }) : child;
2503
+ });
2504
+ };
2505
+ this._baseline = _objectSpread2(_objectSpread2({}, this._baseline), {}, {
2506
+ pages: (this._baseline.pages || []).map(function (page) {
2507
+ return page ? _objectSpread2(_objectSpread2({}, page), {}, {
2508
+ children: _patch(page.children)
2509
+ }) : page;
2510
+ })
2511
+ });
2512
+ }
2513
+ }, {
2514
+ key: "onCommit",
2515
+ value: function onCommit(snapshot) {
2516
+ var _this = this;
2517
+ if (!snapshot) return;
2518
+ var previous = this._baseline;
2519
+ this._baseline = snapshot;
2520
+ if (!previous) return;
2521
+ diffToEntries(previous, snapshot, this._opts).forEach(function (entry) {
2522
+ return _this._add(entry);
2523
+ });
2524
+ }
2525
+ }, {
2526
+ key: "record",
2527
+ value: function record(sentence, key) {
2528
+ this._add({
2529
+ key: key,
2530
+ sentence: String(sentence)
2531
+ });
2532
+ }
2533
+ }, {
2534
+ key: "undone",
2535
+ value: function undone(snapshot) {
2536
+ this._add({
2537
+ sentence: 'Undid the last change.'
2538
+ });
2539
+ this.rebaseline(snapshot);
2540
+ }
2541
+ }, {
2542
+ key: "redone",
2543
+ value: function redone(snapshot) {
2544
+ this._add({
2545
+ sentence: 'Redid the last change.'
2546
+ });
2547
+ this.rebaseline(snapshot);
2548
+ }
2549
+ }, {
2550
+ key: "getLog",
2551
+ value: function getLog(finalSnapshot) {
2552
+ var maxSentenceLength = this._opts.maxSentenceLength;
2553
+ var lines = _toConsumableArray(this._start);
2554
+ if (this._dropped) lines.push('Earlier actions were left out.');
2555
+ this._actions.forEach(function (a) {
2556
+ return lines.push(a.sentence);
2557
+ });
2558
+ if (finalSnapshot) lines.push(describeFinal(finalSnapshot));
2559
+ return lines.map(function (line) {
2560
+ return clip(line, maxSentenceLength);
2561
+ });
2562
+ }
2563
+ }, {
2564
+ key: "_add",
2565
+ value: function _add(entry) {
2566
+ var at = this._now();
2567
+ var last = this._actions[this._actions.length - 1];
2568
+ var _this$_opts = this._opts,
2569
+ mergeWindowMs = _this$_opts.mergeWindowMs,
2570
+ maxEntries = _this$_opts.maxEntries;
2571
+ if (entry.key && last && last.key === entry.key && at - last.at <= mergeWindowMs) {
2572
+ if (entry.render && last.render) {
2573
+ if (last.from === entry.to) {
2574
+ this._actions.pop();
2575
+ return;
2576
+ }
2577
+ this._actions[this._actions.length - 1] = _objectSpread2(_objectSpread2({}, entry), {}, {
2578
+ from: last.from,
2579
+ at: at,
2580
+ sentence: entry.render(last.from, entry.to)
2581
+ });
2582
+ } else {
2583
+ this._actions[this._actions.length - 1] = _objectSpread2(_objectSpread2({}, entry), {}, {
2584
+ at: at
2585
+ });
2586
+ }
2587
+ return;
2588
+ }
2589
+ this._actions.push(_objectSpread2(_objectSpread2({}, entry), {}, {
2590
+ at: at
2591
+ }));
2592
+ if (this._actions.length > maxEntries) {
2593
+ this._actions.shift();
2594
+ this._dropped = true;
2595
+ }
2596
+ }
2597
+ }]);
2598
+ }();
2599
+
2600
+ // ── Options singleton ───────────────────────────────────────────────
2601
+ // Window-level, like the other config: each Rollup output bundle gets its own
2602
+ // copy of this module, so a closure variable set from one would never be seen
2603
+ // by another.
2604
+
2605
+ var OPTIONS_KEY = '__labellife_activity_log_options__';
2606
+ function setActivityLogOptions(options) {
2607
+ if (typeof window === 'undefined') return;
2608
+ window[OPTIONS_KEY] = _objectSpread2(_objectSpread2({}, window[OPTIONS_KEY] || {}), options || {});
2609
+ }
2610
+ function getActivityLogOptions() {
2611
+ var set = typeof window !== 'undefined' && window[OPTIONS_KEY] || {};
2612
+ return _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), set);
2613
+ }
2614
+
1833
2615
  var _excluded$5 = ["mimeType", "quality", "dpi", "dpiMetadata"],
1834
2616
  _excluded2$1 = ["mimeType", "quality"],
1835
2617
  _excluded3$1 = ["fileName"],
@@ -1946,7 +2728,9 @@ var Store = types.model('Store', {
1946
2728
  // incremented after each font load to trigger canvas re-render
1947
2729
  _pendingInputFields: [],
1948
2730
  // elements awaiting user input after loadJSON
1949
- customFonts: [] // host-injected custom font catalog: [{ name, variants: [{weight,style,file}] }]
2731
+ customFonts: [],
2732
+ // host-injected custom font catalog: [{ name, variants: [{weight,style,file}] }]
2733
+ _activity: new ActivityTracker(getActivityLogOptions) // plain-English log of what the user did
1950
2734
  };
1951
2735
  }).views(function (self) {
1952
2736
  return {
@@ -2107,6 +2891,8 @@ var Store = types.model('Store', {
2107
2891
  if (self.pages.length > 0 && !self._activePageId) {
2108
2892
  self._activePageId = self.pages[0].id;
2109
2893
  }
2894
+ // A store that never loads a template still needs a baseline for the activity log.
2895
+ self._resetActivity();
2110
2896
  },
2111
2897
  set: function set(attrs) {
2112
2898
  for (var _i2 = 0, _Object$entries2 = Object.entries(attrs); _i2 < _Object$entries2.length; _i2++) {
@@ -2767,6 +3553,7 @@ var Store = types.model('Store', {
2767
3553
  self.history.clear();
2768
3554
  self.history.addUndoState();
2769
3555
  }
3556
+ self._resetActivity();
2770
3557
 
2771
3558
  // Auto-load fonts referenced in text elements
2772
3559
  self._autoLoadFonts(data);
@@ -2791,6 +3578,67 @@ var Store = types.model('Store', {
2791
3578
  self.history.clear();
2792
3579
  self.history.addUndoState();
2793
3580
  }
3581
+ self._resetActivity();
3582
+ },
3583
+ // ── Activity log: plain-English record of what the user did ─────
3584
+ _activitySnapshot: function _activitySnapshot() {
3585
+ var snapshot = _objectSpread2({}, getSnapshot(self));
3586
+ delete snapshot.history;
3587
+ return snapshot;
3588
+ },
3589
+ _resetActivity: function _resetActivity() {
3590
+ try {
3591
+ self._activity.reset(self._activitySnapshot());
3592
+ } catch (e) {
3593
+ console.warn('Activity log: failed to reset', e);
3594
+ }
3595
+ },
3596
+ getActivityLog: function getActivityLog() {
3597
+ try {
3598
+ return self._activity.getLog(self._activitySnapshot());
3599
+ } catch (e) {
3600
+ console.warn('Activity log: failed to read', e);
3601
+ return [];
3602
+ }
3603
+ },
3604
+ recordActivity: function recordActivity(sentence) {
3605
+ try {
3606
+ self._activity.record(sentence);
3607
+ } catch (e) {
3608
+ console.warn('Activity log: failed to record', e);
3609
+ }
3610
+ },
3611
+ // For changes the canvas makes by itself (not the user): keeps them out of the log.
3612
+ syncActivityBaseline: function syncActivityBaseline(id, attrs) {
3613
+ try {
3614
+ self._activity.patchBaseline(id, attrs);
3615
+ } catch (e) {
3616
+ console.warn('Activity log: failed to sync baseline', e);
3617
+ }
3618
+ },
3619
+ clearActivityLog: function clearActivityLog() {
3620
+ // Keep the baseline at the current state so the next change is still logged.
3621
+ self._activity.clear();
3622
+ self._activity.rebaseline(self._activitySnapshot());
3623
+ },
3624
+ // Called by the input-fields popup. Logs the answer, then re-baselines so the
3625
+ // change it wrote into the element is not logged a second time.
3626
+ logPopupAnswer: function logPopupAnswer() {
3627
+ var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3628
+ action = _ref11.action,
3629
+ field = _ref11.field,
3630
+ value = _ref11.value;
3631
+ try {
3632
+ // 'finish' can arrive twice (answer handler and a host dialog's onComplete): key it so it merges.
3633
+ self._activity.record(describePopup({
3634
+ action: action,
3635
+ field: field,
3636
+ value: value
3637
+ }, getActivityLogOptions()), action === 'finish' ? 'popup:finish' : undefined);
3638
+ self._activity.rebaseline(self._activitySnapshot());
3639
+ } catch (e) {
3640
+ console.warn('Activity log: failed to record popup answer', e);
3641
+ }
2794
3642
  },
2795
3643
  addFont: function addFont(font) {
2796
3644
  var existing = self.fonts.find(function (f) {
@@ -3015,11 +3863,11 @@ var Store = types.model('Store', {
3015
3863
  };
3016
3864
  });
3017
3865
  function createStore() {
3018
- var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3019
- _ref11$key = _ref11.key,
3020
- key = _ref11$key === void 0 ? '' : _ref11$key,
3021
- _ref11$showCredit = _ref11.showCredit,
3022
- showCredit = _ref11$showCredit === void 0 ? false : _ref11$showCredit;
3866
+ var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3867
+ _ref12$key = _ref12.key,
3868
+ key = _ref12$key === void 0 ? '' : _ref12$key,
3869
+ _ref12$showCredit = _ref12.showCredit,
3870
+ showCredit = _ref12$showCredit === void 0 ? false : _ref12$showCredit;
3023
3871
  var store = Store.create({});
3024
3872
  store._initConfig(key, showCredit);
3025
3873
  return store;
@@ -11574,10 +12422,25 @@ function computeCurvedCacheBounds(element) {
11574
12422
  function syncHeightKeepingCenter(element, newHeight) {
11575
12423
  if (Math.abs(newHeight - element.height) <= 1) return;
11576
12424
  var deltaY = (newHeight - element.height) / 2;
11577
- element.set({
12425
+ var attrs = {
11578
12426
  height: newHeight,
11579
12427
  y: element.y - deltaY
11580
- });
12428
+ };
12429
+ element.set(attrs);
12430
+ // An automatic re-layout, not a user action: keep it out of the activity log.
12431
+ if (element.store && element.store.syncActivityBaseline) {
12432
+ element.store.syncActivityBaseline(element.id, attrs);
12433
+ }
12434
+ }
12435
+
12436
+ // Safari doesn't make a webfont available to canvas (not even to measureText) until some
12437
+ // canvas has actually drawn text with it, so loading alone isn't enough: draw once on a
12438
+ // hidden canvas to activate the face, then measure.
12439
+ var _scratchCtx = null;
12440
+ function primeCanvasFont(font, text) {
12441
+ if (!_scratchCtx) _scratchCtx = document.createElement('canvas').getContext('2d');
12442
+ _scratchCtx.font = font;
12443
+ _scratchCtx.fillText(text || 'Hamburgefonstiv', 0, 0);
11581
12444
  }
11582
12445
 
11583
12446
  // Safari can resolve document.fonts.load() (and fire loadingdone) before the canvas
@@ -11597,6 +12460,7 @@ function waitForCanvasFont(fontSpec, family, sample, isCancelled) {
11597
12460
  var frames = 0;
11598
12461
  var _check = function check() {
11599
12462
  if (isCancelled() || frames >= FONT_READY_MAX_FRAMES) return resolve();
12463
+ primeCanvasFont("".concat(fontSpec, " \"").concat(family, "\", serif"), text);
11600
12464
  var withFont = widthWith("".concat(fontSpec, " \"").concat(family, "\", serif"));
11601
12465
  var withFallbackSerif = widthWith("".concat(fontSpec, " serif"));
11602
12466
  var withFallbackSans = widthWith("".concat(fontSpec, " sans-serif"));
@@ -11607,6 +12471,28 @@ function waitForCanvasFont(fontSpec, family, sample, isCancelled) {
11607
12471
  _check();
11608
12472
  });
11609
12473
  }
12474
+
12475
+ // TEMPORARY font-timing diagnostics. Enable in the browser console with
12476
+ // window.__labellifeFontDebug = true
12477
+ // before loading a template, then copy the "[font-debug]" lines. Remove once Safari is sorted.
12478
+ function fontDebug(label, element, node) {
12479
+ if (typeof window === 'undefined' || !window.__labellifeFontDebug) return;
12480
+ try {
12481
+ var family = element.fontFamily;
12482
+ var faces = [];
12483
+ document.fonts.forEach(function (f) {
12484
+ if (f.family.replace(/["']/g, '') === family) faces.push("".concat(f.weight, "/").concat(f.status, "/").concat(f.unicodeRange.slice(0, 18)));
12485
+ });
12486
+ var lines = node && node.textArr ? node.textArr.map(function (l) {
12487
+ return Math.round(l.width);
12488
+ }) : null;
12489
+ // eslint-disable-next-line no-console
12490
+ console.log("[font-debug] t=".concat(Math.round(performance.now()), " ").concat(label, " family=\"").concat(family, "\" ") + "check=".concat(document.fonts.check("16px \"".concat(family, "\"")), " faces=").concat(JSON.stringify(faces), " ") + "boxW=".concat(Math.round(element.width), " nodeW=").concat(node ? Math.round(node.width()) : '-', " ") + "lineWidths=".concat(JSON.stringify(lines), " lines=").concat(lines ? lines.length : '-'));
12491
+ } catch (e) {
12492
+ // eslint-disable-next-line no-console
12493
+ console.log('[font-debug] failed', e);
12494
+ }
12495
+ }
11610
12496
  var TextElementComponent = observer(function (_ref) {
11611
12497
  var _element$backgroundOp;
11612
12498
  var element = _ref.element;
@@ -11634,6 +12520,7 @@ var TextElementComponent = observer(function (_ref) {
11634
12520
  var _node$getLayer2;
11635
12521
  var node = textRef.current;
11636
12522
  if (!node) return;
12523
+ fontDebug('relayout:before', element, node);
11637
12524
 
11638
12525
  // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
11639
12526
  // every draw (no internal cached layout like Konva.Text has), so
@@ -11644,9 +12531,21 @@ var TextElementComponent = observer(function (_ref) {
11644
12531
  (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11645
12532
  return;
11646
12533
  }
11647
- var f = node.fontFamily();
11648
- node.fontFamily('serif');
11649
- node.fontFamily(f);
12534
+
12535
+ // Re-run Konva's own layout directly — what changing `align` does, which is the manual
12536
+ // workaround that fixes this in Safari. Toggling fontFamily is the fallback if the
12537
+ // private method is ever removed.
12538
+ if (typeof node._getContextFont === 'function') {
12539
+ primeCanvasFont(node._getContextFont(), node.text());
12540
+ }
12541
+ if (typeof node._setTextData === 'function') {
12542
+ node._setTextData();
12543
+ } else {
12544
+ var f = node.fontFamily();
12545
+ node.fontFamily('serif');
12546
+ node.fontFamily(f);
12547
+ }
12548
+ fontDebug('relayout:after', element, node);
11650
12549
  var h = node.height();
11651
12550
  if (h > 0) {
11652
12551
  setTextHeight(h);
@@ -11658,12 +12557,16 @@ var TextElementComponent = observer(function (_ref) {
11658
12557
  }
11659
12558
  (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11660
12559
  };
12560
+ useEffect(function () {
12561
+ fontDebug('mount', element, textRef.current);
12562
+ }, []);
11661
12563
 
11662
12564
  // Any font finishing a load (covers fonts requested elsewhere, e.g. store.loadFont).
11663
12565
  useEffect(function () {
11664
12566
  // Two frames' delay: Safari's canvas can still be on the fallback at event time.
11665
12567
  var onFontLoaded = function onFontLoaded() {
11666
- return requestAnimationFrame(function () {
12568
+ fontDebug('loadingdone', element, textRef.current);
12569
+ requestAnimationFrame(function () {
11667
12570
  return requestAnimationFrame(function () {
11668
12571
  var _relayoutRef$current;
11669
12572
  return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
@@ -11694,8 +12597,17 @@ var TextElementComponent = observer(function (_ref) {
11694
12597
  var _relayoutRef$current2;
11695
12598
  if (!cancelled) (_relayoutRef$current2 = relayoutRef.current) === null || _relayoutRef$current2 === void 0 || _relayoutRef$current2.call(relayoutRef);
11696
12599
  })["catch"](function () {});
12600
+ // Safari can still be on fallback metrics after the checks above, and re-measuring is
12601
+ // idempotent, so repeat a few times while the page settles.
12602
+ var retryTimers = [300, 1000, 2500].map(function (ms) {
12603
+ return setTimeout(function () {
12604
+ var _relayoutRef$current3;
12605
+ if (!cancelled) (_relayoutRef$current3 = relayoutRef.current) === null || _relayoutRef$current3 === void 0 || _relayoutRef$current3.call(relayoutRef);
12606
+ }, ms);
12607
+ });
11697
12608
  return function () {
11698
12609
  cancelled = true;
12610
+ retryTimers.forEach(clearTimeout);
11699
12611
  };
11700
12612
  }, [element.fontFamily, element.fontWeight, element.fontStyle]);
11701
12613
 
@@ -11877,10 +12789,10 @@ var TextElementComponent = observer(function (_ref) {
11877
12789
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11878
12790
  if (removed) return;
11879
12791
  removed = true;
11880
- element.set({
11881
- text: cancel ? originalText : textarea.value
12792
+ element.finishEdit({
12793
+ text: cancel ? originalText : textarea.value,
12794
+ originalText: originalText
11882
12795
  });
11883
- element.toggleEditMode(false);
11884
12796
  if (textareaRef.current === textarea) textareaRef.current = null;
11885
12797
  if (textarea.parentNode) {
11886
12798
  textarea.parentNode.removeChild(textarea);
@@ -13180,6 +14092,17 @@ var InputFieldsDialog = observer(function (_ref2) {
13180
14092
  var config = getInputFieldsConfig();
13181
14093
  var pendingFields = store._pendingInputFields || [];
13182
14094
 
14095
+ // Plain-English activity log (see model/activity-log.js). Called after the
14096
+ // element has been updated so the log can re-baseline past that change.
14097
+ var logAnswer = function logAnswer(action, el, value) {
14098
+ if (typeof store.logPopupAnswer !== 'function') return;
14099
+ store.logPopupAnswer({
14100
+ action: action,
14101
+ field: el ? getSnapshot(el) : undefined,
14102
+ value: value
14103
+ });
14104
+ };
14105
+
13183
14106
  // When disabled, clear any pending fields so they are treated as skipped
13184
14107
  useEffect(function () {
13185
14108
  if (!enabled && pendingFields.length > 0) {
@@ -13235,6 +14158,7 @@ var InputFieldsDialog = observer(function (_ref2) {
13235
14158
  text: previousValue || ''
13236
14159
  });
13237
14160
  }
14161
+ logAnswer('back', el);
13238
14162
  isGoingBackRef.current = true;
13239
14163
  store._unresolveInputField(el);
13240
14164
  }
@@ -13282,9 +14206,11 @@ var InputFieldsDialog = observer(function (_ref2) {
13282
14206
  });
13283
14207
  }
13284
14208
  }
14209
+ logAnswer('submit', el, value);
13285
14210
  store._resolveInputField(elementId);
13286
14211
  if (fields.length <= 1) {
13287
14212
  _flushRemovedElements();
14213
+ logAnswer('finish');
13288
14214
  store.history.addUndoState();
13289
14215
  if (_onComplete) _onComplete();
13290
14216
  } else {
@@ -13310,10 +14236,12 @@ var InputFieldsDialog = observer(function (_ref2) {
13310
14236
  skipped: true,
13311
14237
  removed: shouldRemove
13312
14238
  });
14239
+ logAnswer('skip', el);
13313
14240
  store._resolveInputField(elementId);
13314
14241
  if (fields.length <= 1) {
13315
14242
  var hadRemovals = removedDueToSkipRef.current.length > 0;
13316
14243
  _flushRemovedElements();
14244
+ logAnswer('finish');
13317
14245
  if (hadRemovals) store.history.addUndoState();
13318
14246
  if (_onComplete) _onComplete();
13319
14247
  } else {
@@ -13344,6 +14272,7 @@ var InputFieldsDialog = observer(function (_ref2) {
13344
14272
  text: previousValue || ''
13345
14273
  });
13346
14274
  }
14275
+ logAnswer('back', el);
13347
14276
  store._unresolveInputField(el);
13348
14277
  }
13349
14278
  setDisplayIndex(function (prev) {
@@ -13378,6 +14307,7 @@ var InputFieldsDialog = observer(function (_ref2) {
13378
14307
  canGoBack: canGoBack,
13379
14308
  onComplete: function onComplete() {
13380
14309
  _flushRemovedElements();
14310
+ logAnswer('finish');
13381
14311
  store.history.addUndoState();
13382
14312
  if (_onComplete) _onComplete();
13383
14313
  }
@@ -14133,5 +15063,5 @@ function WorkspaceWrap(_ref3) {
14133
15063
  }));
14134
15064
  }
14135
15065
 
14136
- export { BackgroundSection, DEFAULT_FONTS, DEFAULT_SECTIONS, DesignContainer, ElementsSection, ImagesGrid, InputFieldsDialog, InputFieldsSection, LayersSection, PolotnoContainer, SectionTab, SidePanel, SidePanelWrap, Store, TextSection, Toolbar, UploadSection, Workspace, WorkspaceWrap, ZoomButtons, createStore, cropImage, fetchGoogleFonts, getImageSize, getInputFieldsConfig, getTheme, getTranslations, getUnsplashSearchUrl, getUnsplashTrackDownloadUrl, loadGoogleFont, loadImage, popupActionButtonSx, pxToUnit, setInputFieldsConfig, setTheme, setTranslations, setUnsplashSearchUrl, setUnsplashTrackDownloadUrl, t, unitToPx };
15066
+ export { BackgroundSection, DEFAULT_FONTS, DEFAULT_SECTIONS, DesignContainer, ElementsSection, ImagesGrid, InputFieldsDialog, InputFieldsSection, LayersSection, PolotnoContainer, SectionTab, SidePanel, SidePanelWrap, Store, TextSection, Toolbar, UploadSection, Workspace, WorkspaceWrap, ZoomButtons, createStore, cropImage, fetchGoogleFonts, getActivityLogOptions, getImageSize, getInputFieldsConfig, getTheme, getTranslations, getUnsplashSearchUrl, getUnsplashTrackDownloadUrl, loadGoogleFont, loadImage, popupActionButtonSx, pxToUnit, setActivityLogOptions, setInputFieldsConfig, setTheme, setTranslations, setUnsplashSearchUrl, setUnsplashTrackDownloadUrl, t, unitToPx };
14137
15067
  //# sourceMappingURL=index.js.map