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/cjs/index.js CHANGED
@@ -104,6 +104,20 @@ function _asyncToGenerator(n) {
104
104
  });
105
105
  };
106
106
  }
107
+ function _classCallCheck(a, n) {
108
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
109
+ }
110
+ function _defineProperties(e, r) {
111
+ for (var t = 0; t < r.length; t++) {
112
+ var o = r[t];
113
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
114
+ }
115
+ }
116
+ function _createClass(e, r, t) {
117
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
118
+ writable: false
119
+ }), e;
120
+ }
107
121
  function _createForOfIteratorHelper(r, e) {
108
122
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
109
123
  if (!t) {
@@ -1003,6 +1017,22 @@ var TextElement = Shape.named('TextElement').props({
1003
1017
  return {
1004
1018
  toggleEditMode: function toggleEditMode(editing) {
1005
1019
  self._editModeEnabled = editing !== undefined ? editing : !self._editModeEnabled;
1020
+ },
1021
+ // Ends an inline text edit. The canvas editor writes the text on every keystroke
1022
+ // without recording a history state, so the finished edit is committed here (once,
1023
+ // and only when the text really changed). That makes it undoable and lets the
1024
+ // activity log see it.
1025
+ finishEdit: function finishEdit(_ref) {
1026
+ var text = _ref.text,
1027
+ originalText = _ref.originalText;
1028
+ self.text = text;
1029
+ self._editModeEnabled = false;
1030
+ if (text === originalText) return;
1031
+ try {
1032
+ mobxStateTree.getRoot(self).history.addUndoState();
1033
+ } catch (e) {
1034
+ console.warn('Text edit: failed to record history state', e);
1035
+ }
1006
1036
  }
1007
1037
  };
1008
1038
  });
@@ -1568,10 +1598,20 @@ var History = mobxStateTree.types.model('History', {
1568
1598
  self.history.splice(0, self.history.length - 100);
1569
1599
  self.undoIdx = self.history.length - 1;
1570
1600
  }
1601
+ self._notifyActivity('onCommit', stateToSave);
1571
1602
  } catch (e) {
1572
1603
  console.warn('History: failed to save state', e);
1573
1604
  }
1574
1605
  },
1606
+ // Feeds the plain-English activity log; it must never break editing.
1607
+ _notifyActivity: function _notifyActivity(method, snapshot) {
1608
+ try {
1609
+ var tracker = mobxStateTree.getRoot(self)._activity;
1610
+ if (tracker) tracker[method](snapshot);
1611
+ } catch (e) {
1612
+ console.warn('Activity log: failed to update', e);
1613
+ }
1614
+ },
1575
1615
  _restoreState: function _restoreState(state) {
1576
1616
  if (!state) return;
1577
1617
  self._ignoring = true;
@@ -1630,11 +1670,13 @@ var History = mobxStateTree.types.model('History', {
1630
1670
  if (!self.canUndo) return;
1631
1671
  self.undoIdx -= 1;
1632
1672
  self._restoreState(self.history[self.undoIdx]);
1673
+ self._notifyActivity('undone', self.history[self.undoIdx]);
1633
1674
  },
1634
1675
  redo: function redo() {
1635
1676
  if (!self.canRedo) return;
1636
1677
  self.undoIdx += 1;
1637
1678
  self._restoreState(self.history[self.undoIdx]);
1679
+ self._notifyActivity('redone', self.history[self.undoIdx]);
1638
1680
  },
1639
1681
  clear: function clear() {
1640
1682
  self.history.clear();
@@ -1832,6 +1874,746 @@ function buildFontFaceCss(customFont) {
1832
1874
  // Comprehensive list of Google Fonts matching Polotno's font library
1833
1875
  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'];
1834
1876
 
1877
+ // src/model/activity-log.js
1878
+ //
1879
+ // Turns what the user does into plain English sentences. Pure functions on
1880
+ // plain snapshot objects: no MST, no React, so it runs under plain node tests.
1881
+ // Never writes image data or URLs into a sentence.
1882
+
1883
+ var DEFAULT_OPTIONS = {
1884
+ includeTextContent: true,
1885
+ maxTextLength: 40,
1886
+ maxEntries: 300,
1887
+ maxSentenceLength: 200,
1888
+ mergeWindowMs: 1500
1889
+ };
1890
+ function clip(text, max) {
1891
+ var s = String(text == null ? '' : text);
1892
+ return s.length > max ? "".concat(s.slice(0, max), "\u2026") : s;
1893
+ }
1894
+ function imageSource(src) {
1895
+ var s = String(src || '');
1896
+ if (s.startsWith('data:') || s.startsWith('blob:')) return 'uploaded';
1897
+ if (s.toLowerCase().includes('unsplash')) return 'stock photo';
1898
+ return '';
1899
+ }
1900
+ function describeElement(el) {
1901
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
1902
+ var type = el && el.type;
1903
+ switch (type) {
1904
+ case 'text':
1905
+ {
1906
+ var text = el.text == null ? '' : String(el.text);
1907
+ if (!opts.includeTextContent || !text) return 'the text';
1908
+ return "the text \"".concat(clip(text, opts.maxTextLength), "\"");
1909
+ }
1910
+ case 'image':
1911
+ return 'the image';
1912
+ case 'figure':
1913
+ return el.subType ? "the shape (".concat(el.subType, ")") : 'the shape';
1914
+ case 'line':
1915
+ return 'the line';
1916
+ case 'group':
1917
+ return 'the group';
1918
+ case 'svg':
1919
+ return 'the graphic';
1920
+ default:
1921
+ return 'the element';
1922
+ }
1923
+ }
1924
+
1925
+ // ── Start, final and popup sentences ────────────────────────────────
1926
+
1927
+ var MAX_LISTED_TEXTS = 5;
1928
+ var HIDDEN_VALUE = '(value hidden)';
1929
+ function walk(children, fn) {
1930
+ (children || []).forEach(function (child) {
1931
+ if (!child) return;
1932
+ fn(child);
1933
+ if (child.children) walk(child.children, fn);
1934
+ });
1935
+ }
1936
+ function allElements(snapshot) {
1937
+ var out = [];
1938
+ (snapshot && snapshot.pages || []).forEach(function (page) {
1939
+ return walk(page && page.children, function (el) {
1940
+ return out.push(el);
1941
+ });
1942
+ });
1943
+ return out;
1944
+ }
1945
+ var num = function num(n) {
1946
+ return String(Number.isFinite(+n) ? +(+n).toFixed(2) : n);
1947
+ };
1948
+ function describeSize(snapshot) {
1949
+ var s = snapshot || {};
1950
+ return "".concat(num(s.width), " x ").concat(num(s.height), " ").concat(s.unit || 'px');
1951
+ }
1952
+ var plural = function plural(n, word) {
1953
+ return "".concat(n, " ").concat(word).concat(n === 1 ? '' : 's');
1954
+ };
1955
+ var COUNTED = [['text', 'text'], ['image', 'image'], ['figure', 'shape'], ['line', 'line'], ['svg', 'graphic']];
1956
+ function countParts(elements) {
1957
+ return COUNTED.map(function (_ref) {
1958
+ var _ref2 = _slicedToArray(_ref, 2),
1959
+ type = _ref2[0],
1960
+ word = _ref2[1];
1961
+ return [elements.filter(function (e) {
1962
+ return e.type === type;
1963
+ }).length, word];
1964
+ }).filter(function (_ref3) {
1965
+ var _ref4 = _slicedToArray(_ref3, 1),
1966
+ n = _ref4[0];
1967
+ return n > 0;
1968
+ }).map(function (_ref5) {
1969
+ var _ref6 = _slicedToArray(_ref5, 2),
1970
+ n = _ref6[0],
1971
+ word = _ref6[1];
1972
+ return plural(n, word);
1973
+ });
1974
+ }
1975
+ function joinWithAnd(parts) {
1976
+ if (parts.length <= 1) return parts.join('');
1977
+ return "".concat(parts.slice(0, -1).join(', '), " and ").concat(parts[parts.length - 1]);
1978
+ }
1979
+ function variableName(el) {
1980
+ var custom = el && el.custom || {};
1981
+ return custom.variableName || custom.promptText || 'the field';
1982
+ }
1983
+ function describeStart(snapshot) {
1984
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
1985
+ var elements = allElements(snapshot);
1986
+ var size = describeSize(snapshot);
1987
+ if (elements.length === 0) return ["Started from a blank label, ".concat(size, ".")];
1988
+ var parts = countParts(elements);
1989
+ var texts = elements.filter(function (e) {
1990
+ return e.type === 'text' && e.text;
1991
+ });
1992
+ if (opts.includeTextContent && texts.length && parts[0].endsWith(texts.length === 1 ? ' text' : ' texts')) {
1993
+ var listed = texts.slice(0, MAX_LISTED_TEXTS).map(function (e) {
1994
+ return "\"".concat(clip(e.text, opts.maxTextLength), "\"");
1995
+ }).join(', ');
1996
+ parts[0] = "".concat(parts[0], " (").concat(listed, ")");
1997
+ }
1998
+ var pages = (snapshot && snapshot.pages || []).length || 1;
1999
+ var sentences = ["Started from a template, ".concat(size, ", ").concat(plural(pages, 'page'), ", with ").concat(joinWithAnd(parts), ".")];
2000
+ var vars = elements.filter(function (e) {
2001
+ return e.custom && e.custom.inputField;
2002
+ });
2003
+ if (vars.length) {
2004
+ var named = vars.map(function (e) {
2005
+ return "\"".concat(variableName(e), "\" (").concat(e.custom.inputType || 'text', ")");
2006
+ }).join(', ');
2007
+ sentences.push("The template asked for ".concat(plural(vars.length, 'variable'), ": ").concat(named, "."));
2008
+ }
2009
+ return sentences;
2010
+ }
2011
+ function describeFinal(snapshot) {
2012
+ var parts = countParts(allElements(snapshot));
2013
+ return "Final label: ".concat([].concat(_toConsumableArray(parts.length ? parts : ['empty']), [describeSize(snapshot)]).join(', '), ".");
2014
+ }
2015
+ function describePopup() {
2016
+ var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2017
+ action = _ref7.action,
2018
+ field = _ref7.field,
2019
+ value = _ref7.value;
2020
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
2021
+ if (action === 'finish') return 'User finished the variable questions.';
2022
+ var custom = field && field.custom || {};
2023
+ var name = variableName(field);
2024
+ var shown = function shown(v) {
2025
+ return opts.includeTextContent ? clip(v, opts.maxTextLength) : HIDDEN_VALUE;
2026
+ };
2027
+ switch (action) {
2028
+ case 'skip':
2029
+ return custom.removeIfSkipped ? "User skipped variable \"".concat(name, "\"; the element was removed from the label.") : "User skipped variable \"".concat(name, "\".");
2030
+ case 'back':
2031
+ return "User went back to change variable \"".concat(name, "\".");
2032
+ case 'submit':
2033
+ break;
2034
+ default:
2035
+ return "User answered variable \"".concat(name, "\".");
2036
+ }
2037
+ switch (custom.inputType) {
2038
+ case 'radio':
2039
+ {
2040
+ var isOption = Array.isArray(custom.options) && custom.options.includes(value);
2041
+ return isOption ? "User chose \"".concat(shown(value), "\" for variable \"").concat(name, "\".") : "User typed their own answer \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2042
+ }
2043
+ case 'list':
2044
+ {
2045
+ var picked = String(value == null ? '' : value).split(', ').filter(Boolean).map(function (v) {
2046
+ return "\"".concat(shown(v), "\"");
2047
+ }).join(', ');
2048
+ return "User selected ".concat(picked, " for variable \"").concat(name, "\".");
2049
+ }
2050
+ case 'date':
2051
+ return "User picked the date \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2052
+ case 'integer':
2053
+ return "User entered the number ".concat(shown(value), " for variable \"").concat(name, "\".");
2054
+ case 'image':
2055
+ return "User uploaded an image for variable \"".concat(name, "\".");
2056
+ default:
2057
+ return "User entered \"".concat(shown(value), "\" for variable \"").concat(name, "\".");
2058
+ }
2059
+ }
2060
+
2061
+ // ── Diff: snapshot → sentences ──────────────────────────────────────
2062
+
2063
+ var words = function words(prop) {
2064
+ return String(prop).replace(/([A-Z])/g, ' $1').toLowerCase().trim();
2065
+ };
2066
+ var _short = function _short(v) {
2067
+ var s = String(v == null ? '' : v);
2068
+ return "".concat(s.length, ":").concat(s.slice(0, 40));
2069
+ };
2070
+ var isLocked = function isLocked(el) {
2071
+ return el.draggable === false && el.resizable === false && el.contentEditable === false && el.styleEditable === false;
2072
+ };
2073
+ var quotedText = function quotedText(el, n, opts) {
2074
+ return opts.includeTextContent && el.text ? "\"".concat(clip(el.text, opts.maxTextLength), "\"") : n;
2075
+ };
2076
+
2077
+ // One row per property group: how to read its value, and how to word the change.
2078
+ // A new property is one new row. `render(ctx)` returns (from, to) => sentence so a
2079
+ // merged entry can be re-worded with its first `from` and last `to`.
2080
+ var ROWS = [{
2081
+ key: 'text',
2082
+ props: ['text'],
2083
+ render: function render(_ref8) {
2084
+ var opts = _ref8.opts;
2085
+ return function (f, t) {
2086
+ return opts.includeTextContent ? "Changed the text \"".concat(clip(f, opts.maxTextLength), "\" to \"").concat(clip(t, opts.maxTextLength), "\".") : 'Changed the text.';
2087
+ };
2088
+ }
2089
+ }, {
2090
+ key: 'fontFamily',
2091
+ props: ['fontFamily'],
2092
+ render: function render(_ref9) {
2093
+ var n = _ref9.n;
2094
+ return function (f, t) {
2095
+ return "Changed the font of ".concat(n, " to ").concat(t, ".");
2096
+ };
2097
+ }
2098
+ }, {
2099
+ key: 'fontSize',
2100
+ props: ['fontSize'],
2101
+ render: function render(_ref0) {
2102
+ var n = _ref0.n;
2103
+ return function (f, t) {
2104
+ return "Changed the font size of ".concat(n, " from ").concat(f, " to ").concat(t, ".");
2105
+ };
2106
+ }
2107
+ }, {
2108
+ key: 'fill',
2109
+ props: ['fill'],
2110
+ render: function render(_ref1) {
2111
+ var n = _ref1.n;
2112
+ return function (f, t) {
2113
+ return "Changed the colour of ".concat(n, " to ").concat(t, ".");
2114
+ };
2115
+ }
2116
+ }, {
2117
+ key: 'position',
2118
+ props: ['x', 'y'],
2119
+ render: function render(_ref10) {
2120
+ var n = _ref10.n;
2121
+ return function () {
2122
+ return "Moved ".concat(n, ".");
2123
+ };
2124
+ }
2125
+ }, {
2126
+ key: 'size',
2127
+ props: ['width', 'height'],
2128
+ render: function render(_ref11) {
2129
+ var n = _ref11.n;
2130
+ return function () {
2131
+ return "Resized ".concat(n, ".");
2132
+ };
2133
+ }
2134
+ }, {
2135
+ key: 'rotation',
2136
+ props: ['rotation'],
2137
+ render: function render(_ref12) {
2138
+ var n = _ref12.n;
2139
+ return function (f, t) {
2140
+ return "Rotated ".concat(n, " to ").concat(t, " degrees.");
2141
+ };
2142
+ }
2143
+ }, {
2144
+ key: 'visible',
2145
+ props: ['visible'],
2146
+ render: function render(_ref13) {
2147
+ var n = _ref13.n;
2148
+ return function (f, t) {
2149
+ return t ? "Showed ".concat(n, ".") : "Hid ".concat(n, ".");
2150
+ };
2151
+ }
2152
+ }, {
2153
+ key: 'lock',
2154
+ props: ['draggable', 'resizable', 'contentEditable', 'styleEditable'],
2155
+ value: isLocked,
2156
+ render: function render(_ref14) {
2157
+ var n = _ref14.n;
2158
+ return function (f, t) {
2159
+ return t ? "Locked ".concat(n, ".") : "Unlocked ".concat(n, ".");
2160
+ };
2161
+ }
2162
+ }, {
2163
+ key: 'crop',
2164
+ props: ['cropX', 'cropY', 'cropWidth', 'cropHeight'],
2165
+ render: function render(_ref15) {
2166
+ var n = _ref15.n;
2167
+ return function () {
2168
+ return "Cropped ".concat(n, ".");
2169
+ };
2170
+ }
2171
+ }, {
2172
+ key: 'clipSrc',
2173
+ props: ['clipSrc'],
2174
+ render: function render(_ref16) {
2175
+ var n = _ref16.n;
2176
+ return function (f, t) {
2177
+ return t ? "Applied a mask to ".concat(n, ".") : "Removed the mask from ".concat(n, ".");
2178
+ };
2179
+ }
2180
+ }, {
2181
+ key: 'curveEnabled',
2182
+ props: ['curveEnabled'],
2183
+ render: function render(_ref17) {
2184
+ var n = _ref17.n,
2185
+ next = _ref17.next,
2186
+ opts = _ref17.opts;
2187
+ return function (f, t) {
2188
+ return t ? "Applied curved text to ".concat(quotedText(next, n, opts), ".") : "Removed the curve from ".concat(n, ".");
2189
+ };
2190
+ }
2191
+ }, {
2192
+ key: 'shadowEnabled',
2193
+ props: ['shadowEnabled'],
2194
+ render: function render(_ref18) {
2195
+ var n = _ref18.n;
2196
+ return function (f, t) {
2197
+ return t ? "Added a shadow to ".concat(n, ".") : "Removed the shadow from ".concat(n, ".");
2198
+ };
2199
+ }
2200
+ }, {
2201
+ key: 'grayscaleEnabled',
2202
+ props: ['grayscaleEnabled'],
2203
+ render: function render(_ref19) {
2204
+ var n = _ref19.n;
2205
+ return function (f, t) {
2206
+ return t ? "Made ".concat(n, " grayscale.") : "Removed the grayscale from ".concat(n, ".");
2207
+ };
2208
+ }
2209
+ }, {
2210
+ key: 'src',
2211
+ props: ['src'],
2212
+ value: function value(el) {
2213
+ return _short(el.src);
2214
+ },
2215
+ render: function render(_ref20) {
2216
+ var n = _ref20.n,
2217
+ next = _ref20.next;
2218
+ return function () {
2219
+ var source = imageSource(next.src);
2220
+ var note = source === 'uploaded' ? ' (uploaded by the user)' : source ? " (".concat(source, ")") : '';
2221
+ return "Replaced ".concat(n).concat(note, ".");
2222
+ };
2223
+ }
2224
+ }];
2225
+ var HANDLED = new Set(['id', 'type', 'custom', 'children'].concat(_toConsumableArray(ROWS.flatMap(function (r) {
2226
+ return r.props;
2227
+ }))));
2228
+ function rowValue(row, el) {
2229
+ if (row.value) return row.value(el);
2230
+ return row.props.length === 1 ? el[row.props[0]] : row.props.map(function (p) {
2231
+ return el[p];
2232
+ }).join(',');
2233
+ }
2234
+ function indexSnapshot(snapshot) {
2235
+ var pages = new Map();
2236
+ var elements = new Map();
2237
+ var orders = new Map();
2238
+ (snapshot && snapshot.pages || []).forEach(function (page) {
2239
+ if (!page) return;
2240
+ pages.set(page.id, page);
2241
+ var _visit = function visit(children, parentId) {
2242
+ orders.set(parentId, (children || []).filter(Boolean).map(function (c) {
2243
+ return c.id;
2244
+ }));
2245
+ (children || []).forEach(function (child) {
2246
+ if (!child) return;
2247
+ elements.set(child.id, {
2248
+ el: child,
2249
+ parentId: parentId
2250
+ });
2251
+ if (child.children) _visit(child.children, child.id);
2252
+ });
2253
+ };
2254
+ _visit(page.children, page.id);
2255
+ });
2256
+ return {
2257
+ pages: pages,
2258
+ elements: elements,
2259
+ orders: orders
2260
+ };
2261
+ }
2262
+ function indefinite(el, opts) {
2263
+ switch (el.type) {
2264
+ case 'text':
2265
+ return opts.includeTextContent && el.text ? "a text \"".concat(clip(el.text, opts.maxTextLength), "\"") : 'a text';
2266
+ case 'image':
2267
+ {
2268
+ var source = imageSource(el.src);
2269
+ var note = source === 'uploaded' ? ' (uploaded by the user)' : source ? " (".concat(source, ")") : '';
2270
+ return "an image".concat(note);
2271
+ }
2272
+ case 'figure':
2273
+ return el.subType ? "a shape (".concat(el.subType, ")") : 'a shape';
2274
+ case 'line':
2275
+ return 'a line';
2276
+ case 'group':
2277
+ return 'a group';
2278
+ case 'svg':
2279
+ return 'a graphic';
2280
+ default:
2281
+ return 'an element';
2282
+ }
2283
+ }
2284
+ var BACKGROUND_IMAGE = /^(https?:|data:|blob:|url\()/;
2285
+ function diffToEntries(prev, next) {
2286
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;
2287
+ if (!prev || !next) return [];
2288
+ var a = indexSnapshot(prev);
2289
+ var b = indexSnapshot(next);
2290
+ var out = [];
2291
+
2292
+ // Label size
2293
+ var sizeFrom = describeSize(prev);
2294
+ var sizeTo = describeSize(next);
2295
+ if (sizeFrom !== sizeTo) {
2296
+ out.push({
2297
+ key: 'label:size',
2298
+ from: sizeFrom,
2299
+ to: sizeTo,
2300
+ render: function render(f, t) {
2301
+ return "Changed the label size from ".concat(f, " to ").concat(t, ".");
2302
+ },
2303
+ sentence: "Changed the label size from ".concat(sizeFrom, " to ").concat(sizeTo, ".")
2304
+ });
2305
+ }
2306
+
2307
+ // Pages
2308
+ var addedPages = new Set(_toConsumableArray(b.pages.keys()).filter(function (id) {
2309
+ return !a.pages.has(id);
2310
+ }));
2311
+ var removedPages = new Set(_toConsumableArray(a.pages.keys()).filter(function (id) {
2312
+ return !b.pages.has(id);
2313
+ }));
2314
+ addedPages.forEach(function (id) {
2315
+ return out.push({
2316
+ key: "".concat(id, ":added"),
2317
+ sentence: 'Added a page.'
2318
+ });
2319
+ });
2320
+ removedPages.forEach(function (id) {
2321
+ return out.push({
2322
+ key: "".concat(id, ":removed"),
2323
+ sentence: 'Removed a page.'
2324
+ });
2325
+ });
2326
+
2327
+ // Added and removed elements (only the top of an added/removed subtree)
2328
+ var added = new Set(_toConsumableArray(b.elements.keys()).filter(function (id) {
2329
+ return !a.elements.has(id);
2330
+ }));
2331
+ var removed = new Set(_toConsumableArray(a.elements.keys()).filter(function (id) {
2332
+ return !b.elements.has(id);
2333
+ }));
2334
+ added.forEach(function (id) {
2335
+ var _b$elements$get = b.elements.get(id),
2336
+ el = _b$elements$get.el,
2337
+ parentId = _b$elements$get.parentId;
2338
+ if (added.has(parentId) || addedPages.has(parentId)) return;
2339
+ out.push({
2340
+ key: "".concat(id, ":added"),
2341
+ sentence: "Added ".concat(indefinite(el, opts), ".")
2342
+ });
2343
+ });
2344
+ removed.forEach(function (id) {
2345
+ var _a$elements$get = a.elements.get(id),
2346
+ el = _a$elements$get.el,
2347
+ parentId = _a$elements$get.parentId;
2348
+ if (removed.has(parentId) || removedPages.has(parentId)) return;
2349
+ out.push({
2350
+ key: "".concat(id, ":removed"),
2351
+ sentence: "Removed ".concat(describeElement(el, opts), ".")
2352
+ });
2353
+ });
2354
+
2355
+ // Changed elements
2356
+ b.elements.forEach(function (_ref21, id) {
2357
+ var nextEl = _ref21.el;
2358
+ var before = a.elements.get(id);
2359
+ if (!before) return;
2360
+ var prevEl = before.el;
2361
+ var ctx = {
2362
+ n: describeElement(nextEl, opts),
2363
+ prev: prevEl,
2364
+ next: nextEl,
2365
+ opts: opts
2366
+ };
2367
+ ROWS.forEach(function (row) {
2368
+ var from = rowValue(row, prevEl);
2369
+ var to = rowValue(row, nextEl);
2370
+ if (from === to || from === undefined && to === undefined) return;
2371
+ var render = row.render(ctx);
2372
+ out.push({
2373
+ key: "".concat(id, ":").concat(row.key),
2374
+ from: from,
2375
+ to: to,
2376
+ render: render,
2377
+ sentence: render(from, to)
2378
+ });
2379
+ });
2380
+ var props = new Set([].concat(_toConsumableArray(Object.keys(prevEl)), _toConsumableArray(Object.keys(nextEl))));
2381
+ props.forEach(function (prop) {
2382
+ if (HANDLED.has(prop)) return;
2383
+ var from = JSON.stringify(prevEl[prop]);
2384
+ var to = JSON.stringify(nextEl[prop]);
2385
+ if (from === to) return;
2386
+ out.push({
2387
+ key: "".concat(id, ":").concat(prop),
2388
+ from: from,
2389
+ to: to,
2390
+ sentence: "Changed the ".concat(words(prop), " of ").concat(ctx.n, ".")
2391
+ });
2392
+ });
2393
+ });
2394
+
2395
+ // Layer order within each parent, for elements present before and after
2396
+ b.orders.forEach(function (nextIds, parentId) {
2397
+ var prevIds = a.orders.get(parentId);
2398
+ if (!prevIds) return;
2399
+ var common = new Set(nextIds.filter(function (id) {
2400
+ return prevIds.includes(id);
2401
+ }));
2402
+ var pOrder = prevIds.filter(function (id) {
2403
+ return common.has(id);
2404
+ });
2405
+ var nOrder = nextIds.filter(function (id) {
2406
+ return common.has(id);
2407
+ });
2408
+ if (pOrder.join('|') === nOrder.join('|')) return;
2409
+ var mover = nOrder.find(function (c) {
2410
+ var p = pOrder.filter(function (id) {
2411
+ return id !== c;
2412
+ }).join('|');
2413
+ var n = nOrder.filter(function (id) {
2414
+ return id !== c;
2415
+ }).join('|');
2416
+ return p === n;
2417
+ });
2418
+ if (!mover) {
2419
+ out.push({
2420
+ key: "".concat(parentId, ":order"),
2421
+ sentence: 'Changed the layer order.'
2422
+ });
2423
+ return;
2424
+ }
2425
+ var name = describeElement(b.elements.get(mover).el, opts);
2426
+ var pos = nOrder.indexOf(mover);
2427
+ 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, ".");
2428
+ out.push({
2429
+ key: "".concat(mover, ":order"),
2430
+ sentence: sentence
2431
+ });
2432
+ });
2433
+
2434
+ // Page background
2435
+ b.pages.forEach(function (page, id) {
2436
+ var before = a.pages.get(id);
2437
+ if (!before) return;
2438
+ var from = before.background || '';
2439
+ var to = page.background || '';
2440
+ if (from === to) return;
2441
+ var sentence = !to ? 'Removed the background.' : BACKGROUND_IMAGE.test(to) ? 'Set an image as the background.' : "Changed the background colour to ".concat(to, ".");
2442
+ out.push({
2443
+ key: "".concat(id, ":background"),
2444
+ sentence: sentence
2445
+ });
2446
+ });
2447
+ return out;
2448
+ }
2449
+
2450
+ // ── Tracker: keeps the log, merges quick repeats, caps the size ─────
2451
+
2452
+ var ActivityTracker = /*#__PURE__*/function () {
2453
+ function ActivityTracker() {
2454
+ var getOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
2455
+ return DEFAULT_OPTIONS;
2456
+ };
2457
+ var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now;
2458
+ _classCallCheck(this, ActivityTracker);
2459
+ this._getOptions = getOptions;
2460
+ this._now = now;
2461
+ this.clear();
2462
+ }
2463
+ return _createClass(ActivityTracker, [{
2464
+ key: "_opts",
2465
+ get: function get() {
2466
+ return _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), this._getOptions() || {});
2467
+ }
2468
+ }, {
2469
+ key: "clear",
2470
+ value: function clear() {
2471
+ this._start = [];
2472
+ this._actions = [];
2473
+ this._dropped = false;
2474
+ this._baseline = null;
2475
+ }
2476
+ }, {
2477
+ key: "reset",
2478
+ value: function reset(snapshot) {
2479
+ var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2480
+ this.clear();
2481
+ if (!snapshot) return;
2482
+ this._baseline = snapshot;
2483
+ this._start = [].concat(_toConsumableArray(describeStart(snapshot, this._opts)), _toConsumableArray(extra));
2484
+ }
2485
+ }, {
2486
+ key: "rebaseline",
2487
+ value: function rebaseline(snapshot) {
2488
+ if (snapshot) this._baseline = snapshot;
2489
+ }
2490
+
2491
+ // The canvas sometimes rewrites an element by itself (e.g. re-measuring a text's height once a
2492
+ // font has loaded). That is not something the user did, so fold it into the baseline for just
2493
+ // that element: the next commit then won't report it, and the user's own pending changes stay.
2494
+ }, {
2495
+ key: "patchBaseline",
2496
+ value: function patchBaseline(id, attrs) {
2497
+ if (!id || !this._baseline) return;
2498
+ var _patch = function patch(children) {
2499
+ return (children || []).map(function (child) {
2500
+ if (!child) return child;
2501
+ if (child.id === id) return _objectSpread2(_objectSpread2({}, child), attrs);
2502
+ return child.children ? _objectSpread2(_objectSpread2({}, child), {}, {
2503
+ children: _patch(child.children)
2504
+ }) : child;
2505
+ });
2506
+ };
2507
+ this._baseline = _objectSpread2(_objectSpread2({}, this._baseline), {}, {
2508
+ pages: (this._baseline.pages || []).map(function (page) {
2509
+ return page ? _objectSpread2(_objectSpread2({}, page), {}, {
2510
+ children: _patch(page.children)
2511
+ }) : page;
2512
+ })
2513
+ });
2514
+ }
2515
+ }, {
2516
+ key: "onCommit",
2517
+ value: function onCommit(snapshot) {
2518
+ var _this = this;
2519
+ if (!snapshot) return;
2520
+ var previous = this._baseline;
2521
+ this._baseline = snapshot;
2522
+ if (!previous) return;
2523
+ diffToEntries(previous, snapshot, this._opts).forEach(function (entry) {
2524
+ return _this._add(entry);
2525
+ });
2526
+ }
2527
+ }, {
2528
+ key: "record",
2529
+ value: function record(sentence, key) {
2530
+ this._add({
2531
+ key: key,
2532
+ sentence: String(sentence)
2533
+ });
2534
+ }
2535
+ }, {
2536
+ key: "undone",
2537
+ value: function undone(snapshot) {
2538
+ this._add({
2539
+ sentence: 'Undid the last change.'
2540
+ });
2541
+ this.rebaseline(snapshot);
2542
+ }
2543
+ }, {
2544
+ key: "redone",
2545
+ value: function redone(snapshot) {
2546
+ this._add({
2547
+ sentence: 'Redid the last change.'
2548
+ });
2549
+ this.rebaseline(snapshot);
2550
+ }
2551
+ }, {
2552
+ key: "getLog",
2553
+ value: function getLog(finalSnapshot) {
2554
+ var maxSentenceLength = this._opts.maxSentenceLength;
2555
+ var lines = _toConsumableArray(this._start);
2556
+ if (this._dropped) lines.push('Earlier actions were left out.');
2557
+ this._actions.forEach(function (a) {
2558
+ return lines.push(a.sentence);
2559
+ });
2560
+ if (finalSnapshot) lines.push(describeFinal(finalSnapshot));
2561
+ return lines.map(function (line) {
2562
+ return clip(line, maxSentenceLength);
2563
+ });
2564
+ }
2565
+ }, {
2566
+ key: "_add",
2567
+ value: function _add(entry) {
2568
+ var at = this._now();
2569
+ var last = this._actions[this._actions.length - 1];
2570
+ var _this$_opts = this._opts,
2571
+ mergeWindowMs = _this$_opts.mergeWindowMs,
2572
+ maxEntries = _this$_opts.maxEntries;
2573
+ if (entry.key && last && last.key === entry.key && at - last.at <= mergeWindowMs) {
2574
+ if (entry.render && last.render) {
2575
+ if (last.from === entry.to) {
2576
+ this._actions.pop();
2577
+ return;
2578
+ }
2579
+ this._actions[this._actions.length - 1] = _objectSpread2(_objectSpread2({}, entry), {}, {
2580
+ from: last.from,
2581
+ at: at,
2582
+ sentence: entry.render(last.from, entry.to)
2583
+ });
2584
+ } else {
2585
+ this._actions[this._actions.length - 1] = _objectSpread2(_objectSpread2({}, entry), {}, {
2586
+ at: at
2587
+ });
2588
+ }
2589
+ return;
2590
+ }
2591
+ this._actions.push(_objectSpread2(_objectSpread2({}, entry), {}, {
2592
+ at: at
2593
+ }));
2594
+ if (this._actions.length > maxEntries) {
2595
+ this._actions.shift();
2596
+ this._dropped = true;
2597
+ }
2598
+ }
2599
+ }]);
2600
+ }();
2601
+
2602
+ // ── Options singleton ───────────────────────────────────────────────
2603
+ // Window-level, like the other config: each Rollup output bundle gets its own
2604
+ // copy of this module, so a closure variable set from one would never be seen
2605
+ // by another.
2606
+
2607
+ var OPTIONS_KEY = '__labellife_activity_log_options__';
2608
+ function setActivityLogOptions(options) {
2609
+ if (typeof window === 'undefined') return;
2610
+ window[OPTIONS_KEY] = _objectSpread2(_objectSpread2({}, window[OPTIONS_KEY] || {}), options || {});
2611
+ }
2612
+ function getActivityLogOptions() {
2613
+ var set = typeof window !== 'undefined' && window[OPTIONS_KEY] || {};
2614
+ return _objectSpread2(_objectSpread2({}, DEFAULT_OPTIONS), set);
2615
+ }
2616
+
1835
2617
  var _excluded$5 = ["mimeType", "quality", "dpi", "dpiMetadata"],
1836
2618
  _excluded2$1 = ["mimeType", "quality"],
1837
2619
  _excluded3$1 = ["fileName"],
@@ -1948,7 +2730,9 @@ var Store = mobxStateTree.types.model('Store', {
1948
2730
  // incremented after each font load to trigger canvas re-render
1949
2731
  _pendingInputFields: [],
1950
2732
  // elements awaiting user input after loadJSON
1951
- customFonts: [] // host-injected custom font catalog: [{ name, variants: [{weight,style,file}] }]
2733
+ customFonts: [],
2734
+ // host-injected custom font catalog: [{ name, variants: [{weight,style,file}] }]
2735
+ _activity: new ActivityTracker(getActivityLogOptions) // plain-English log of what the user did
1952
2736
  };
1953
2737
  }).views(function (self) {
1954
2738
  return {
@@ -2109,6 +2893,8 @@ var Store = mobxStateTree.types.model('Store', {
2109
2893
  if (self.pages.length > 0 && !self._activePageId) {
2110
2894
  self._activePageId = self.pages[0].id;
2111
2895
  }
2896
+ // A store that never loads a template still needs a baseline for the activity log.
2897
+ self._resetActivity();
2112
2898
  },
2113
2899
  set: function set(attrs) {
2114
2900
  for (var _i2 = 0, _Object$entries2 = Object.entries(attrs); _i2 < _Object$entries2.length; _i2++) {
@@ -2769,6 +3555,7 @@ var Store = mobxStateTree.types.model('Store', {
2769
3555
  self.history.clear();
2770
3556
  self.history.addUndoState();
2771
3557
  }
3558
+ self._resetActivity();
2772
3559
 
2773
3560
  // Auto-load fonts referenced in text elements
2774
3561
  self._autoLoadFonts(data);
@@ -2793,6 +3580,67 @@ var Store = mobxStateTree.types.model('Store', {
2793
3580
  self.history.clear();
2794
3581
  self.history.addUndoState();
2795
3582
  }
3583
+ self._resetActivity();
3584
+ },
3585
+ // ── Activity log: plain-English record of what the user did ─────
3586
+ _activitySnapshot: function _activitySnapshot() {
3587
+ var snapshot = _objectSpread2({}, mobxStateTree.getSnapshot(self));
3588
+ delete snapshot.history;
3589
+ return snapshot;
3590
+ },
3591
+ _resetActivity: function _resetActivity() {
3592
+ try {
3593
+ self._activity.reset(self._activitySnapshot());
3594
+ } catch (e) {
3595
+ console.warn('Activity log: failed to reset', e);
3596
+ }
3597
+ },
3598
+ getActivityLog: function getActivityLog() {
3599
+ try {
3600
+ return self._activity.getLog(self._activitySnapshot());
3601
+ } catch (e) {
3602
+ console.warn('Activity log: failed to read', e);
3603
+ return [];
3604
+ }
3605
+ },
3606
+ recordActivity: function recordActivity(sentence) {
3607
+ try {
3608
+ self._activity.record(sentence);
3609
+ } catch (e) {
3610
+ console.warn('Activity log: failed to record', e);
3611
+ }
3612
+ },
3613
+ // For changes the canvas makes by itself (not the user): keeps them out of the log.
3614
+ syncActivityBaseline: function syncActivityBaseline(id, attrs) {
3615
+ try {
3616
+ self._activity.patchBaseline(id, attrs);
3617
+ } catch (e) {
3618
+ console.warn('Activity log: failed to sync baseline', e);
3619
+ }
3620
+ },
3621
+ clearActivityLog: function clearActivityLog() {
3622
+ // Keep the baseline at the current state so the next change is still logged.
3623
+ self._activity.clear();
3624
+ self._activity.rebaseline(self._activitySnapshot());
3625
+ },
3626
+ // Called by the input-fields popup. Logs the answer, then re-baselines so the
3627
+ // change it wrote into the element is not logged a second time.
3628
+ logPopupAnswer: function logPopupAnswer() {
3629
+ var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3630
+ action = _ref11.action,
3631
+ field = _ref11.field,
3632
+ value = _ref11.value;
3633
+ try {
3634
+ // 'finish' can arrive twice (answer handler and a host dialog's onComplete): key it so it merges.
3635
+ self._activity.record(describePopup({
3636
+ action: action,
3637
+ field: field,
3638
+ value: value
3639
+ }, getActivityLogOptions()), action === 'finish' ? 'popup:finish' : undefined);
3640
+ self._activity.rebaseline(self._activitySnapshot());
3641
+ } catch (e) {
3642
+ console.warn('Activity log: failed to record popup answer', e);
3643
+ }
2796
3644
  },
2797
3645
  addFont: function addFont(font) {
2798
3646
  var existing = self.fonts.find(function (f) {
@@ -3017,11 +3865,11 @@ var Store = mobxStateTree.types.model('Store', {
3017
3865
  };
3018
3866
  });
3019
3867
  function createStore() {
3020
- var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3021
- _ref11$key = _ref11.key,
3022
- key = _ref11$key === void 0 ? '' : _ref11$key,
3023
- _ref11$showCredit = _ref11.showCredit,
3024
- showCredit = _ref11$showCredit === void 0 ? false : _ref11$showCredit;
3868
+ var _ref12 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3869
+ _ref12$key = _ref12.key,
3870
+ key = _ref12$key === void 0 ? '' : _ref12$key,
3871
+ _ref12$showCredit = _ref12.showCredit,
3872
+ showCredit = _ref12$showCredit === void 0 ? false : _ref12$showCredit;
3025
3873
  var store = Store.create({});
3026
3874
  store._initConfig(key, showCredit);
3027
3875
  return store;
@@ -11576,10 +12424,25 @@ function computeCurvedCacheBounds(element) {
11576
12424
  function syncHeightKeepingCenter(element, newHeight) {
11577
12425
  if (Math.abs(newHeight - element.height) <= 1) return;
11578
12426
  var deltaY = (newHeight - element.height) / 2;
11579
- element.set({
12427
+ var attrs = {
11580
12428
  height: newHeight,
11581
12429
  y: element.y - deltaY
11582
- });
12430
+ };
12431
+ element.set(attrs);
12432
+ // An automatic re-layout, not a user action: keep it out of the activity log.
12433
+ if (element.store && element.store.syncActivityBaseline) {
12434
+ element.store.syncActivityBaseline(element.id, attrs);
12435
+ }
12436
+ }
12437
+
12438
+ // Safari doesn't make a webfont available to canvas (not even to measureText) until some
12439
+ // canvas has actually drawn text with it, so loading alone isn't enough: draw once on a
12440
+ // hidden canvas to activate the face, then measure.
12441
+ var _scratchCtx = null;
12442
+ function primeCanvasFont(font, text) {
12443
+ if (!_scratchCtx) _scratchCtx = document.createElement('canvas').getContext('2d');
12444
+ _scratchCtx.font = font;
12445
+ _scratchCtx.fillText(text || 'Hamburgefonstiv', 0, 0);
11583
12446
  }
11584
12447
 
11585
12448
  // Safari can resolve document.fonts.load() (and fire loadingdone) before the canvas
@@ -11599,6 +12462,7 @@ function waitForCanvasFont(fontSpec, family, sample, isCancelled) {
11599
12462
  var frames = 0;
11600
12463
  var _check = function check() {
11601
12464
  if (isCancelled() || frames >= FONT_READY_MAX_FRAMES) return resolve();
12465
+ primeCanvasFont("".concat(fontSpec, " \"").concat(family, "\", serif"), text);
11602
12466
  var withFont = widthWith("".concat(fontSpec, " \"").concat(family, "\", serif"));
11603
12467
  var withFallbackSerif = widthWith("".concat(fontSpec, " serif"));
11604
12468
  var withFallbackSans = widthWith("".concat(fontSpec, " sans-serif"));
@@ -11609,6 +12473,28 @@ function waitForCanvasFont(fontSpec, family, sample, isCancelled) {
11609
12473
  _check();
11610
12474
  });
11611
12475
  }
12476
+
12477
+ // TEMPORARY font-timing diagnostics. Enable in the browser console with
12478
+ // window.__labellifeFontDebug = true
12479
+ // before loading a template, then copy the "[font-debug]" lines. Remove once Safari is sorted.
12480
+ function fontDebug(label, element, node) {
12481
+ if (typeof window === 'undefined' || !window.__labellifeFontDebug) return;
12482
+ try {
12483
+ var family = element.fontFamily;
12484
+ var faces = [];
12485
+ document.fonts.forEach(function (f) {
12486
+ if (f.family.replace(/["']/g, '') === family) faces.push("".concat(f.weight, "/").concat(f.status, "/").concat(f.unicodeRange.slice(0, 18)));
12487
+ });
12488
+ var lines = node && node.textArr ? node.textArr.map(function (l) {
12489
+ return Math.round(l.width);
12490
+ }) : null;
12491
+ // eslint-disable-next-line no-console
12492
+ 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 : '-'));
12493
+ } catch (e) {
12494
+ // eslint-disable-next-line no-console
12495
+ console.log('[font-debug] failed', e);
12496
+ }
12497
+ }
11612
12498
  var TextElementComponent = mobxReactLite.observer(function (_ref) {
11613
12499
  var _element$backgroundOp;
11614
12500
  var element = _ref.element;
@@ -11636,6 +12522,7 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11636
12522
  var _node$getLayer2;
11637
12523
  var node = textRef.current;
11638
12524
  if (!node) return;
12525
+ fontDebug('relayout:before', element, node);
11639
12526
 
11640
12527
  // CurvedText's sceneFunc re-measures glyphs via ctx.measureText on
11641
12528
  // every draw (no internal cached layout like Konva.Text has), so
@@ -11646,9 +12533,21 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11646
12533
  (_node$getLayer = node.getLayer()) === null || _node$getLayer === void 0 || _node$getLayer.batchDraw();
11647
12534
  return;
11648
12535
  }
11649
- var f = node.fontFamily();
11650
- node.fontFamily('serif');
11651
- node.fontFamily(f);
12536
+
12537
+ // Re-run Konva's own layout directly — what changing `align` does, which is the manual
12538
+ // workaround that fixes this in Safari. Toggling fontFamily is the fallback if the
12539
+ // private method is ever removed.
12540
+ if (typeof node._getContextFont === 'function') {
12541
+ primeCanvasFont(node._getContextFont(), node.text());
12542
+ }
12543
+ if (typeof node._setTextData === 'function') {
12544
+ node._setTextData();
12545
+ } else {
12546
+ var f = node.fontFamily();
12547
+ node.fontFamily('serif');
12548
+ node.fontFamily(f);
12549
+ }
12550
+ fontDebug('relayout:after', element, node);
11652
12551
  var h = node.height();
11653
12552
  if (h > 0) {
11654
12553
  setTextHeight(h);
@@ -11660,12 +12559,16 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11660
12559
  }
11661
12560
  (_node$getLayer2 = node.getLayer()) === null || _node$getLayer2 === void 0 || _node$getLayer2.batchDraw();
11662
12561
  };
12562
+ React.useEffect(function () {
12563
+ fontDebug('mount', element, textRef.current);
12564
+ }, []);
11663
12565
 
11664
12566
  // Any font finishing a load (covers fonts requested elsewhere, e.g. store.loadFont).
11665
12567
  React.useEffect(function () {
11666
12568
  // Two frames' delay: Safari's canvas can still be on the fallback at event time.
11667
12569
  var onFontLoaded = function onFontLoaded() {
11668
- return requestAnimationFrame(function () {
12570
+ fontDebug('loadingdone', element, textRef.current);
12571
+ requestAnimationFrame(function () {
11669
12572
  return requestAnimationFrame(function () {
11670
12573
  var _relayoutRef$current;
11671
12574
  return (_relayoutRef$current = relayoutRef.current) === null || _relayoutRef$current === void 0 ? void 0 : _relayoutRef$current.call(relayoutRef);
@@ -11696,8 +12599,17 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11696
12599
  var _relayoutRef$current2;
11697
12600
  if (!cancelled) (_relayoutRef$current2 = relayoutRef.current) === null || _relayoutRef$current2 === void 0 || _relayoutRef$current2.call(relayoutRef);
11698
12601
  })["catch"](function () {});
12602
+ // Safari can still be on fallback metrics after the checks above, and re-measuring is
12603
+ // idempotent, so repeat a few times while the page settles.
12604
+ var retryTimers = [300, 1000, 2500].map(function (ms) {
12605
+ return setTimeout(function () {
12606
+ var _relayoutRef$current3;
12607
+ if (!cancelled) (_relayoutRef$current3 = relayoutRef.current) === null || _relayoutRef$current3 === void 0 || _relayoutRef$current3.call(relayoutRef);
12608
+ }, ms);
12609
+ });
11699
12610
  return function () {
11700
12611
  cancelled = true;
12612
+ retryTimers.forEach(clearTimeout);
11701
12613
  };
11702
12614
  }, [element.fontFamily, element.fontWeight, element.fontStyle]);
11703
12615
 
@@ -11879,10 +12791,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
11879
12791
  var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11880
12792
  if (removed) return;
11881
12793
  removed = true;
11882
- element.set({
11883
- text: cancel ? originalText : textarea.value
12794
+ element.finishEdit({
12795
+ text: cancel ? originalText : textarea.value,
12796
+ originalText: originalText
11884
12797
  });
11885
- element.toggleEditMode(false);
11886
12798
  if (textareaRef.current === textarea) textareaRef.current = null;
11887
12799
  if (textarea.parentNode) {
11888
12800
  textarea.parentNode.removeChild(textarea);
@@ -13182,6 +14094,17 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13182
14094
  var config = getInputFieldsConfig();
13183
14095
  var pendingFields = store._pendingInputFields || [];
13184
14096
 
14097
+ // Plain-English activity log (see model/activity-log.js). Called after the
14098
+ // element has been updated so the log can re-baseline past that change.
14099
+ var logAnswer = function logAnswer(action, el, value) {
14100
+ if (typeof store.logPopupAnswer !== 'function') return;
14101
+ store.logPopupAnswer({
14102
+ action: action,
14103
+ field: el ? mobxStateTree.getSnapshot(el) : undefined,
14104
+ value: value
14105
+ });
14106
+ };
14107
+
13185
14108
  // When disabled, clear any pending fields so they are treated as skipped
13186
14109
  React.useEffect(function () {
13187
14110
  if (!enabled && pendingFields.length > 0) {
@@ -13237,6 +14160,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13237
14160
  text: previousValue || ''
13238
14161
  });
13239
14162
  }
14163
+ logAnswer('back', el);
13240
14164
  isGoingBackRef.current = true;
13241
14165
  store._unresolveInputField(el);
13242
14166
  }
@@ -13284,9 +14208,11 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13284
14208
  });
13285
14209
  }
13286
14210
  }
14211
+ logAnswer('submit', el, value);
13287
14212
  store._resolveInputField(elementId);
13288
14213
  if (fields.length <= 1) {
13289
14214
  _flushRemovedElements();
14215
+ logAnswer('finish');
13290
14216
  store.history.addUndoState();
13291
14217
  if (_onComplete) _onComplete();
13292
14218
  } else {
@@ -13312,10 +14238,12 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13312
14238
  skipped: true,
13313
14239
  removed: shouldRemove
13314
14240
  });
14241
+ logAnswer('skip', el);
13315
14242
  store._resolveInputField(elementId);
13316
14243
  if (fields.length <= 1) {
13317
14244
  var hadRemovals = removedDueToSkipRef.current.length > 0;
13318
14245
  _flushRemovedElements();
14246
+ logAnswer('finish');
13319
14247
  if (hadRemovals) store.history.addUndoState();
13320
14248
  if (_onComplete) _onComplete();
13321
14249
  } else {
@@ -13346,6 +14274,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13346
14274
  text: previousValue || ''
13347
14275
  });
13348
14276
  }
14277
+ logAnswer('back', el);
13349
14278
  store._unresolveInputField(el);
13350
14279
  }
13351
14280
  setDisplayIndex(function (prev) {
@@ -13380,6 +14309,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
13380
14309
  canGoBack: canGoBack,
13381
14310
  onComplete: function onComplete() {
13382
14311
  _flushRemovedElements();
14312
+ logAnswer('finish');
13383
14313
  store.history.addUndoState();
13384
14314
  if (_onComplete) _onComplete();
13385
14315
  }
@@ -14158,6 +15088,7 @@ exports.ZoomButtons = ZoomButtons;
14158
15088
  exports.createStore = createStore;
14159
15089
  exports.cropImage = cropImage;
14160
15090
  exports.fetchGoogleFonts = fetchGoogleFonts;
15091
+ exports.getActivityLogOptions = getActivityLogOptions;
14161
15092
  exports.getImageSize = getImageSize;
14162
15093
  exports.getInputFieldsConfig = getInputFieldsConfig;
14163
15094
  exports.getTheme = getTheme;
@@ -14168,6 +15099,7 @@ exports.loadGoogleFont = loadGoogleFont;
14168
15099
  exports.loadImage = loadImage;
14169
15100
  exports.popupActionButtonSx = popupActionButtonSx;
14170
15101
  exports.pxToUnit = pxToUnit;
15102
+ exports.setActivityLogOptions = setActivityLogOptions;
14171
15103
  exports.setInputFieldsConfig = setInputFieldsConfig;
14172
15104
  exports.setTheme = setTheme;
14173
15105
  exports.setTranslations = setTranslations;