-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1225 from substance/footnote-fixes
Numerous bug fixes.
- Loading branch information
Showing
12 changed files
with
134 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { Command, isNil } from 'substance' | ||
|
||
export default class RemoveReferenceCommand extends Command { | ||
getCommandState (params, context) { | ||
return { disabled: this.isDisabled(params, context) } | ||
} | ||
import RemoveItemCommand from '../shared/RemoveItemCommand' | ||
|
||
export default class RemoveReferenceCommand extends RemoveItemCommand { | ||
isDisabled (params, context) { | ||
const xpath = params.selectionState.xpath | ||
const node = this._getNode(params) | ||
const isCustomSelection = params.selection.isCustomSelection() | ||
if (!isCustomSelection || isNil(xpath) || xpath.length === 0) return true | ||
if (!isCustomSelection || !node) return true | ||
// Every reference should be inside article references property | ||
return xpath[xpath.length - 1].property !== 'references' | ||
return node.getXpath().property !== 'references' | ||
} | ||
|
||
execute (params, context) { | ||
const api = context.api | ||
const reference = params.selectionState.node | ||
api._removeReference(reference) | ||
_getNode (params) { | ||
return params.selectionState.node | ||
} | ||
} |
25 changes: 13 additions & 12 deletions
25
src/article/editor/RemoveItemCommand.js → src/article/shared/RemoveItemCommand.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters