markupeditor 0.9.43 → 0.9.46

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.
@@ -34516,6 +34516,8 @@ function setStyle(style) {
34516
34516
  function setStyleCommand(style) {
34517
34517
  let commandAdapter = (viewState, dispatch, view) => {
34518
34518
  let state = view?.state ?? viewState;
34519
+ const delegate = activeConfig()?.delegate;
34520
+ if (delegate?.canStyle && !delegate.canStyle(isTableSelected(state))) return false;
34519
34521
  const protonode = _nodeFor(style, state.schema);
34520
34522
  const doc = state.doc;
34521
34523
  const selection = state.selection;
@@ -34620,6 +34622,8 @@ function setCodeLanguageCommand(language) {
34620
34622
  }
34621
34623
  return true
34622
34624
  }
34625
+ const delegate = activeConfig()?.delegate;
34626
+ if (delegate?.canStyle && !delegate.canStyle(isTableSelected(state))) return false;
34623
34627
  const codeBlockType = state.schema.nodes.code_block;
34624
34628
  const doc = state.doc;
34625
34629
  const selection = state.selection;
@@ -34812,6 +34816,8 @@ function wrapInListCommand(schema, targetNodeType, attrs) {
34812
34816
  const listItemTypes = [targetListItemType];
34813
34817
 
34814
34818
  const commandAdapter = (state, dispatch, view) => {
34819
+ const delegate = activeConfig()?.delegate;
34820
+ if (delegate?.canList && !delegate.canList(isTableSelected(state))) return false;
34815
34821
  const inTargetNodeType = getListType(state) === listTypeFor(targetNodeType, state.schema);
34816
34822
  const command = inTargetNodeType ? liftListItem(state.schema.nodes.list_item) : wrapInList(targetNodeType, attrs);
34817
34823
  if (command(state)) {
@@ -34965,6 +34971,7 @@ function indent$1() {
34965
34971
  function indentCommand() {
34966
34972
  let commandAdapter = (viewState, dispatch, view) => {
34967
34973
  let state = view?.state ?? viewState;
34974
+ if (isTableSelected(state)) return false; // Indenting wraps/re-nests blocks, which corrupts a table's structure
34968
34975
  let blockquote = state.schema.nodes.blockquote;
34969
34976
  let li = state.schema.nodes.list_item;
34970
34977
  let ul = state.schema.nodes.bullet_list;
@@ -35080,6 +35087,7 @@ function outdent$1() {
35080
35087
  function outdentCommand() {
35081
35088
  let commandAdapter = (viewState, dispatch, view) => {
35082
35089
  let state = view?.state ?? viewState;
35090
+ if (isTableSelected(state)) return false; // Outdenting lifts/re-nests blocks, which corrupts a table's structure
35083
35091
  const { $from, $to } = state.selection;
35084
35092
  let tr = state.tr;
35085
35093
  let willLift = false;
@@ -35401,7 +35409,7 @@ function _getMarkTypes() {
35401
35409
  }
35402
35410
  /**
35403
35411
  * Return the link attributes at the selection.
35404
- *
35412
+ *
35405
35413
  * @returns {object} An Object whose properties are the link attributes (like href, link) at the selection.
35406
35414
  */
35407
35415
  function getLinkAttributes() {
@@ -36350,10 +36358,14 @@ function insertHRule() {
36350
36358
  }
36351
36359
  function insertHRuleCommand() {
36352
36360
  const commandAdapter = (state, dispatch, view) => {
36353
- const hRuleNode = view.state.schema.nodes.horizontal_rule.create();
36354
- const transaction = view.state.tr.replaceSelectionWith(hRuleNode, true);
36355
- view.dispatch(transaction);
36356
- stateChanged(view);
36361
+ const delegate = activeConfig()?.delegate;
36362
+ if (delegate?.canInsertHRule && !delegate.canInsertHRule(isTableSelected(state))) return false;
36363
+ if (dispatch) {
36364
+ const hRuleNode = state.schema.nodes.horizontal_rule.create();
36365
+ const transaction = state.tr.replaceSelectionWith(hRuleNode, true);
36366
+ dispatch(transaction);
36367
+ stateChanged(view);
36368
+ }
36357
36369
  return true;
36358
36370
  };
36359
36371
 
@@ -40971,7 +40983,7 @@ function hRuleItem(config) {
40971
40983
  icon: icon,
40972
40984
  title: title,
40973
40985
  active: (state) => { return isHRuleSelected(state) },
40974
- enable: () => { return true } // TODO: should be conditional?
40986
+ enable: true
40975
40987
  };
40976
40988
  return cmdItem(insertHRuleCommand(), options)
40977
40989
  }
@@ -42142,6 +42154,7 @@ class LinkView {
42142
42154
  link.setAttribute('href', href);
42143
42155
  link.setAttribute('title', title);
42144
42156
  link.addEventListener('click', (ev)=> {
42157
+ ev.preventDefault();
42145
42158
  if (ev.altKey) {
42146
42159
  if (href.startsWith('#')) {
42147
42160
  let id = href.substring(1);
@@ -43307,7 +43320,13 @@ class MarkupEditor {
43307
43320
  'focus': () => { setTimeout(() => focused(target)); },
43308
43321
  'blur': () => { setTimeout(() => blurred(target)); },
43309
43322
  'cut': () => { setTimeout(() => { callbackInput(target); }, 0); },
43310
- 'click': (view) => { setTimeout(() => { clicked(view, target); }, 0); },
43323
+ 'click': (view, event) => {
43324
+ const altKey = event.altKey;
43325
+ // Plain click on a link: LinkView's own listener already decided what
43326
+ // to do (open on Alt+Click, nothing otherwise); don't also report it,
43327
+ // or markupClicked's default behavior would follow the link regardless.
43328
+ setTimeout(() => { if (altKey || !getLinkAttributes().href) clicked(view, target); }, 0);
43329
+ },
43311
43330
  'delete': () => { setTimeout(() => { callbackInput(target); }, 0); },
43312
43331
  },
43313
43332
  handlePaste(view, event) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.43",
3
+ "version": "0.9.46",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",