markupeditor 0.9.11 → 0.9.13

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.
@@ -48,6 +48,29 @@
48
48
  "header": true,
49
49
  "border": true
50
50
  },
51
+ "help": {
52
+ "style": "Set paragraph style",
53
+ "bold": "Toggle bold",
54
+ "italic": "Toggle italic",
55
+ "underline": "Toggle underline",
56
+ "code": "Toggle code",
57
+ "strikethrough": "Toggle strikethrough",
58
+ "subscript": "Toggle subscript",
59
+ "superscript": "Toggle superscript",
60
+ "bullet": "Toggle bulleted list",
61
+ "number": "Toggle numbered list",
62
+ "indent": "Increase indent",
63
+ "outdent": "Decrease indent",
64
+ "link": "Insert/edit link",
65
+ "image": "Insert/edit image",
66
+ "table": "Insert/edit table",
67
+ "search": "Toggle search",
68
+ "searchForward": "Search forward",
69
+ "searchBackward": "Search backward",
70
+ "matchCase": "Match case",
71
+ "undo": "Undo",
72
+ "redo": "Redo"
73
+ },
51
74
  "augmentation": {
52
75
  "prepend": null,
53
76
  "append": null
@@ -16725,6 +16725,20 @@ function getDataImages() {
16725
16725
  return dataImages
16726
16726
  }
16727
16727
 
16728
+ /**
16729
+ * Return an array of `src` attributes for images that contain relative references, empty if there are none.
16730
+ *
16731
+ * @returns {Array<string>}
16732
+ */
16733
+ function getLocalImages() {
16734
+ const isAbsoluteURL = src => { try { return !!new URL(src) } catch { return false } };
16735
+ const isRelative = src =>
16736
+ !!src && !isAbsoluteURL(src) && !src.startsWith('data:') && !src.startsWith('/');
16737
+ return Array.from(activeEditorElement().getElementsByTagName('img'))
16738
+ .map(img => img.getAttribute('src'))
16739
+ .filter(isRelative)
16740
+ }
16741
+
16728
16742
  /**
16729
16743
  * We saved an image at a new location or translated it from data to a file reference,
16730
16744
  * so we need to update the document to reflect it.
@@ -17176,7 +17190,7 @@ function focusOn(id) {
17176
17190
  const view = activeView();
17177
17191
  const {node, pos} = _getNode(id);
17178
17192
  if (node && (node.attrs.id !== selectedID())) {
17179
- const selection = new TextSelection(view.state.doc.resolve(pos));
17193
+ const selection = TextSelection.near(view.state.tr.doc.resolve(pos));
17180
17194
  const transaction = view.state.tr.setSelection(selection).scrollIntoView();
17181
17195
  view.dispatch(transaction);
17182
17196
  }}
@@ -17451,7 +17465,7 @@ function toggleListItem$1(listType) {
17451
17465
  command(view.state, (transaction) => {
17452
17466
  const newState = view.state.apply(transaction);
17453
17467
  view.updateState(newState);
17454
- });
17468
+ }, view);
17455
17469
  }}
17456
17470
  /**
17457
17471
  * Return the type of list the selection is in, else null.
@@ -19592,6 +19606,29 @@ var tableMenu = {
19592
19606
  header: true,
19593
19607
  border: true
19594
19608
  };
19609
+ var help = {
19610
+ style: "Set paragraph style",
19611
+ bold: "Toggle bold",
19612
+ italic: "Toggle italic",
19613
+ underline: "Toggle underline",
19614
+ code: "Toggle code",
19615
+ strikethrough: "Toggle strikethrough",
19616
+ subscript: "Toggle subscript",
19617
+ superscript: "Toggle superscript",
19618
+ bullet: "Toggle bulleted list",
19619
+ number: "Toggle numbered list",
19620
+ indent: "Increase indent",
19621
+ outdent: "Decrease indent",
19622
+ link: "Insert/edit link",
19623
+ image: "Insert/edit image",
19624
+ table: "Insert/edit table",
19625
+ search: "Toggle search",
19626
+ searchForward: "Search forward",
19627
+ searchBackward: "Search backward",
19628
+ matchCase: "Match case",
19629
+ undo: "Undo",
19630
+ redo: "Redo"
19631
+ };
19595
19632
  var augmentation = {
19596
19633
  prepend: null,
19597
19634
  append: null
@@ -19628,6 +19665,7 @@ var toolbarConfig = {
19628
19665
  styleMenu: styleMenu,
19629
19666
  styleBar: styleBar,
19630
19667
  tableMenu: tableMenu,
19668
+ help: help,
19631
19669
  augmentation: augmentation,
19632
19670
  icons: icons
19633
19671
  };
@@ -21440,10 +21478,11 @@ class LinkItem extends DialogItem {
21440
21478
  super(config);
21441
21479
  let keymap = this.config.keymap;
21442
21480
  let icons = config.toolbar.icons;
21481
+ let help = config.toolbar.help;
21443
21482
  let options = {
21444
21483
  enable: () => { return true }, // Always enabled because it is presented modally
21445
21484
  active: (state) => { return markActive(state, state.schema.marks.link) },
21446
- title: 'Insert/edit link' + keyString('link', keymap),
21485
+ title: help.link + keyString('link', keymap),
21447
21486
  icon: icons.link
21448
21487
  };
21449
21488
 
@@ -21755,10 +21794,11 @@ class ImageItem extends DialogItem {
21755
21794
  constructor(config) {
21756
21795
  super(config);
21757
21796
  let icons = config.toolbar.icons;
21797
+ let help = config.toolbar.help;
21758
21798
  let options = {
21759
21799
  enable: () => { return true }, // Always enabled because it is presented modally
21760
21800
  active: (state) => { return getImageAttributes(state).src },
21761
- title: 'Insert/edit image' + keyString('image', config.keymap),
21801
+ title: help.image + keyString('image', config.keymap),
21762
21802
  icon: icons.image
21763
21803
  };
21764
21804
 
@@ -22172,10 +22212,11 @@ class SearchItem {
22172
22212
  constructor(config) {
22173
22213
  let keymap = config.keymap;
22174
22214
  this.icons = config.toolbar.icons;
22215
+ this.help = config.toolbar.help;
22175
22216
  let options = {
22176
22217
  enable: () => { return true },
22177
22218
  active: () => { return this.showing() },
22178
- title: 'Toggle search' + keyString('search', keymap),
22219
+ title: this.help.search + keyString('search', keymap),
22179
22220
  icon: this.icons.search,
22180
22221
  id: prefix + '-searchitem'
22181
22222
  };
@@ -22299,11 +22340,11 @@ class SearchItem {
22299
22340
 
22300
22341
  // The searchBackward and searchForward buttons don't need updating
22301
22342
  let searchBackward = this.searchBackwardCommand.bind(this);
22302
- let searchBackwardItem = cmdItem(searchBackward, {title: "Search backward", icon: this.icons.searchBackward});
22343
+ let searchBackwardItem = cmdItem(searchBackward, {title: this.help.searchBackward, icon: this.icons.searchBackward});
22303
22344
  let searchBackwardDom = searchBackwardItem.render(view).dom;
22304
22345
  let searchBackwardSpan = crelt("span", {class: prefix + "-menuitem"}, searchBackwardDom);
22305
22346
  let searchForward = this.searchForwardCommand.bind(this);
22306
- let searchForwardItem = cmdItem(searchForward, {title: "Search forward", icon: this.icons.searchForward});
22347
+ let searchForwardItem = cmdItem(searchForward, {title: this.help.searchForward, icon: this.icons.searchForward});
22307
22348
  let searchForwardDom = searchForwardItem.render(view).dom;
22308
22349
  let searchForwardSpan = crelt("span", {class: prefix + "-menuitem"}, searchForwardDom);
22309
22350
  let separator = crelt("span", {class: prefix + "-menuseparator"});
@@ -22315,7 +22356,7 @@ class SearchItem {
22315
22356
  let toggleMatchCase = this.toggleMatchCaseCommand.bind(this);
22316
22357
  this.matchCaseItem = cmdItem(
22317
22358
  toggleMatchCase, {
22318
- title: "Match case",
22359
+ title: this.help.matchCase,
22319
22360
  icon: this.icons.matchCase,
22320
22361
  enable: () => {return true},
22321
22362
  active: () => {return this.caseSensitive}
@@ -22499,7 +22540,8 @@ function markActive(state, type) {
22499
22540
  * @returns string
22500
22541
  */
22501
22542
  function keyString(itemName, keymap) {
22502
- return ' (' + baseKeyString(itemName, keymap) + ')'
22543
+ let base = baseKeyString(itemName, keymap);
22544
+ return (base.length > 0) ? ' (' + base + ')' : ''
22503
22545
  }
22504
22546
 
22505
22547
  function baseKeyString(itemName, keymap) {
@@ -22775,6 +22817,7 @@ function insertBarItems(config) {
22775
22817
 
22776
22818
  function tableMenuItems(config) {
22777
22819
  let icons = config.toolbar.icons;
22820
+ let help = config.toolbar.help;
22778
22821
  let items = [];
22779
22822
  let { header, border } = config.toolbar.tableMenu;
22780
22823
  items.push(new TableCreateSubmenu({title: 'Insert table', label: 'Insert'}));
@@ -22818,7 +22861,7 @@ function tableMenuItems(config) {
22818
22861
  enable: (state) => { return isTableSelected(state) }
22819
22862
  }));
22820
22863
  }
22821
- return new Dropdown(items, { title: 'Insert/edit table', icon: icons.table })
22864
+ return new Dropdown(items, { title: help.table, icon: icons.table })
22822
22865
  }
