-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed ghost editor dependency #8137
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var softReturn = require('./soft-return'); | ||
|
||
module.exports = [softReturn]; |
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,7 @@ | ||
module.exports = { | ||
name: 'soft-return', | ||
type: 'dom', | ||
render(opts) { | ||
return opts.env.dom.createElement('br'); | ||
} | ||
}; |
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,7 @@ | ||
module.exports = { | ||
name: 'hr-card', | ||
type: 'dom', | ||
render(opts) { | ||
return opts.env.dom.createElement('hr'); | ||
} | ||
}; |
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,12 @@ | ||
var SimpleDom = require('simple-dom'), | ||
tokenizer = require('simple-html-tokenizer').tokenize, | ||
parser; | ||
|
||
module.exports = { | ||
name: 'html-card', | ||
type: 'dom', | ||
render(opts) { | ||
parser = new SimpleDom.HTMLParser(tokenizer, opts.env.dom, SimpleDom.voidMap); | ||
return parser.parse('<div>' + opts.payload.html + '</div>'); | ||
} | ||
}; |
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,9 @@ | ||
module.exports = { | ||
name: 'image-card', | ||
type: 'dom', | ||
render(opts) { | ||
var img = opts.env.dom.createElement('img'); | ||
img.setAttribute('src', opts.payload.img); | ||
return img; | ||
} | ||
}; |
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,6 @@ | ||
var hr = require('./hr'), | ||
html = require('./html'), | ||
image = require('./image'), | ||
markdown = require('./markdown'); | ||
|
||
module.exports = [hr, html, image, markdown]; |
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,14 @@ | ||
var SimpleDom = require('simple-dom'), | ||
tokenizer = require('simple-html-tokenizer').tokenize, | ||
Showdown = require('showdown-ghost'), | ||
converter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}), | ||
parser; | ||
|
||
module.exports = { | ||
name: 'markdown-card', | ||
type: 'dom', | ||
render(opts) { | ||
parser = new SimpleDom.HTMLParser(tokenizer, opts.env.dom, SimpleDom.voidMap); | ||
return parser.parse('<div>' + converter.makeHtml(opts.payload.markdown || '') + '</div>'); | ||
} | ||
}; |
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,9 @@ | ||
var cards = require('./cards'), | ||
atoms = require('./atoms'); | ||
module.exports = { | ||
cards: cards, | ||
atoms: atoms, | ||
activate: function () { | ||
// needed by ghost | ||
} | ||
}; |
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,18 @@ | ||
var should = require('should'), | ||
card = require('../cards/hr'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
|
||
should = should; | ||
describe('HR card', function () { | ||
it('generates a horizontal rule', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<hr></hr>'); | ||
}); | ||
}); |
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,47 @@ | ||
var should = require('should'), | ||
card = require('../cards/html'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
|
||
should = should; | ||
describe('HTML card', function () { | ||
it('HTML Card renders', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
}, | ||
payload: { | ||
html: '<h1>HEADING</h1><p>PARAGRAPH</p>' | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<div><h1>HEADING</h1><p>PARAGRAPH</p></div>'); | ||
}); | ||
it('Plain content renders', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
}, | ||
payload: { | ||
html: 'CONTENT' | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<div>CONTENT</div>'); | ||
}); | ||
it.skip('Invalid HTML returns', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
}, | ||
payload: { | ||
html: '<h1>HEADING<' | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<div><h1>HEADING<</div>'); | ||
}); | ||
}); |
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,21 @@ | ||
var should = require('should'), | ||
card = require('../cards/image'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
|
||
should = should; | ||
describe('Image card', function () { | ||
it('generates an image', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
}, | ||
payload: { | ||
img: 'https://www.ghost.org/image.png' | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<img src="https://www.ghost.org/image.png"></img>'); | ||
}); | ||
}); |
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,21 @@ | ||
var should = require('should'), | ||
card = require('../cards/markdown'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
|
||
should = should; | ||
describe('Markdown card', function () { | ||
it('Markdown Card renders', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
}, | ||
payload: { | ||
markdown: '#HEADING\r\n- list\r\n- items' | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<div><h1 id="heading">HEADING</h1>\n\n<ul>\n<li>list</li>\n<li>items</li>\n</ul></div>'); | ||
}); | ||
}); |
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,18 @@ | ||
var should = require('should'), | ||
card = require('../atoms/soft-return'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
|
||
should = should; | ||
describe('Soft return card', function () { | ||
it('generates a `br` tag', function () { | ||
opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<br></br>'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var SimpleDom = require('simple-dom'), | ||
Renderer = require('mobiledoc-dom-renderer').default, | ||
config = require('../config'), | ||
defaults = require(config.get('paths').internalAppPath + 'default-cards'), | ||
options = { | ||
dom: new SimpleDom.Document(), | ||
cards: defaults.cards, | ||
atoms: defaults.atoms | ||
}; | ||
|
||
// function getCards() { | ||
// return config.get('internalApps').reduce( | ||
// function (cards, appName) { | ||
// var app = require(path.join(config.get('paths').internalAppPath, appName)); | ||
// if (app.hasOwnProperty('cards')) { | ||
// cards = cards.concat(app.cards); | ||
// } | ||
// return cards; | ||
// }, [ ]); | ||
// } | ||
// function getAtoms() { | ||
// return config.get('internalApps').reduce( | ||
// function (atoms, appName) { | ||
// var app = require(path.join(config.get('paths').internalAppPath, appName)); | ||
// if (app.hasOwnProperty('atoms')) { | ||
// atoms = atoms.concat(app.atoms); | ||
// } | ||
// return atoms; | ||
// }, [ ]); | ||
// } | ||
|
||
module.exports = { | ||
render: function (mobiledoc) { | ||
var renderer = new Renderer(options), | ||
rendered = renderer.render(mobiledoc), | ||
serializer = new SimpleDom.HTMLSerializer([]), | ||
html = serializer.serializeChildren(rendered.result); | ||
return html; | ||
} | ||
}; |
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,31 @@ | ||
var converter = require('../../../server/utils/mobiledoc-converter'); | ||
|
||
describe('Convert mobiledoc to HTML ', function () { | ||
var mobiledoc = { | ||
version: '0.3.1', | ||
atoms: [], | ||
cards: [ | ||
['markdown-card', | ||
{ | ||
pos: 'top', | ||
card_name: 'markdown-card', | ||
markdown: '#heading\n\n- list one\n- list two\n- list three' | ||
} | ||
], | ||
['markdown-card', { | ||
pos: 'top' | ||
}] | ||
], | ||
markups: [], | ||
sections: [ | ||
[1, 'p', [ | ||
[0, [], 0, 'test'] | ||
]], | ||
[10, 0], | ||
[10, 1] | ||
] | ||
}; | ||
it('Converts a mobiledoc to HTML', function () { | ||
converter.render(mobiledoc).should.match('<p>test</p><div><h1 id="heading">heading</h1>\n\n<ul>\n<li>list one</li>\n<li>list two</li>\n<li>list three</li>\n</ul></div><div></div>'); | ||
}); | ||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.