File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 18
18
require "qiita/markdown/embed/speeker_deck"
19
19
require "qiita/markdown/embed/docswell"
20
20
require "qiita/markdown/embed/figma"
21
+ require "qiita/markdown/embed/stack_blitz"
21
22
require "qiita/markdown/transformers/filter_attributes"
22
23
require "qiita/markdown/transformers/filter_script"
23
24
require "qiita/markdown/transformers/filter_iframe"
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module Qiita
4
+ module Markdown
5
+ module Embed
6
+ module StackBlitz
7
+ SCRIPT_HOST = "stackblitz.com"
8
+ end
9
+ end
10
+ end
11
+ end
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class FilterIframe
11
11
Embed ::Docswell ::SCRIPT_HOSTS ,
12
12
Embed ::Figma ::SCRIPT_HOST ,
13
13
Embed ::GoogleDrive ::SCRIPT_HOST ,
14
+ Embed ::StackBlitz ::SCRIPT_HOST ,
14
15
] . flatten . freeze
15
16
16
17
def self . call ( **args )
Original file line number Diff line number Diff line change 1747
1747
end
1748
1748
end
1749
1749
1750
+ context "with HTML embed code for StackBlitz" do
1751
+ shared_examples "embed code stackblitz example" do
1752
+ let ( :markdown ) do
1753
+ <<~MARKDOWN
1754
+ <iframe src="#{ url } " width="800" height="600" frameborder="0" allowfullscreen="true"></iframe>
1755
+ MARKDOWN
1756
+ end
1757
+ let ( :url ) { "#{ scheme } //stackblitz.com/embed/example" }
1758
+
1759
+ if allowed
1760
+ it "does not sanitize embed code" do
1761
+ should eq <<~HTML
1762
+ < iframe src ="#{ url } " width="800" height="600" frameborder="0" allowfullscreen="true"> </ iframe>
1763
+ HTML
1764
+ end
1765
+ else
1766
+ it "forces width attribute on iframe" do
1767
+ should eq <<~HTML
1768
+ < iframe src ="#{ url } " width="100%" height="600" frameborder="0" allowfullscreen="true"> </ iframe>
1769
+ HTML
1770
+ end
1771
+ end
1772
+ end
1773
+
1774
+ context "with scheme" do
1775
+ let ( :scheme ) { "https:" }
1776
+
1777
+ include_examples "embed code stackblitz example"
1778
+ end
1779
+
1780
+ context "without scheme" do
1781
+ let ( :scheme ) { "" }
1782
+
1783
+ include_examples "embed code stackblitz example"
1784
+ end
1785
+ end
1786
+
1750
1787
context "with embed code for Tweet" do
1751
1788
let ( :markdown ) do
1752
1789
<<-MARKDOWN . strip_heredoc
You can’t perform that action at this time.
0 commit comments