22823
22866
 
22824
22867
  function tableEditItem(command, options) {
@@ -22854,25 +22897,26 @@ function tableBorderItem(command, options) {
22854
22897
  function styleBarItems(config, schema) {
22855
22898
  let keymap = config.keymap;
22856
22899
  let icons = config.toolbar.icons;
22900
+ let help = config.toolbar.help;
22857
22901
  let items = [];
22858
22902
  let { list, dent } = config.toolbar.styleBar;
22859
22903
  if (list) {
22860
22904
  let bullet = toggleListItem(
22861
22905
  schema,
22862
22906
  schema.nodes.bullet_list,
22863
- { title: 'Toggle bulleted list' + keyString('bullet', keymap), icon: icons.bulletList }
22907
+ { title: help.bullet + keyString('bullet', keymap), icon: icons.bulletList }
22864
22908
  );
22865
22909
  let number = toggleListItem(
22866
22910
  schema,
22867
22911
  schema.nodes.ordered_list,
22868
- { title: 'Toggle numbered list' + keyString('number', keymap), icon: icons.orderedList }
22912
+ { title: help.number + keyString('number', keymap), icon: icons.orderedList }
22869
22913
  );
22870
22914
  items.push(bullet);
22871
22915
  items.push(number);
22872
22916
  }
22873
22917
  if (dent) {
22874
- let indent = indentItem({ title: 'Increase indent' + keyString('indent', keymap), icon: icons.blockquote });
22875
- let outdent = outdentItem({ title: 'Decrease indent' + keyString('outdent', keymap), icon: icons.lift });
22918
+ let indent = indentItem({ title: help.indent + keyString('indent', keymap), icon: icons.blockquote });
22919
+ let outdent = outdentItem({ title: help.outdent + keyString('outdent', keymap), icon: icons.lift });
22876
22920
  items.push(indent);
22877
22921
  items.push(outdent);
22878
22922
  }
@@ -22922,15 +22966,16 @@ function outdentItem(options) {
22922
22966
  function formatItems(config, schema) {
22923
22967
  let keymap = config.keymap;
22924
22968
  let icons = config.toolbar.icons;
22969
+ let help = config.toolbar.help;
22925
22970
  let items = [];
22926
22971
  let { bold, italic, underline, code, strikethrough, subscript, superscript } = config.toolbar.formatBar;
22927
- if (bold) items.push(formatItem(schema.marks.strong, 'B', { title: 'Toggle bold' + keyString('bold', keymap), icon: icons.strong }));
22928
- if (italic) items.push(formatItem(schema.marks.em, 'I', { title: 'Toggle italic' + keyString('italic', keymap), icon: icons.em }));
22929
- if (underline) items.push(formatItem(schema.marks.u, 'U', { title: 'Toggle underline' + keyString('underline', keymap), icon: icons.u }));
22930
- if (code) items.push(formatItem(schema.marks.code, 'CODE', { title: 'Toggle code' + keyString('code', keymap), icon: icons.code }));
22931
- if (strikethrough) items.push(formatItem(schema.marks.s, 'DEL', { title: 'Toggle strikethrough' + keyString('strikethrough', keymap), icon: icons.s }));
22932
- if (subscript) items.push(formatItem(schema.marks.sub, 'SUB', { title: 'Toggle subscript' + keyString('subscript', keymap), icon: icons.sub }));
22933
- if (superscript) items.push(formatItem(schema.marks.sup, 'SUP', { title: 'Toggle superscript' + keyString('superscript', keymap), icon: icons.sup }));
22972
+ if (bold) items.push(formatItem(schema.marks.strong, 'B', { title: help.bold + keyString('bold', keymap), icon: icons.strong }));
22973
+ if (italic) items.push(formatItem(schema.marks.em, 'I', { title: help.italic + keyString('italic', keymap), icon: icons.em }));
22974
+ if (underline) items.push(formatItem(schema.marks.u, 'U', { title: help.underline + keyString('underline', keymap), icon: icons.u }));
22975
+ if (code) items.push(formatItem(schema.marks.code, 'CODE', { title: help.code + keyString('code', keymap), icon: icons.code }));
22976
+ if (strikethrough) items.push(formatItem(schema.marks.s, 'DEL', { title: help.strikethrough + keyString('strikethrough', keymap), icon: icons.s }));
22977
+ if (subscript) items.push(formatItem(schema.marks.sub, 'SUB', { title: help.subscript + keyString('subscript', keymap), icon: icons.sub }));
22978
+ if (superscript) items.push(formatItem(schema.marks.sup, 'SUP', { title: help.superscript + keyString('superscript', keymap), icon: icons.sup }));
22934
22979
  return items;
22935
22980
  }
22936
22981
 
@@ -22954,6 +22999,7 @@ function formatItem(markType, markName, options) {
22954
22999
  */
22955
23000
  function styleMenuItems(config, schema) {
22956
23001
  let keymap = config.keymap;
23002
+ let help = config.toolbar.help;
22957
23003
  let items = [];
22958
23004
  let { p, h1, h2, h3, h4, h5, h6, pre } = config.toolbar.styleMenu;
22959
23005
  if (p) items.push(new ParagraphStyleItem(schema.nodes.paragraph, 'P', { label: p, keymap: baseKeyString('p', keymap) }));
@@ -22974,10 +23020,10 @@ function styleMenuItems(config, schema) {
22974
23020
  return label ? (multiple ? label + '+' : label) : styleElement
22975
23021
  };
22976
23022
  let allLabels = [p, h1, h2, h3, h4, h5, h6, pre].filter(Boolean).flatMap(l => [l, l + '+']);
22977
- return [new Dropdown(items, { title: 'Set paragraph style', label: 'Style', titleUpdate: titleUpdate, labels: allLabels})]
23023
+ return [new Dropdown(items, { title: help.style, label: 'Style', titleUpdate: titleUpdate, labels: allLabels})]
22978
23024
  } else {
22979
23025
  let icons = config.toolbar.icons;
22980
- return [new Dropdown(items, { title: 'Set paragraph style', icon: icons.paragraphStyle })]
23026
+ return [new Dropdown(items, { title: help.style, icon: icons.paragraphStyle })]
22981
23027
  }
22982
23028
  }
22983
23029
 
@@ -24859,6 +24905,7 @@ const MU = {
24859
24905
  focusOn,
24860
24906
  focused,
24861
24907
  getDataImages,
24908
+ getLocalImages,
24862
24909
  getHTML,
24863
24910
  getHeight,
24864
24911
  getImageAttributes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",