-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to mobiledoc-kit 0.12.4 Adds mobiledoc-section-attribute-button for building toolbars. Adds text-alignment buttons to mobiledoc-toolbar Updates README accordingly
- Loading branch information
Showing
15 changed files
with
370 additions
and
17 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
36 changes: 36 additions & 0 deletions
36
addon/components/mobiledoc-section-attribute-button/component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { defineProperty, observer, computed } from '@ember/object'; | ||
import Component from '@ember/component'; | ||
import layout from './template'; | ||
import { camelize } from '@ember/string'; | ||
import { isEmpty } from '@ember/utils'; | ||
|
||
export default Component.extend({ | ||
tagName: 'button', | ||
layout, | ||
attributeBindings: ['type', 'title'], | ||
classNameBindings: ['isActive:active'], | ||
type: 'button', | ||
init() { | ||
this._super(...arguments); | ||
this._updateIsActiveCP(); | ||
}, | ||
onNameOrValueDidChange: observer('attributeName', 'attributeValue', function() { | ||
this._updateIsActiveCP(); | ||
}), | ||
_updateIsActiveCP() { | ||
let attributeName = this.get('attributeName'); | ||
let fullPath = `editor.activeSectionAttributes.${camelize(attributeName)}`; | ||
let cp = computed(fullPath, 'attributeValue', function(){ | ||
let activeValues = this.get(fullPath) || []; | ||
let attributeValue = this.get('attributeValue'); | ||
return activeValues.includes(attributeValue) || (isEmpty(activeValues) && this.editor.isDefaultAttributeValue(attributeName, attributeValue)); | ||
}); | ||
defineProperty(this, 'isActive', cp); | ||
}, | ||
click() { | ||
let editor = this.get('editor'); | ||
let attributeName = this.get('attributeName'); | ||
let attributeValue = this.get('attributeValue'); | ||
editor.setAttribute(attributeName, attributeValue); | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
addon/components/mobiledoc-section-attribute-button/template.hbs
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{{#if hasBlock}}{{yield}}{{else}}{{mobiledoc-titleize attributeValue}}{{/if~}} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
export function includes([array, item] /* , attributeHash */) { | ||
if (!array || !array.includes) { | ||
return false; | ||
} | ||
return array.includes(item); | ||
} | ||
|
||
export default helper(includes); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-mobiledoc-editor/components/mobiledoc-section-attribute-button/component'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, includes } from 'ember-mobiledoc-editor/helpers/includes'; |
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
Oops, something went wrong.